<?php
require_once __DIR__ . '/../includes/auth.php';
if (!empty($_SESSION['admin_user_id'])) {
redirect('index.php');
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!csrf_verify()) {
$error = 'Session expired, please try again.';
} else {
$username = trim($_POST['username'] ?? '');
$password = $_POST['password'] ?? '';
if ($username !== '' && $password !== '' && attempt_login($username, $password)) {
redirect('index.php');
} else {
$error = 'Invalid username or password.';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Login | Excellent Education</title>
<link rel="icon" type="image/png" href="../assets/img/logo-icon.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800&family=Outfit:wght@600;700;800&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<script>
tailwind.config = { theme: { extend: { colors: { brand: { red:'#E31E24', green:'#2E9B38', gold:'#F5B400', black:'#0A0A0A' } },
fontFamily: { heading:['Outfit','sans-serif'], body:['Poppins','sans-serif'] } } } }
</script>
<style>body{font-family:'Poppins',sans-serif} h1,h2{font-family:'Outfit',sans-serif}</style>
</head>
<body class="min-h-screen flex items-center justify-center bg-brand-black bg-[radial-gradient(circle_at_20%_20%,rgba(46,155,56,0.15),transparent_40%),radial-gradient(circle_at_80%_80%,rgba(227,30,36,0.15),transparent_40%)] px-4">
<div class="w-full max-w-md">
<div class="text-center mb-8">
<img src="../assets/img/logo-full.png" alt="Excellent Education" class="h-14 mx-auto mb-2">
<p class="text-gray-400 text-sm">Admin Panel Login</p>
</div>
<div class="bg-white rounded-2xl shadow-2xl p-8 border-t-4 border-brand-gold">
<?php if ($error): ?>
<div class="mb-5 px-4 py-3 rounded-xl bg-red-50 text-brand-red text-sm font-medium border border-red-200">
<i class="fa-solid fa-circle-exclamation mr-2"></i><?= e($error) ?>
</div>
<?php endif; ?>
<form method="post" class="space-y-4">
<?= csrf_field() ?>
<div>
<label class="block text-sm font-medium mb-1.5">Username or Email</label>
<input type="text" name="username" required autofocus class="w-full rounded-xl border border-gray-300 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-brand-green">
</div>
<div>
<label class="block text-sm font-medium mb-1.5">Password</label>
<input type="password" name="password" required class="w-full rounded-xl border border-gray-300 px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-brand-green">
</div>
<button type="submit" class="w-full bg-gradient-to-r from-brand-red to-brand-green text-white font-semibold py-3 rounded-xl hover:brightness-110 transition">
Log In <i class="fa-solid fa-arrow-right-to-bracket ml-1"></i>
</button>
</form>
</div>
<p class="text-center text-gray-500 text-xs mt-6">Default: admin / Admin@123 — change this immediately after first login.</p>
</div>
</body>
</html>