<?php
declare(strict_types=1);
/** @var array{ok:?string,err:?string} $flash */

require_once __DIR__ . '/http_helpers.php';
$flash = $flash ?? ['ok' => null, 'err' => null];
$csrf = \SeoScope\Auth\AdminCsrf::token();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= seoscope_h(__('setup.title')) ?> — <?= seoscope_h(__('app.name')) ?></title>
    <link rel="stylesheet" href="<?= seoscope_h(seoscope_url('/assets/fonts/inter/inter.css')) ?>">
    <link rel="stylesheet" href="<?= seoscope_h(seoscope_url('/assets/vendor/bootstrap/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?= seoscope_h(seoscope_url('/assets/admin-template/css/admin-template.css')) ?>">
</head>
<body class="login-page">
    <div class="login-shell">
        <div class="login-wrapper">
            <div class="login-card" style="max-width: 520px; margin: 0 auto;">
                <h2 class="fw-800 mb-2"><?= seoscope_h(__('setup.title')) ?></h2>
                <p class="subtitle mb-4"><?= seoscope_h(__('setup.subtitle')) ?></p>

                <?php if (!empty($flash['err'])): ?>
                    <div class="alert alert-danger mb-3"><?= seoscope_h((string) $flash['err']) ?></div>
                <?php elseif (!empty($flash['ok'])): ?>
                    <div class="alert alert-success mb-3"><?= seoscope_h((string) $flash['ok']) ?></div>
                <?php endif; ?>

                <form method="post" action="<?= seoscope_h(seoscope_url('/setup')) ?>">
                    <input type="hidden" name="_csrf" value="<?= seoscope_h($csrf) ?>">

                    <div class="mb-3">
                        <label class="form-label" for="email"><?= seoscope_h(__('auth.email')) ?></label>
                        <input class="form-control" type="email" id="email" name="email" required autocomplete="username" placeholder="name@example.com">
                    </div>

                    <div class="mb-3">
                        <label class="form-label" for="password"><?= seoscope_h(__('auth.password')) ?></label>
                        <input class="form-control" type="password" id="password" name="password" required autocomplete="new-password" placeholder="••••••••">
                        <div class="text-muted small mt-1"><?= seoscope_h(__('setup.password_hint')) ?></div>
                    </div>

                    <button type="submit" class="btn-login"><?= seoscope_h(__('setup.create_admin')) ?></button>
                </form>
            </div>
        </div>
    </div>
</body>
</html>

