<?php
// Admin header — Coinbase-style light topbar with dark hero band, requires
// the caller to have already run requireAdmin() before including this.
if (empty($pageTitle)) $pageTitle = 'Admin';
$currentPage = basename($_SERVER['PHP_SELF']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="robots" content="noindex, nofollow">
<title><?= htmlspecialchars($pageTitle) ?> - Admin · FamAPI</title>
<link rel="stylesheet" href="../assets/coinbase.css?v=9">
<style>
  .admin-hero {
    background: linear-gradient(135deg,#0a0e1a 0%,#00194d 60%,#003a94 100%);
    color:#fff;
    padding:34px 32px 30px;
    border-radius:0 0 28px 28px;
  }
  .admin-hero h1 { font-size:26px; margin:0 0 6px; letter-spacing:-0.3px; }
  .admin-hero p { margin:0; color:#c7d6f5; font-size:14px; }
  .admin-top {
    max-width:1240px; margin:0 auto; display:flex; align-items:center;
    justify-content:space-between; gap:18px; flex-wrap:wrap;
    padding:22px 32px 0;
  }
  .admin-top .brand { display:flex; align-items:center; gap:12px; font-weight:800; font-size:19px; }
  .admin-top .brand .tag {
    font-size:11px; font-weight:800; letter-spacing:1px; color:#0052ff;
    background:#e3eaff; padding:3px 10px; border-radius:999px;
  }
  .admin-top .user-box { font-size:13px; color:var(--body); display:flex; align-items:center; gap:14px; }
  .admin-top .user-box a { font-weight:700; }
  .admin-nav {
    max-width:1240px; margin:0 auto; padding:18px 32px 0;
    display:flex; gap:6px; flex-wrap:wrap; align-items:center;
  }
  .admin-nav a {
    font-size:13px; font-weight:700; color:var(--body);
    padding:9px 16px; border-radius:999px; text-decoration:none;
    transition:background .15s,color .15s;
  }
  .admin-nav a:hover { background:var(--surface-hover); }
  .admin-nav a.active { background:var(--primary); color:#fff; }
  .admin-nav .spacer { flex:1; }
  .admin-nav .logout { color:var(--down); }
  .admin-wrap { max-width:1240px; margin:0 auto; padding:30px 32px 90px; }
  .admin-wrap .page-title { font-size:24px; margin:0 0 4px; letter-spacing:-0.3px; }
  .admin-wrap .page-sub { color:var(--muted); font-size:14px; margin:0 0 24px; }
  .stat-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:16px; margin-bottom:26px; }
  .admin-wrap .table-card { overflow-x:auto; }
  table.data-table { width:100%; border-collapse:collapse; font-size:13.5px; }
  table.data-table th {
    text-align:left; padding:12px 14px; color:var(--muted); font-size:11px;
    text-transform:uppercase; letter-spacing:.6px; border-bottom:1px solid var(--border); white-space:nowrap;
  }
  table.data-table td { padding:13px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
  table.data-table tr:last-child td { border-bottom:none; }
  table.data-table tr:hover td { background:var(--surface-soft); }
  .avatar-sm { width:36px; height:36px; border-radius:50%; object-fit:cover; }
  .avatar-fallback {
    width:36px; height:36px; border-radius:50%; background:var(--surface-hover);
    display:flex; align-items:center; justify-content:center; font-weight:800; font-size:14px; color:var(--muted);
  }
  .stat-desc { font-size:12px; color:var(--muted); margin-top:6px; }
  .logo-tag {
    font-size:10.5px; font-weight:800; letter-spacing:1px; color:#0052ff;
    background:#e3eaff; padding:3px 9px; border-radius:999px; vertical-align:2px; margin-left:4px;
  }
</style>
</head>
<body>
<header class="topnav">
  <div class="container topnav-inner">
    <a href="../index.php" class="nav-logo">Fam<span class="nav-logo-accent">API</span> <span class="logo-tag">ADMIN</span></a>
  </div>
</header>

<div class="admin-top">
  <div class="brand">Admin <span class="tag"><?= htmlspecialchars(strtoupper($pageTitle)) ?></span></div>
  <div class="user-box">
    <span>Signed in as <strong>Administrator</strong></span>
    <a href="../logout.php">Logout</a>
  </div>
</div>

<div class="admin-nav">
  <a href="dashboard.php" class="<?= $currentPage === 'dashboard.php' ? 'active' : '' ?>">Overview</a>
  <a href="users.php" class="<?= $currentPage === 'users.php' || $currentPage === 'user_edit.php' ? 'active' : '' ?>">Users</a>
  <a href="plans.php" class="<?= $currentPage === 'plans.php' ? 'active' : '' ?>">Plan Editor</a>
  <a href="payment_links.php" class="<?= $currentPage === 'payment_links.php' ? 'active' : '' ?>">Payment Links</a>
  <a href="settings.php" class="<?= $currentPage === 'settings.php' ? 'active' : '' ?>">Settings</a>
  <span class="spacer"></span>
  <a href="../docs.php" class="logout">Docs</a>
  <a href="../index.php" class="logout">View site</a>
  <a href="../logout.php" class="logout">Logout</a>
</div>

<div class="admin-hero">
  <h1><?= htmlspecialchars($pageTitle) ?></h1>
  <p><?= !empty($pageSub) ? htmlspecialchars($pageSub) : 'Manage your FamAPI platform.' ?></p>
</div>
