/* =====================================================================
   assets/css/nav-rail.css
   -----------------------------------------------------------------------
   UI-1.5 — coquille finale : vrai rail vertical desktop + tiroir mobile.

   Principes :
   - #mainNav reste le même point de montage du router (aucune route ni
     permission modifiée), mais vit désormais dans <aside .app-sidebar>.
   - Desktop/tablette large : rail vertical sticky, couleur principale.
   - <= 760px : tiroir global piloté par #appNavToggle, distinct du tiroir
     Administration existant (#adminMobileToggle).
   ===================================================================== */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--fa-bg);
}

.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: var(--fa-accent);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, .12);
  z-index: 40;
}

.app-sidebar-heading {
  padding: var(--fa-space-4) var(--fa-space-4) var(--fa-space-2);
  color: rgba(255, 255, 255, .62);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.app-main-shell {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-module-host {
  min-width: 0;
  flex: 1;
}

/* L'ancienne classe .nav-bar garde son nom pour compatibilité, mais sa
   géométrie historique est neutralisée dans le nouveau rail. */
.app-sidebar > .nav-bar {
  display: block;
  padding: 0 0 var(--fa-space-4);
  overflow: visible;
}

.app-rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--fa-space-2);
  padding: 0 var(--fa-space-2) var(--fa-space-4);
  background: transparent;
  overflow: visible;
}

.app-rail-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: var(--fa-space-2) 0;
  border-right: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.app-rail-group:last-child { border-bottom: 0; }

.app-rail-group-label {
  padding: 0 var(--fa-space-3) var(--fa-space-1);
  color: rgba(255, 255, 255, .54);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-rail-item {
  width: 100%;
  min-height: var(--fa-row-h);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 var(--fa-space-3);
  border: 0;
  border-radius: var(--fa-radius);
  background: transparent;
  color: rgba(255, 255, 255, .84);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.app-rail-item:hover,
.app-rail-item:focus-visible {
  background: rgba(255, 255, 255, .10);
  color: #fff;
  outline: none;
}

.app-rail-item.active {
  background: var(--fa-accent-active);
  color: #fff;
  font-weight: 700;
}

.app-nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--fa-border);
  border-radius: var(--fa-radius);
  background: var(--fa-surface);
  color: var(--fa-text);
  font-size: 20px;
  line-height: 1;
}

.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  border: 0;
  padding: 0;
  background: rgba(20, 24, 28, .38);
}

@media (max-width: 1024px) and (min-width: 761px) {
  .app-shell { grid-template-columns: 216px minmax(0, 1fr); }
  .app-rail-item { min-height: var(--fa-tap); }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .app-main-shell { min-height: 100dvh; }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(84vw, 300px);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 10px 0 30px rgba(0, 0, 0, .20);
    z-index: 50;
  }

  .app-shell.nav-open .app-sidebar { transform: translateX(0); }
  .app-shell.nav-open .app-sidebar-backdrop { display: block; }

  .app-nav-toggle { display: inline-flex; flex: none; }
  .app-rail-item { min-height: var(--fa-tap); font-size: 14px; }

  .app-sidebar-heading {
    padding-top: 18px;
    color: rgba(255, 255, 255, .72);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar { transition: none; }
}

/* =====================================================================
   Refonte UI/UX finale — logo/restaurant actif/utilisateur DANS la
   sidebar (conforme maquette). Couleur de la sidebar INCHANGÉE
   (var(--fa-accent), déjà définie plus haut dans .app-rail) — ce bloc
   ajoute seulement la structure, jamais une nouvelle teinte.
   ===================================================================== */
.app-sidebar-brand {
  display: flex; align-items: center; gap: var(--fa-space-2);
  padding: var(--fa-space-3) var(--fa-space-3) var(--fa-space-2);
  color: #fff;
}
.app-sidebar-brand h1 { font-size: 16px; margin: 0; color: #fff; }
.app-sidebar-brand .sub { font-size: 11px; color: rgba(255,255,255,.6); }

.app-sidebar-restaurant {
  padding: 0 var(--fa-space-3) var(--fa-space-2);
  font-size: 12px;
  color: rgba(255,255,255,.75);
  border-bottom: 1px solid rgba(255,255,255,.14);
  margin-bottom: var(--fa-space-2);
}

.app-sidebar-user {
  margin-top: auto;
  display: flex; flex-direction: column; gap: var(--fa-space-2);
  padding: var(--fa-space-3);
  border-top: 1px solid rgba(255,255,255,.14);
  font-size: 12px;
  color: rgba(255,255,255,.85);
}
.app-sidebar-user .btn-secondary {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--fa-radius); padding: 8px 12px; font-size: 13px; cursor: pointer;
}

.app-sidebar { display: flex; flex-direction: column; }

/* Header réduit : uniquement les 2 bascules mobile (nav/admin), masqué sur desktop. */
.topbar--mobile-only { display: none; padding: var(--fa-space-2); background: var(--fa-surface); border-bottom: 1px solid var(--fa-border); }
@media (max-width: 1024px) {
  .topbar--mobile-only { display: flex; align-items: center; gap: var(--fa-space-2); }
}
