<?php if (isset($_SESSION['user'])): ?>
  <?php
  $vorname = $_SESSION['user_vorname'] ?? '';
  $nachname = $_SESSION['user_nachname'] ?? '';
  $gemeinde = $_SESSION['gemeinde_id'] ?? '';
  $anzeige = trim($vorname . ' ' . $nachname);
  ?>
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container-fluid">
      <a class="navbar-brand" href="../index.php">cloud.F-Invent</a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Start</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../favoriten.php">Favoriten</a></li>
              <li><a class="dropdown-item" href="../kalender.php">Kalender</a></li>
            </ul>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Dashboards</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../dashboard_atemschutz.php">Atemschutz</a></li>
              <li><a class="dropdown-item" href="../dashboard.php">Geräte</a></li>
              <li><a class="dropdown-item" href="../dashboard_psa.php">Lager-PSA</a></li>
              <li><a class="dropdown-item" href="../dashboard_db.php">Lager-Dienstbekleidung</a></li>
              <li><a class="dropdown-item" href="../dashboard_uniform.php">Lager-Uniformen</a></li>
            </ul>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Technik</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../atemschutz.php">Atemschutz</a></li>
              <li><a class="dropdown-item" href="../fahrzeuge.php">Fahrzeuge</a></li>
              <li><a class="dropdown-item" href="../geraete.php">Geräte</a></li>
              <li><a class="dropdown-item" href="../melder.php">Melder</a></li>
              <li><a class="dropdown-item" href="../transponder.php">Transponder</a></li>
              <li><a class="dropdown-item" href="../papierkorb.php">Papierkorb</a></li>
            </ul>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">PSA</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../kameraden.php">Kameraden</a></li>
              <li><a class="dropdown-item" href="../psa.php">PSA</a></li>
            </ul>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Lager</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../lager.php">Lager</a></li>
              <li><a class="dropdown-item" href="../lieferschein_neu.php">Lieferscheine</a></li>
            </ul>
          </li>
          <li class="nav-item"><a class="nav-link" href="../dokumente.php">Dokumente</a></li>
          <li class="nav-item"><a class="nav-link" href="../tickets.php">Ticketsystem</a></li>
          <li class="nav-item"><a class="nav-link" href="../aufgaben.php">Aufgaben</a></li>
          <li class="nav-item"><a class="nav-link" href="../chat.php">Chat</a></li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Verwaltung</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../account.php">Account</a></li>
              <li><a class="dropdown-item" href="../einheit.php">Meine Einheit</a></li>
              <li><a class="dropdown-item" href="../zeiterfassung.php">Zeiterfassung</a></li>
              <li><a class="dropdown-item" href="#">Einstellungen</a></li>
              <?php if ($_SESSION['is_admin'] == 1): ?>
  <li><a class="dropdown-item text-danger" href="../admin/user_logged.php">🔐 Adminbereich</a></li>
<?php endif; ?>
            </ul>
          </li>
        </ul>

        <!-- Benutzeranzeige ganz rechts -->
        <div class="ms-auto d-flex align-items-center text-white">
          <div class="me-3 text-end small">
            👤 <?= htmlspecialchars($anzeige) ?><br>
            🚒 <?= htmlspecialchars($gemeinde) ?>
          </div>
          <a class="btn btn-sm btn-outline-light" href="../logout.php">Logout</a>
        </div>
      </div>
    </div>
  </nav>
<?php endif; ?>
