<?php
session_start();
require_once '../includes/database.php';

// Simple admin authentication (in production, use secure authentication)
if($_POST) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    
    // Simple hardcoded admin credentials (change these in production)
    $admin_username = 'admin';
    $admin_password = 'admin123'; // In production, use hashed passwords
    
    if($username === $admin_username && $password === $admin_password) {
        $_SESSION['admin_logged_in'] = true;
        header('Location: index.php');
        exit;
    } else {
        $error = "Invalid admin credentials!";
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Admin Login - FantasyVote</title>
    <link rel="stylesheet" href="../css/style.css">
</head>
<body>
    <div class="container">
        <div class="auth-form">
            <h2>Admin Login</h2>
            
            <?php if(isset($error)): ?>
                <div class='alert error'><?php echo $error; ?></div>
            <?php endif; ?>
            
            <form method="POST">
                <div class="form-group">
                    <label>Username:</label>
                    <input type="text" name="username" required>
                </div>
                <div class="form-group">
                    <label>Password:</label>
                    <input type="password" name="password" required>
                </div>
                <button type="submit" class="btn btn-primary">Login</button>
            </form>
            
            <p><a href="../index.php">← Back to Main Site</a></p>
        </div>
    </div>
</body>
</html>