<?php
session_start();
include '../config/database.php';

if (isset($_POST['login'])) {
    $user = $_POST['user'];
    $pass = $_POST['pass'];

    $stmt = $conn->prepare("SELECT * FROM admin_settings WHERE admin_user = ? AND admin_pass = ?");
    $stmt->execute([$user, $pass]);
    $admin = $stmt->fetch();

    if ($admin) {
        $_SESSION['admin_logged_in'] = true;
        header("Location: index.php");
    } else {
        $error = "بيانات الدخول غير صحيحة!";
    }
}
?>
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
    <meta charset="UTF-8">
    <title>تسجيل دخول المدير</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <style>
        body { background: #001f3f; color: white; height: 100vh; display: flex; align-items: center; justify-content: center; }
        .login-card { background: rgba(255,255,255,0.1); padding: 30px; border-radius: 20px; backdrop-filter: blur(10px); width: 400px; }
    </style>
</head>
<body>
    <div class="login-card text-center">
        <h3>لوحة إدارة فستيفال لاند</h3>
        <?php if(isset($error)) echo "<div class='alert alert-danger'>$error</div>"; ?>
        <form method="POST">
            <input type="text" name="user" class="form-control mb-3" placeholder="اسم المستخدم" required>
            <input type="password" name="pass" class="form-control mb-3" placeholder="كلمة السر" required>
            <button name="login" class="btn btn-warning w-100">دخول</button>
        </form>
    </div>
</body>
</html>
