<?php
session_start();
if (isset($_SESSION['admin_logged_in'])) {
  header("Location: admin_dashboard.php");
  exit;
}
$notif = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  $username = isset($_POST['username']) ? $_POST['username'] : '';
  $password = isset($_POST['password']) ? $_POST['password'] : '';


  // Ganti sesuai username & password admin
  if ($username === 'adminkuy' && $password === 'Sukabumi2018') {
    $_SESSION['admin_logged_in'] = true;
    header("Location: admin_dashboard.php");
    exit;
  } else {
    $notif = "❌ Username atau password salah.";
  }
}
?>
<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <title>Login Admin</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    * {
      box-sizing: border-box;
    }
    body {
      font-family: Arial, sans-serif;
      background: #f7f7f7;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
      padding: 20px;
    }
    .login-box {
      background: white;
      padding: 30px;
      border-radius: 12px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
      width: 100%;
      max-width: 400px;
      text-align: center;
    }
    .login-box img {
      width: 100px;
      height: 100px;
      border-radius: 50%;
      object-fit: cover;
      border: 2px solid #ccc;
      margin-bottom: 20px;
    }
    .login-box h1 {
      margin-bottom: 24px;
      font-size: 22px;
      color: #333;
    }
    .login-box input {
      width: 100%;
      padding: 12px;
      margin-bottom: 14px;
      font-size: 15px;
      border-radius: 8px;
      border: 1px solid #ccc;
    }
    .login-box button {
      width: 100%;
      padding: 12px;
      font-size: 16px;
      background: #ffc357;
      color: white;
      border: none;
      border-radius: 8px;
      cursor: pointer;
      font-weight: bold;
    }
    .notif {
      margin-bottom: 16px;
      color: red;
      font-size: 14px;
    }
  </style>
</head>
<body>
<div class="login-box">
  <img src="assets/logo_akunkuy.jpg" alt="Logo Akunkuy">
  <h1>Login Admin</h1>

  <?php if ($notif): ?>
    <div class="notif"><?= $notif ?></div>
  <?php endif; ?>

  <form method="POST">
    <input type="text" name="username" placeholder="Username" required>
    <input type="password" name="password" placeholder="Password" required>
    <button type="submit">Masuk</button>
  </form>
</div>
</body>
</html>
