<?php
/**
 * admin/login.php
 * -----------------------------------------------------------------
 * Simple password gate for the manual activation admin panel.
 * -----------------------------------------------------------------
 */
session_start();

define('ADMIN_SECRET_PATH', '/home/caracuanbiz/admin-secret.php');

$error = '';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $submitted = (string)($_POST['password'] ?? '');
    $correct = is_file(ADMIN_SECRET_PATH) ? (string)include ADMIN_SECRET_PATH : null;

    if ($correct === null) {
        $error = 'Server is missing admin-secret.php. See setup notes in admin-secret.example.php.';
    } elseif (hash_equals($correct, $submitted)) {
        $_SESSION['clyde_admin'] = true;
        header('Location: index.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.0">
<title>Admin Login — Clyde 37-DE Dashboard</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');
*{box-sizing:border-box;}
body{
  margin:0;min-height:100vh;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(ellipse at top,#1a1e22 0%,#15181b 55%);
  font-family:'Inter',sans-serif;
  color:#ece9e2;
}
.box{
  background:linear-gradient(180deg,#23282d,#1a1e22);
  border:1px solid #a8841f;
  border-radius:10px;
  padding:32px 28px;
  width:100%;max-width:340px;
}
.box .eyebrow{
  font-family:'JetBrains Mono',monospace;
  font-size:11px;letter-spacing:0.12em;color:#ffc52f;text-transform:uppercase;
}
.box h1{
  font-family:'Oswald',sans-serif;text-transform:uppercase;
  font-size:22px;margin:6px 0 18px 0;color:#ece9e2;
}
input[type=password]{
  width:100%;font-family:'JetBrains Mono',monospace;font-size:14px;
  background:#0e1113;border:1px solid #343a40;color:#ece9e2;
  padding:11px 12px;border-radius:6px;margin-bottom:12px;
}
input[type=password]:focus{outline:1px solid #a8841f;}
button{
  width:100%;font-family:'Oswald',sans-serif;text-transform:uppercase;letter-spacing:0.03em;
  background:#ffc52f;color:#15181b;border:none;border-radius:6px;
  padding:12px 0;font-weight:700;font-size:14px;cursor:pointer;
}
button:hover{filter:brightness(1.08);}
.err{
  background:rgba(255,82,82,0.1);border:1px solid rgba(255,82,82,0.4);
  color:#ff5252;font-size:12.5px;padding:9px 11px;border-radius:6px;margin-bottom:12px;
}
</style>
</head>
<body>
  <form class="box" method="POST">
    <div class="eyebrow">Clyde 37-DE / RCI-1550</div>
    <h1>Admin Login</h1>
    <?php if ($error): ?><div class="err"><?php echo htmlspecialchars($error); ?></div><?php endif; ?>
    <input type="password" name="password" placeholder="Admin password" autofocus required>
    <button type="submit">Login</button>
  </form>
</body>
</html>