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

if(isset($_SESSION['admin_logged_in']) && $_SESSION['admin_logged_in'] === true){
    header("Location: dashboard.php");
    exit;
}

$error = "";

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

    // HARD-CODED MASTER ADMIN LOGIN
    if($email === "admin@fxhunterai.com" && $pass === "FxHunter@Admin2025"){
        $_SESSION['admin_logged_in'] = true;
        header("Location: dashboard.php");
        exit;
    } else {
        $error = "Invalid admin credentials.";
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<title>FXH Admin Login</title>
</head>
<body>
<h2>Admin Login</h2>
<form method="POST">
    <input type="email" name="email" placeholder="Admin Email" required><br>
    <input type="password" name="password" placeholder="Password" required><br>
    <button type="submit">Login</button>
</form>
<p style="color:red"><?= $error ?></p>
</body>
</html>
