<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}
?>

<header class="header fixed-top" style="background-color: #1490d7;">
  <div class="container d-flex align-items-center justify-content-between py-2">

    <!-- Logo -->
    <a href="index.php" class="d-flex align-items-center">
      <img src="assets/img/logo.png" alt="Clinic Logo" style="height:50px; margin-right:10px;">
      <span class="fw-bold text-white">ICMR-NIRRCH</span>
    </a>

    <!-- Desktop Navbar -->
    <nav class="d-none d-xl-flex gap-3">
      <a href="index.php" class="text-white">Home</a>
      <?php if (isset($_SESSION['user'])): ?>
        <a href="fill-application.php" class="text-white">Fill Application</a>
        <a href="userprint.php" class="text-white">Print Application</a>
        <a href="logout.php" class="text-white"><?= htmlspecialchars($_SESSION['user']['full_name']); ?> (Logout)</a>
      <?php else: ?>
        <a href="login.php" class="text-white">Login</a>
        <a href="register.php" class="text-white">Register</a>
      <?php endif; ?>
    </nav>

    <!-- Mobile toggle -->
    <button type="button" class="btn d-xl-none text-white" data-bs-toggle="modal" data-bs-target="#mobileMenu">
      <i class="bi bi-list fs-3"></i>
    </button>

  </div>
</header>

<!-- Mobile Menu Modal -->
<div class="modal fade" id="mobileMenu" tabindex="-1" aria-labelledby="mobileMenuLabel" aria-hidden="true">
  <div class="modal-dialog modal-fullscreen-sm-down">
    <div class="modal-content" style="background-color: #1490d7;">
      <div class="modal-header border-0">
        <h5 class="modal-title text-white fw-bold" id="mobileMenuLabel">Menu</h5>
        <button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body d-flex flex-column gap-3">
        <a href="index.php" class="text-white fs-5 text-center">Home</a>
        <?php if (isset($_SESSION['user'])): ?>
 <!--          <a href="fill-application.php" class="text-white fs-5 text-center">Fill Application</a>
          <a href="userprint.php" class="text-white fs-5 text-center">Print Application</a>
          <a href="logout.php" class="text-white fs-5 text-center"><? //= htmlspecialchars($_SESSION['user']['full_name']); ?> (Logout)</a> -->
        <?php else: ?>
          <a href="login.php" class="text-white fs-5 text-center">Login</a>
          <a href="register.php" class="text-white fs-5 text-center">Register</a>
        <?php endif; ?>
      </div>
    </div>
  </div>
</div>

<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
