<?php
session_start();
// PERBAIKAN: Sesuaikan nama session dengan yang ada di login_proses.php
if (isset($_SESSION['is_logged_in'])) {
    header("Location: dashboard.php");
    exit;
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Admin Tangkis</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../assets/css/style.css">
    <style>
        body { background-color: #f8f9fa; }
        .login-container { max-width: 400px; margin-top: 100px; }
    </style>
</head>
<body>

<div class="container login-container">
    <div class="card shadow-sm border-0">
        <div class="card-header bg-primary text-white text-center py-3">
            <h4 class="mb-0">Login Admin Tangkis</h4>
            <small>BPS Kabupaten Lampung Timur</small>
        </div>
        <div class="card-body p-4">
            
            <?php if (isset($_GET['error'])): ?>
                <div class="alert alert-danger small text-center">
                    <?= htmlspecialchars($_GET['error']) ?>
                </div>
            <?php endif; ?>

            <?php if (isset($_GET['pesan']) && $_GET['pesan'] == 'logout_berhasil'): ?>
                <div class="alert alert-success small text-center">
                    Anda telah berhasil keluar (logout).
                </div>
            <?php endif; ?>

            <form method="POST" action="login_proses.php"> 
                <div class="mb-3">
                    <label class="form-label">Username</label>
                    <input type="text" name="username" class="form-control" required placeholder="Masukkan username">
                </div>

                <div class="mb-3">
                    <label class="form-label">Password</label>
                    <input type="password" name="password" class="form-control" required placeholder="Masukkan password">
                </div>

                <div class="d-grid gap-2 mt-4">
                    <button type="submit" class="btn btn-primary">Masuk ke Dashboard</button>
                    <a href="../pelapor/index.php" class="btn btn-outline-secondary">Kembali ke Beranda</a>
                </div>
            </form>
        </div>
    </div>
    <div class="text-center mt-4 text-muted small">
        © <?= date('Y') ?> BPS Kabupaten Lampung Timur
    </div>
</div>

</body>
</html>