<?php
// um-admin/index.php — Admin Login
if (session_status() === PHP_SESSION_NONE) session_start();
if (!empty($_SESSION['um_admin'])) { header('Location: dashboard.php'); exit; }

$err = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (trim($_POST['pass'] ?? '') === 'LOL1122') {
        $_SESSION['um_admin'] = true;
        header('Location: dashboard.php'); exit;
    }
    $err = 'Invalid password. Try again.';
}
?><!DOCTYPE html>
<html lang="en"><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Admin — PakClub</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
*{box-sizing:border-box;margin:0;padding:0}
body{background:#0b0e18;min-height:100vh;display:flex;align-items:center;justify-content:center;font-family:'Segoe UI',sans-serif}
.card{background:rgba(255,255,255,.04);backdrop-filter:blur(20px);border:1px solid rgba(255,255,255,.08);border-radius:20px;padding:50px 40px;width:100%;max-width:420px;box-shadow:0 30px 80px rgba(0,0,0,.6)}
.logo{text-align:center;margin-bottom:36px}
.logo-icon{width:64px;height:64px;background:linear-gradient(135deg,#f26d0f,#c45a0a);border-radius:18px;display:inline-flex;align-items:center;justify-content:center;font-size:28px;color:#fff;margin-bottom:14px;box-shadow:0 10px 30px rgba(242,109,15,.4)}
.logo h1{color:#fff;font-size:22px;font-weight:700}
.logo p{color:#8892a4;font-size:13px;margin-top:4px}
.field{margin-bottom:20px}
.field label{display:block;color:#8892a4;font-size:12px;font-weight:600;text-transform:uppercase;letter-spacing:.8px;margin-bottom:8px}
.input-wrap{position:relative}
.input-wrap i{position:absolute;left:16px;top:50%;transform:translateY(-50%);color:#8892a4;font-size:15px}
input[type=password]{width:100%;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.1);border-radius:10px;padding:14px 16px 14px 44px;color:#fff;font-size:15px;outline:none;transition:border-color .2s}
input[type=password]:focus{border-color:#f26d0f}
.err{background:rgba(239,68,68,.1);border:1px solid rgba(239,68,68,.3);border-radius:8px;padding:12px 16px;color:#f87171;font-size:13px;margin-bottom:20px;display:flex;align-items:center;gap:8px}
.btn{width:100%;background:linear-gradient(135deg,#f26d0f,#c45a0a);color:#fff;border:none;border-radius:10px;padding:15px;font-size:16px;font-weight:700;cursor:pointer;transition:opacity .2s;box-shadow:0 6px 20px rgba(242,109,15,.4)}
.btn:hover{opacity:.9}
.toggle-eye{position:absolute;right:16px;top:50%;transform:translateY(-50%);color:#8892a4;cursor:pointer;font-size:15px}
</style>
</head><body>
<div class="card">
  <div class="logo">
    <div class="logo-icon"><i class="fa-solid fa-shield-halved"></i></div>
    <h1>PakClub Admin</h1>
    <p>Restricted access — authorised personnel only</p>
  </div>
  <?php if($err): ?><div class="err"><i class="fa-solid fa-circle-exclamation"></i><?= htmlspecialchars($err) ?></div><?php endif; ?>
  <form method="POST" autocomplete="off">
    <div class="field">
      <label>Admin Password</label>
      <div class="input-wrap">
        <i class="fa-solid fa-lock"></i>
        <input type="password" name="pass" id="passInput" placeholder="Enter admin password" required autofocus>
        <span class="toggle-eye" onclick="togglePwd()"><i class="fa-solid fa-eye-slash" id="eyeIcon"></i></span>
      </div>
    </div>
    <button type="submit" class="btn"><i class="fa-solid fa-right-to-bracket"></i> &nbsp;Sign In</button>
  </form>
</div>
<script>
function togglePwd(){
  const i=document.getElementById('passInput'),e=document.getElementById('eyeIcon');
  if(i.type==='password'){i.type='text';e.className='fa-solid fa-eye';}
  else{i.type='password';e.className='fa-solid fa-eye-slash';}
}
</script>
</body></html>
