<?php $bp = defined('BASE_PATH') ? BASE_PATH : '/gmind'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= htmlspecialchars($title ?? 'Admin Login', ENT_QUOTES, 'UTF-8') ?> | Gmind Admin</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@600;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="<?= $bp ?>/css/admin.css">
</head>
<body class="admin-login-body">
    <div class="admin-login-container">
        <div class="admin-login-card">
            <!-- Branding -->
            <div class="admin-login-brand">
                <span class="admin-logo-text">GMIND</span>
                <span class="admin-logo-subtext">INSTITUTE</span>
                <p class="admin-login-tagline">Admin Panel</p>
            </div>

            <!-- Flash Messages -->
            <?php if (!empty($flash_error)): ?>
            <div class="admin-alert admin-alert-error">
                <span><?= htmlspecialchars($flash_error, ENT_QUOTES, 'UTF-8') ?></span>
            </div>
            <?php endif; ?>

            <?php if (!empty($flash_success)): ?>
            <div class="admin-alert admin-alert-success">
                <span><?= htmlspecialchars($flash_success, ENT_QUOTES, 'UTF-8') ?></span>
            </div>
            <?php endif; ?>

            <!-- Login Form -->
            <form method="POST" action="<?= $bp ?>/admin/login" class="admin-login-form" novalidate>
                <input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrfToken ?? '', ENT_QUOTES, 'UTF-8') ?>">

                <div class="admin-form-group">
                    <label for="email" class="admin-form-label">Email Address</label>
                    <input type="email" id="email" name="email" class="admin-form-input"
                           placeholder="superadmin@gmind.in" required autofocus
                           value="<?= htmlspecialchars($_POST['email'] ?? '', ENT_QUOTES, 'UTF-8') ?>">
                </div>

                <div class="admin-form-group">
                    <label for="password" class="admin-form-label">Password</label>
                    <input type="password" id="password" name="password" class="admin-form-input"
                           placeholder="Enter your password" required>
                </div>

                <button type="submit" class="admin-btn admin-btn-primary admin-btn-block">
                    Sign In
                </button>
            </form>

            <div class="admin-login-footer">
                <a href="<?= $bp ?>/branch/login">Branch Admin Login &rarr;</a>
                <span style="margin: 0 8px; color: #999;">|</span>
                <a href="<?= $bp ?>/">&larr; Back to Website</a>
            </div>
        </div>
    </div>
</body>
</html>
