<?php
session_start();
require_once __DIR__ . '/../includes/auth_paths.php';

$config = ah_load_auth_config();
$isLocal = ah_is_local_env();
$tempEnabled = $isLocal && (($config['temp_local_login'] ?? true) !== false);
$tempUser = (string)($config['temp_local_username'] ?? 'admin');
$tempPass = (string)($config['temp_local_password'] ?? 'temp123');
$error = $_SESSION['login_error'] ?? '';
unset($_SESSION['login_error']);
?>
<?php include('../header.php'); ?>
<?php include('../menu.php'); ?>
<link rel="stylesheet" href="/css/style.css?v=2">

<main class="main-container login-shell">
  <section class="login-hero-card">
    <div class="login-hero-copy">
      <span class="section-kicker">Almost Heaven Admin</span>
      <h2 class="text-warning">Station control, page builder, and live tools</h2>
      <p>Sign in to manage pages, events, requests, team content, and the Smurfettes-powered admin upgrades now running inside Almost Heaven.</p>

      <div class="login-feature-grid">
        <div class="login-feature-pill">✨ Visual page builder</div>
        <div class="login-feature-pill">🎙 DJ and schedule tools</div>
        <div class="login-feature-pill">💬 Contact, chat and fan tools</div>
        <div class="login-feature-pill">🛡 External auth ready</div>
      </div>

      <?php if ($tempEnabled): ?>
        <div class="login-dev-note">
          <strong>Local test login active</strong><br>
          Username: <code><?= htmlspecialchars($tempUser) ?></code> &nbsp; Password: <code><?= htmlspecialchars($tempPass) ?></code>
        </div>
      <?php endif; ?>
    </div>

    <div class="login-panel-card">
      <h3>🔐 Admin Login</h3>
      <?php if ($error): ?>
        <div class="login-error-box"><?= htmlspecialchars($error) ?></div>
      <?php endif; ?>
      <form method="post" action="authenticate.php" class="admin-form login-form-v2">
        <label>Username</label>
        <input type="text" name="username" class="admin-input mb-2" placeholder="Enter username" required />
        <label>Password</label>
        <input type="password" name="password" class="admin-input mb-2" placeholder="Enter password" required />
        <button type="submit" class="btn btn-warning btn-login-wow">Enter Dashboard</button>
      </form>
    </div>
  </section>
</main>

<?php include('../footer.php'); ?>
