<?= $this->extend('layouts/auth') ?>

<?= $this->section('title') ?>Login<?= $this->endSection() ?>

<?= $this->section('main') ?>
    <div class="grid w-full gap-8 lg:grid-cols-[1.05fr_0.95fr]">
        <section class="flex items-center">
            <div class="max-w-xl">
                <span class="inline-flex items-center rounded-full bg-sky-100 px-4 py-2 text-xs font-semibold uppercase tracking-[0.2em] text-sky-700">Admin Splash Academy</span>
                <h1 class="mt-6 text-4xl font-semibold tracking-tight text-slate-950 lg:text-5xl">Management clar pentru evaluari, prezenta si progres la inot.</h1>
                <p class="mt-5 text-lg leading-8 text-slate-600">Autentificarea deschide dashboard-ul real pentru Admin si Trainer, alimentat direct din MySQL si seed-uit cu date coerente.</p>
            </div>
        </section>

        <section class="surface-card mx-auto w-full max-w-md p-8 lg:ml-auto">
            <div>
                <p class="text-sm font-semibold uppercase tracking-[0.2em] text-slate-400">Welcome back</p>
                <h2 class="mt-3 text-2xl font-semibold tracking-tight text-slate-950">Sign in to Splash Academy</h2>
            </div>

            <?php if (session('error') !== null) : ?>
                <div class="mt-6 rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700"><?= esc(session('error')) ?></div>
            <?php endif ?>

            <?php if (session('errors') !== null) : ?>
                <div class="mt-6 rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700">
                    <?php foreach ((array) session('errors') as $error) : ?>
                        <div><?= esc($error) ?></div>
                    <?php endforeach ?>
                </div>
            <?php endif ?>

            <?php if (session('message') !== null) : ?>
                <div class="mt-6 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-700"><?= esc(session('message')) ?></div>
            <?php endif ?>

            <form action="<?= url_to('login') ?>" method="post" class="mt-8 space-y-5">
                <?= csrf_field() ?>

                <div>
                    <label for="email" class="mb-2 block text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Email</label>
                    <input id="email" type="email" name="email" value="<?= old('email') ?>" class="form-input" placeholder="admin@academia.local" required>
                </div>

                <div>
                    <label for="password" class="mb-2 block text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Password</label>
                    <input id="password" type="password" name="password" class="form-input" placeholder="••••••••" required>
                </div>

                <?php if (setting('Auth.sessionConfig')['allowRemembering']) : ?>
                    <label class="inline-flex items-center gap-3 text-sm text-slate-600">
                        <input type="checkbox" name="remember" value="1" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-500">
                        Pastreaza sesiunea activa
                    </label>
                <?php endif; ?>

                <button type="submit" class="inline-flex w-full items-center justify-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-soft transition hover:bg-indigo-500">
                    Login
                </button>
            </form>
        </section>
    </div>
<?= $this->endSection() ?>
