<?php
// helper para resaltar la pestaña activa
$here = basename($_SERVER['PHP_SELF']);
function isActive($file) {
    global $here;
    return $here === $file ? 'active fw-semibold text-warning' : '';
}
?>
<nav class="navbar navbar-expand-lg navbar-dark bg-gradient position-sticky top-0 shadow-sm" style="backdrop-filter:blur(6px);z-index:1030;">
  <div class="container-fluid">
    <!-- brand -->
    <a class="navbar-brand d-flex align-items-center" href="dashboard.php">
      <i class="fas fa-code-branch fa-lg me-2"></i>
      <span class="fw-bold">Panel&nbsp;Admin</span>
    </a>

    <!-- toggler -->
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#adminNav">
      <span class="navbar-toggler-icon"></span>
    </button>

    <!-- links -->
    <div id="adminNav" class="collapse navbar-collapse">
      <ul class="navbar-nav ms-auto align-items-lg-center gap-lg-2">
        <li class="nav-item"><a class="nav-link <?= isActive('admin_list_correo.php') ?>"
           href="admin_list_correo.php"><i class="fas fa-envelope me-1"></i>Listar Correos</a></li>

        <li class="nav-item"><a class="nav-link <?= isActive('admin_asignar_contrasena.php') ?>"
           href="admin_asignar_contrasena.php"><i class="fas fa-key me-1"></i>Registro&nbsp;acceso</a></li>

        <li class="nav-item"><a class="nav-link <?= isActive('admin_asignar_masivo.php') ?>"
           href="admin_asignar_masivo.php"><i class="fas fa-users me-1"></i>Registro&nbsp;masivo</a></li>

        <li class="nav-item"><a class="nav-link <?= isActive('subjects_admin.php') ?>"
           href="subjects_admin.php"><i class="fas fa-folder-plus me-1"></i>Registro&nbsp;asuntos</a></li>
           
        <!-- dropdown perfil (desktop) -->
        <li class="nav-item dropdown d-none d-lg-block">
          <a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#">
            <i class="fas fa-user-cog"></i>
          </a>
          <ul class="dropdown-menu dropdown-menu-dark dropdown-menu-end">
            <li><h6 class="dropdown-header"><?= htmlspecialchars($_SESSION['admin_name'] ?? 'Admin') ?></h6></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item text-danger" href="logout_admin.php">
              <i class="fas fa-sign-out-alt me-2"></i>Cerrar sesión
            </a></li>
          </ul>
        </li>

        <!-- logout botón visible solo en móvil -->
        <li class="nav-item d-lg-none">
          <a class="btn btn-danger w-100 my-2" href="logout_admin.php">
            <i class="fas fa-sign-out-alt me-1"></i>Cerrar sesión
          </a>
        </li>
      </ul>
    </div>
  </div>
</nav>
