<?php
require_once dirname(__DIR__) . '/includes/functions.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $pdo = db();
    $username = trim((string)($_POST['username'] ?? ''));
    $password = (string)($_POST['password'] ?? '');
    if ($pdo) {
        $stmt = $pdo->prepare('SELECT * FROM admin_users WHERE username = :username LIMIT 1');
        $stmt->execute([':username' => $username]);
        $admin = $stmt->fetch();
        if ($admin && password_verify($password, $admin['password_hash'])) {
            session_regenerate_id(true);
            $_SESSION['admin_id'] = (int)$admin['id'];
            $_SESSION['admin_username'] = $admin['username'];
            header('Location: dashboard.php');
            exit;
        }
    }
    $error = 'Kullanici adi veya sifre hatali.';
}
?>
<!doctype html><html lang="tr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>ASSK Admin Giris</title><link rel="stylesheet" href="<?= e(url('assets/css/style.css')) ?>"></head>
<body class="login-body"><form class="login-card glass-card" method="post"><span class="brand-mark">A</span><h1>ASSK Admin</h1><p>Premium yuzme kursu paneli</p><?php if ($error): ?><div class="flash"><?= e($error) ?></div><?php endif; ?><label>Kullanici adi<input name="username" required autofocus></label><label>Sifre<input name="password" type="password" required></label><button class="btn btn-primary" type="submit">Panele Gir</button><small>Varsayilan: admin / Admin123!</small></form></body></html>
