<?php
session_start();
// Simple admin login (demo). In production use hashed passwords and DB.
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $user = $_POST['username'] ?? '';
    $pass = $_POST['password'] ?? '';
    // demo credentials
    if ($user === 'admin' && $pass === 'admin123') {
        $_SESSION['is_admin'] = true;
        header('Location: index.php'); exit;
    } else {
        $error = 'Invalid credentials';
    }
}
?>
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>Admin Login - Esa's Fashion</title>
  <link rel="stylesheet" href="/ecom/styles.css">
  <style> .login-box{ max-width:420px;margin:40px auto;padding:20px;background:#fff;border-radius:8px; }
  .login-box input{ width:100%; padding:8px; margin-bottom:10px; border:1px solid #e6e6e6; border-radius:6px; }
  </style>
</head>
<body>
<?php include __DIR__ . '/../header.php'; ?>
<main class="container">
  <div class="login-box">
    <h2>Admin Login</h2>
    <?php if ($error): ?><p class="muted"><?php echo htmlspecialchars($error); ?></p><?php endif; ?>
    <form method="post">
      <input name="username" placeholder="Username" autocomplete="username" required>
      <input name="password" type="password" placeholder="Password" autocomplete="current-password" required>
      <button class="btn" type="submit">Login</button>
    </form>
    <!-- <p class="muted" style="margin-top:10px">Demo admin: <strong>admin</strong> / <strong>admin123</strong></p> -->
  </div>
</main>
<?php include __DIR__ . '/../footer.php'; ?>
</body>
</html>
