<?php
function renderAdminHeader($title, $activePage = '') {
    $siteUrl = defined('SITE_URL') ? SITE_URL : '';
    $adminName = isset($_SESSION['admin_name']) ? htmlspecialchars($_SESSION['admin_name']) : 'Admin';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title><?= htmlspecialchars($title) ?> - Admin - <?= SITE_NAME ?></title>
<link rel="stylesheet" href="<?= $siteUrl ?>/assets/css/style.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
</head><body>
<div class="app-layout">
<div class="sidebar-overlay" id="sidebarOverlay"></div>
<aside class="sidebar" id="sidebar">
  <div class="sidebar-header"><div class="sidebar-logo"><div class="logo-icon">⚙️</div><span>Admin Panel</span></div></div>
  <nav class="sidebar-nav">
    <div class="nav-section">
      <div class="nav-section-title">Overview</div>
      <a href="<?= $siteUrl ?>/admin/dashboard.php" class="nav-item <?= $activePage==='dashboard'?'active':'' ?>"><span class="nav-icon">🏠</span> Dashboard</a>
      <a href="<?= $siteUrl ?>/admin/analytics.php" class="nav-item <?= $activePage==='analytics'?'active':'' ?>"><span class="nav-icon">📈</span> Analytics &amp; Reports</a>
      <a href="<?= $siteUrl ?>/admin/activity-log.php" class="nav-item <?= $activePage==='activity-log'?'active':'' ?>"><span class="nav-icon">📋</span> Activity Log</a>
    </div>
    <div class="nav-section">
      <div class="nav-section-title">Management</div>
      <a href="<?= $siteUrl ?>/admin/users.php" class="nav-item <?= $activePage==='users'?'active':'' ?>"><span class="nav-icon">👥</span> Users</a>
      <a href="<?= $siteUrl ?>/admin/pro-subscriptions.php" class="nav-item <?= $activePage==='pro-subscriptions'?'active':'' ?>"><span class="nav-icon">⚡</span> Pro Subscriptions</a>
      <a href="<?= $siteUrl ?>/admin/al-exams.php" class="nav-item <?= $activePage==='exams'?'active':'' ?>"><span class="nav-icon">📅</span> A/L Exam Dates</a>
      <a href="<?= $siteUrl ?>/admin/announcements.php" class="nav-item <?= $activePage==='announcements'?'active':'' ?>"><span class="nav-icon">📢</span> Announcements</a>
      <a href="<?= $siteUrl ?>/admin/notifications.php" class="nav-item <?= $activePage==='notifications'?'active':'' ?>"><span class="nav-icon">🔔</span> Notifications</a>
      <a href="<?= $siteUrl ?>/admin/weekly-reports.php" class="nav-item <?= $activePage==='weekly-reports'?'active':'' ?>"><span class="nav-icon">📊</span> Weekly Reports</a>
      <a href="<?= $siteUrl ?>/admin/resources.php" class="nav-item <?= $activePage==='resources'?'active':'' ?>"><span class="nav-icon">🗂️</span> Study Resources</a>
      <a href="<?= $siteUrl ?>/admin/syllabus-templates.php" class="nav-item <?= $activePage==='syllabus-templates'?'active':'' ?>"><span class="nav-icon">📘</span> Syllabus Templates</a>
      <a href="<?= $siteUrl ?>/admin/reviews.php" class="nav-item <?= $activePage==='reviews'?'active':'' ?>"><span class="nav-icon">⭐</span> Reviews</a>
      <a href="<?= $siteUrl ?>/admin/mail.php" class="nav-item <?= $activePage==='mail'?'active':'' ?>"><span class="nav-icon">📧</span> Bulk Mail</a>
    </div>
    <div class="nav-section">
      <div class="nav-section-title">Configuration</div>
      <a href="<?= $siteUrl ?>/admin/site-settings.php" class="nav-item <?= $activePage==='site-settings'?'active':'' ?>"><span class="nav-icon">⚙️</span> Site Settings</a>
      <a href="<?= $siteUrl ?>/admin/page-control.php" class="nav-item <?= $activePage==='page-control'?'active':'' ?>"><span class="nav-icon">🚧</span> Page Control</a>
    </div>
    <div class="nav-section">
      <div class="nav-section-title">Account</div>
      <a href="<?= $siteUrl ?>/admin/logout.php" class="nav-item"><span class="nav-icon">🚪</span> Logout</a>
    </div>
  </nav>
  <div class="sidebar-user">
    <div class="user-card">
      <div class="user-avatar" style="background:linear-gradient(135deg,#f59e0b,#ef4444)">A</div>
      <div class="user-info"><div class="name"><?= $adminName ?></div><div class="role admin-badge">Admin</div></div>
    </div>
  </div>
</aside>
<div class="main-content">
  <div class="topbar">
    <div class="topbar-left">
      <button class="sidebar-toggle" id="sidebarToggle">☰</button>
      <div class="topbar-title"><?= htmlspecialchars($title) ?></div>
    </div>
    <div class="topbar-right"><a href="<?= $siteUrl ?>/login.php" class="btn btn-secondary btn-sm">👁️ Student View</a></div>
  </div>
  <div class="page-content">
<?php } ?>
