<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // For demo: hardcoded credentials
    $username = $_POST['username'];
    $password = $_POST['password'];

    if ($username === 'admin' && $password === 'admin123') {
        $_SESSION['user'] = $username;
        $_SESSION['role'] = 'admin';
        header('Location: dashboard.php');
        exit;
    } else {
        $error = "Invalid credentials";
    }
}
?>
<?php
if(!isset($_SESSION)) { session_start(); }
?>
<!DOCTYPE html>
<html>
<head>
    <title>Freestyle Scoring App</title>
    <?php include_once '../includes/stylesheets.php'; ?>

</head>
<body class="body-bg-aurora-bright">
    <?php include '../menu.php'; ?>

<div class="container-fluid container-StyleScore p-4">
    
<h2>Admin Login</h2>
<?php if (!empty($error)) echo "<div class='alert alert-danger'>$error</div>"; ?>
<form method="post">
    <div class="mb-3">
        <label for="username" class="form-label">Username</label>
        <input type="text" class="form-control" name="username" required>
    </div>
    <div class="mb-3">
        <label for="password" class="form-label">Password</label>
        <input type="password" class="form-control" name="password" required>
    </div>
    <button type="submit" class="btn btn-primary">Login</button>
</form>

</div>
</body>
</html>