<?php
// admin/includes/staff_topbar.php
if (session_status() === PHP_SESSION_NONE) session_start();

function staff_display_name(): string {
  // Try common shapes
  if (isset($_SESSION['admin']) && is_array($_SESSION['admin'])) {
    foreach (['display_name','name','username','email'] as $k) {
      if (!empty($_SESSION['admin'][$k])) return (string)$_SESSION['admin'][$k];
    }
  }
  foreach (['display_name','username','email','admin'] as $k) {
    if (!empty($_SESSION[$k]) && is_string($_SESSION[$k])) return $_SESSION[$k];
  }
  return 'Staff';
}
$me = staff_display_name();
$logo = '../assets/img/edencampus.png'; // change path if your assets differ
$curr = basename($_SERVER['PHP_SELF'] ?? '');
?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">

<style>
  :root{ --brand-1:#0b2c61; --brand-2:#5a2bb5; --ink:#0e1b37; }
  .staff-topbar{
    position:sticky; top:0; z-index:1020;
    background: linear-gradient(135deg,var(--brand-1),#081a39);
    box-shadow:0 8px 22px rgba(0,0,0,.28);
  }
  .staff-topbar .navbar-brand img{ height:40px; }
  .staff-topbar .brand-text{ color:#fff; font-weight:800; letter-spacing:.4px; }
  .staff-topbar .brand-sub{ color:#cfe0ff; font-weight:700; margin-left:.5rem; }
  .staff-topbar .nav-link{ color:#e6ebff; font-weight:600; }
  .staff-topbar .nav-link:hover, .staff-topbar .nav-link.active{ color:#fff; }
  .badge-role{ background:rgba(255,255,255,.12); border:1px solid rgba(255,255,255,.18); }
</style>

<nav class="navbar navbar-expand-lg staff-topbar">
  <div class="container">
    <a class="navbar-brand d-flex align-items-center gap-2" href="staff_dashboard.php">
      <img src="<?= htmlspecialchars($logo) ?>" alt="Eden">
      <span class="brand-text">EXAM MANAGEMENT SYSTEMS</span>
      <span class="brand-sub d-none d-md-inline">• STAFF</span>
    </a>

    <button class="navbar-toggler text-white" type="button" data-bs-toggle="collapse" data-bs-target="#navStaff">
      <span class="navbar-toggler-icon" style="filter:invert(1)"></span>
    </button>

    <div class="collapse navbar-collapse" id="navStaff">
      <ul class="navbar-nav ms-auto align-items-lg-center gap-lg-2">
        <li class="nav-item"><a class="nav-link <?= $curr==='staff_dashboard.php'?'active':'' ?>" href="staff_dashboard.php">Dashboard</a></li>
        <li class="nav-item"><a class="nav-link" href="staff_dashboard.php#quick-add">Add Student</a></li>
        <li class="nav-item"><a class="nav-link <?= $curr==='student_created_list.php'?'active':'' ?>" href="student_created_list.php">Recently Created</a></li>
        <li class="nav-item ms-lg-2">
          <span class="badge rounded-pill text-white badge-role px-3 py-2">👋 <?= htmlspecialchars($me) ?></span>
        </li>
        <li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
      </ul>
    </div>
  </div>
</nav>
