<?php
$title = 'Daftar';
$description = 'Form registrasi akun baru.';
$errors = flash('errors', []);
?>
<section class="auth-wrap">
    <div class="container">
        <div class="card auth-card">
            <div class="card-header">
                <span class="eyebrow">Buat akun</span>
                <h1>Daftar akun baru</h1>
                <p>Isi data berikut untuk membuat akun client.</p>
            </div>

            <?php if ($status = flash('status')): ?>
                <div class="alert alert-success"><?= e($status) ?></div>
            <?php endif; ?>

            <?php if ($errors !== []): ?>
                <div class="alert alert-error">
                    <strong>Periksa kembali isian:</strong>
                    <ul class="field-errors">
                        <?php foreach ($errors as $messages): ?>
                            <?php foreach ((array) $messages as $message): ?>
                                <li><?= e($message) ?></li>
                            <?php endforeach; ?>
                        <?php endforeach; ?>
                    </ul>
                </div>
            <?php endif; ?>

            <form class="form-grid" action="<?= e(url('/register')) ?>" method="post" novalidate>
                <?= csrf() ?>
                <div class="field">
                    <label for="nama">Nama Lengkap</label>
                    <input id="nama" name="nama" type="text" value="<?= e(old('nama')) ?>" autocomplete="name" placeholder="Nama lengkap">
                </div>
                <div class="field">
                    <label for="whatsapp">WhatsApp</label>
                    <input id="whatsapp" name="whatsapp" type="text" value="<?= e(old('whatsapp')) ?>" autocomplete="tel" placeholder="6281234567890">
                    <small class="form-hint">Gunakan angka, boleh diawali +.</small>
                </div>
                <div class="field">
                    <label for="email">Email</label>
                    <input id="email" name="email" type="email" value="<?= e(old('email')) ?>" autocomplete="email" placeholder="nama@email.com">
                </div>
                <div class="field">
                    <label for="password">Password</label>
                    <input id="password" name="password" type="password" autocomplete="new-password" placeholder="Minimal 8 karakter">
                </div>
                <div class="field">
                    <label for="password_confirmation">Konfirmasi Password</label>
                    <input id="password_confirmation" name="password_confirmation" type="password" autocomplete="new-password" placeholder="Ulangi password">
                </div>
                <div class="form-footer">
                    <button class="button-primary" type="submit">Daftar</button>
                    <p class="footer-note">Sudah punya akun? <a href="<?= e(url('/login')) ?>">Login</a></p>
                </div>
            </form>
        </div>
    </div>
</section>
