<?php
session_start();

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

  // Sederhana, bisa ganti nanti dengan DB atau enkripsi
  if ($username === 'admin' && $password === 'admin123') {
    $_SESSION['admin'] = true;
    header('Location: menu_admin.php');
    exit;
  } else {
    $error = "Username atau password salah!";
  }
}
?>

<!DOCTYPE html>
<html lang="id">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Login Admin</title>
  <style>
    body { font-family: Arial; background: #f0f0f0; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
    .login-box {
      background: white; padding: 30px; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.1);
      max-width: 400px; width: 100%;
    }
    h2 { text-align: center; margin-bottom: 20px; color: #4CAF50; }
    input[type="text"], input[type="password"] {
      width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box;
    }
    button {
      width: 100%; padding: 12px; background-color: #4CAF50; color: white; border: none; border-radius: 6px; font-size: 16px; cursor: pointer;
    }
    button:hover { background-color: #45a049; }
    .error { color: red; text-align: center; margin-bottom: 10px; }
  </style>
</head>
<body>
  <div class="login-box">
    <h2>🔐 Login Admin</h2>
    <?php if (isset($error)): ?>
      <div class="error"><?= $error ?></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">Login</button>
    </form>
  </div>
</body>
</html>
