<?php
session_start();
$correct_password = 'wuhuan'; // 🔐 Change this to your real password
$error = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  if ($_POST['password'] === $correct_password) {
    $_SESSION['logged_in'] = true;
    header('Location: upload.php');
    exit;
  } else {
    $error = 'Incorrect password.';
  }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>Admin Login</title>
  <style>
    :root {
      --bg: #0b1020;
      --card: #121830;
      --muted: #a9b3c9;
      --text: #e9edf6;
      --accent: #6fb1ff;
    }

    html, body {
      margin: 0;
      background: linear-gradient(180deg, #0b1020, #0c1430);
    }

    body {
      font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, sans-serif;
      color: var(--text);
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 100vh;
    }

    .wrap {
      width: 100%;
      max-width: 420px;
      padding: 0 16px;
    }

    h1 {
      margin-bottom: 12px;
      font-size: clamp(24px, 4vw, 32px);
      text-align: center;
    }

    .card {
      background: var(--card);
      border: 1px solid #223;
      border-radius: 16px;
      padding: 24px;
      box-shadow: 0 10px 28px rgba(0, 0, 0, .25);
    }

    label {
      display: block;
      margin-bottom: 8px;
      font-weight: 500;
    }

    input {
      background: #666666;
      border: 1px solid #223;
      color: var(--text);
      padding: 10px 12px;
      border-radius: 12px;
      outline: none;
      width: 100%;
      margin-bottom: 16px;
      transition: box-shadow 0.2s ease, border-color 0.2s ease;
    }

    /* 💡 Glowing focus effect */
    input:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(111, 177, 255, 0.4);
    }

    .btn {
      background: var(--accent);
      color: #031225;
      border: 0;
      padding: 10px 14px;
      border-radius: 12px;
      font-weight: 700;
      cursor: pointer;
      width: 100%;
      transition: background 0.2s ease;
    }

    .btn:hover {
      background: #87c1ff;
    }

    .error {
      margin-top: 10px;
      color: #f87171;
      font-size: 14px;
      text-align: center;
    }

    .footer {
      text-align: center;
      margin-top: 18px;
      font-size: 13px;
      color: var(--muted);
    }

    .footer a {
      color: var(--accent);
      text-decoration: none;
    }

    .footer a:hover {
      text-decoration: underline;
    }
  </style>
</head>
<body>
  <div class="wrap">
    <h1>Admin Login</h1>
    <div class="card">
      <form method="post" action="">
        <label for="password">Enter Password</label>
        <input type="password" id="password" name="password" required autofocus>
        <button type="submit" class="btn">Login</button>
        <?php if (!empty($error)) echo "<div class='error'>$error</div>"; ?>
      </form>
    </div>
    <div class="footer">
      <p>© <?= date('Y') ?> Equipment Drawings System</p>
      <p><a href="index.html">← Back to main site</a></p>
    </div>
  </div>
</body>
</html>
