<?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>
            </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="../geraete_stats.php">Statistik</a></li>
              <li><a class="dropdown-item" href="../transponder.php">Transponder</a></li>
              <li><a class="dropdown-item" href="../inventur_liste.php">Inventur</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">Stammdaten</a></li>
              <li><a class="dropdown-item" href="../psa.php">PSA</a></li>
              <li><a class="dropdown-item" href="../psa_stats.php">Statistiken</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 dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Warenkorb</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../cart.php">Warenkorb</a></li>
            </ul>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Dokumente</a>
            <ul class="dropdown-menu">
              <li><a class="dropdown-item" href="../dokumente.php">DMS</a></li>
            </ul>
          </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.php">Einstellungen</a></li>
            </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; ?>
