<?php
/**
 * Super Admin Login View
 *
 * Standalone login page (not wrapped in layout).
 * Purple-themed to distinguish from the existing /admin/login (navy).
 */
$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 ?? 'Super Admin Login', ENT_QUOTES, 'UTF-8') ?> | Gmind Super 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">
    <style>
        body { background: linear-gradient(135deg, #2c1e4a 0%, #1a1333 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
        .sa-login-card { background: #fff; border-radius: 16px; max-width: 440px; width: 100%; box-shadow: 0 20px 60px rgba(108, 63, 232, 0.3); overflow: hidden; }
        .sa-login-header { background: linear-gradient(135deg, #6c3fe8, #4a2db8); color: #fff; padding: 32px 28px; text-align: center; }
        .sa-login-header h1 { margin: 0; font-size: 1.6rem; font-family: 'Poppins', sans-serif; font-weight: 700; }
        .sa-login-header p { margin: 6px 0 0; opacity: 0.85; font-size: 0.9rem; }
        .sa-login-body { padding: 32px 28px; }
        .sa-login-body .admin-form-group { margin-bottom: 18px; }
        .sa-login-body label { display: block; font-size: 0.85rem; font-weight: 600; color: #2c1e4a; margin-bottom: 6px; }
        .sa-login-body input { width: 100%; padding: 12px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 0.95rem; transition: border-color 0.2s; box-sizing: border-box; }
        .sa-login-body input:focus { border-color: #6c3fe8; outline: none; box-shadow: 0 0 0 3px rgba(108, 63, 232, 0.1); }
        .sa-login-body button { width: 100%; padding: 14px; background: linear-gradient(135deg, #6c3fe8, #4a2db8); color: #fff; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; font-family: 'Poppins', sans-serif; transition: transform 0.2s, box-shadow 0.2s; }
        .sa-login-body button:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(108, 63, 232, 0.4); }
        .sa-login-footer { text-align: center; margin-top: 18px; padding-top: 18px; border-top: 1px solid #eee; font-size: 0.85rem; }
        .sa-login-footer a { color: #6c3fe8; text-decoration: none; }
        .sa-login-footer a:hover { text-decoration: underline; }
        .sa-login-badge { display: inline-block; background: rgba(255,255,255,0.2); color: #fff; padding: 4px 14px; border-radius: 50px; font-size: 0.75rem; font-weight: 600; margin-top: 10px; letter-spacing: 0.5px; }
        .sa-login-alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 0.88rem; }
        .sa-login-alert-error { background: #fff5f5; color: #c0392b; border: 1px solid #f5c6cb; }
        .sa-login-alert-success { background: #eafaf1; color: #1e7e34; border: 1px solid #c3e6cb; }
    </style>
</head>
<body>
    <div class="sa-login-card">
        <div class="sa-login-header">
            <h1>GMIND INSTITUTE</h1>
            <p>Super Admin Panel</p>
            <span class="sa-login-badge">SYSTEM OWNER ACCESS</span>
        </div>

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

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

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

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

                <button type="submit">Sign In to Super Admin</button>
            </form>

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