<?php
session_start();
require_once __DIR__ . '/../config.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $email = $_POST['email'] ?? '';
    $password = $_POST['password'] ?? '';

    if ($email === 'admin@example.com' && $password === 'admin123') {
        $_SESSION['admin_id'] = 1;
        header("Location: dashboard.php");
        exit;
    } else {
        $error = "Invalid email 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</title>
<style>
body {
    font-family: "Poppins", sans-serif;
    background: linear-gradient(135deg, #4c6ef5, #3b5bdb);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}
.login-container {
    background: #fff;
    padding: 40px 35px;
    border-radius: 12px;
    width: 350px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #333;
}
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
}
button {
    width: 100%;
    padding: 12px;
    border: none;
    background: #4c6ef5;
    color: #fff;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
}
button:hover {
    background: #364fc7;
}
.error {
    color: #d9534f;
    font-size: 14px;
    text-align: center;
    margin-bottom: 10px;
}
.footer {
    text-align: center;
    font-size: 13px;
    color: #888;
    margin-top: 20px;
}
</style>
</head>
<body>
<div class="login-container">
    <h2>Admin Login</h2>
    <?php if(!empty($error)) echo "<p class='error'>$error</p>"; ?>
    <form method="POST">
        <input type="email" name="email" placeholder="Email" required>
        <input type="password" name="password" placeholder="Password" required>
        <button type="submit">Login</button>
    </form>
    <div class="footer">© <?php echo date('Y'); ?> Accounts Book</div>
</div>
</body>
</html>
