/* Barre de navigation (espace gestion et espace utilisateur) - fixee en
   haut, meme structure sur ordinateur et mobile. Sur mobile, les liens
   passent dans un panneau accordeon ouvert par le bouton "hamburger".
   Voir static/js/navigation.js. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: color-mix(in srgb, var(--card-bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  min-height: 64px;
  gap: 4px;
}
.brand {
  font-weight: 800;
  color: var(--text);
  margin-right: 20px;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand img { height: 30px; width: auto; display: block; }

.nav-panel { flex: 1; min-width: 0; }
.nav-panel-inner { display: flex; align-items: center; gap: 12px; }
.nav-links { position: relative; display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.nav-links a {
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 13px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.nav-links a:hover, .nav-links a.active { color: var(--action); }
.nav-links a:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* Indicateur anime : pastille qui glisse sous le lien survole puis revient
   sous le lien actif ; elle s'estompe quand le curseur quitte un lien qui
   n'est pas la page en cours. */
.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  border-radius: 10px;
  background: var(--action-light);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.3, 1), width 0.32s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.35s ease;
}
.nav-indicator::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -14px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--action);
  opacity: var(--nav-underline, 0);
  transition: opacity 0.35s ease;
}
.nav-indicator.is-visible { opacity: 1; }
.nav-indicator.on-active { --nav-underline: 1; }

/* Bascule Gestion / Utilisateur */
.space-switch {
  display: inline-flex;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 999px;
  background: #F2F4F5;
  border: 1px solid var(--border);
}
.space-switch a {
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}
.space-switch a.on { background: var(--card-bg); color: var(--action); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.space-switch a:not(.on):hover { color: var(--text); }

.nav-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Selecteur de langue (voir partials/lang_menu.html) */
.lang-menu { position: relative; flex-shrink: 0; }
.lang-menu summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover, .lang-menu[open] summary { color: var(--action); border-color: var(--action-light); }
.lang-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 950;
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 150px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.lang-menu li a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}
.lang-menu li a:hover { background: var(--action-light); color: var(--action); }
.lang-menu li a[aria-current="true"] { color: var(--action); }
.lang-menu li a[aria-current="true"]::after { content: " ✓"; }

/* Bouton hamburger (mobile) */
.nav-burger {
  display: none;
  margin-left: auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}
.nav-burger span {
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 0.28s ease, opacity 0.2s ease;
}
.nav-burger span:nth-child(1) { top: 15px; }
.nav-burger span:nth-child(2) { top: 21px; }
.nav-burger span:nth-child(3) { top: 27px; }
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1400px) { .topbar .brand span { display: none; } .topbar .brand { margin-right: 12px; } }

@media (max-width: 1260px) {
  .topbar .brand span { display: inline; }
  .topbar { padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top); flex-wrap: wrap; }
  .nav-burger { display: block; }
  /* Panneau accordeon : hauteur animee (grille 0fr -> 1fr) */
  .nav-panel {
    order: 3;
    flex-basis: 100%;
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.34s cubic-bezier(0.22, 0.8, 0.3, 1);
  }
  .nav-panel.is-open { grid-template-rows: 1fr; }
  .nav-panel-inner { overflow: hidden; min-height: 0; flex-direction: column; align-items: stretch; gap: 0; }
  .nav-links { flex-direction: column; align-items: stretch; gap: 2px; padding-top: 4px; }
  .nav-links a { padding: 13px 12px; font-size: 0.98rem; }
  .nav-links a.active { background: var(--action-light); }
  .nav-indicator { display: none; }
  .nav-tools { flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; align-items: flex-start; }
  .space-switch a { padding: 9px 16px; font-size: 0.88rem; }
  .lang-menu summary { padding: 10px 14px; font-size: 0.88rem; }
  /* dans l'accordeon, la liste des langues s'ouvre dans le flux (pas coupee) */
  .nav-panel .lang-menu ul { position: static; margin-top: 6px; box-shadow: none; }
}

/* Pastille du Calendrier (alertes ouvertes importantes / a traiter) - voir status.js */
.nav-badge {
  display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; margin-left: 4px;
  background: var(--status-intrus); color: #fff; font-size: 11px; font-weight: 800; align-items: center; justify-content: center;
}
.nav-badge[hidden] { display: none; }

/* Transitions entre pages : le contenu arrive de la droite quand on va vers
   une page plus loin dans le menu, de la gauche sinon. */
@keyframes nl-enter-from-right { from { opacity: 0; transform: translateX(48px); } to { opacity: 1; transform: none; } }
@keyframes nl-enter-from-left { from { opacity: 0; transform: translateX(-48px); } to { opacity: 1; transform: none; } }
.nl-enter-forward { animation: nl-enter-from-right 0.36s cubic-bezier(0.22, 0.8, 0.3, 1) both; }
.nl-enter-back { animation: nl-enter-from-left 0.36s cubic-bezier(0.22, 0.8, 0.3, 1) both; }

/* Retour en haut */
.to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 800;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--action);
  font-size: 1.2rem;
  font-weight: 800;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.to-top.is-shown { opacity: 1; transform: none; }
.to-top[hidden] { display: none; }

/* Pied de page */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  padding: 22px 16px calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}
.site-footer a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  .nav-indicator, .nav-indicator::after, .nav-panel, .nav-burger span, .to-top, .space-switch a { transition: none; }
  .nl-enter-forward, .nl-enter-back { animation: none; }
}

/* Menu du compte (voir partials/account_menu.html) */
.acct-menu { position: relative; flex-shrink: 0; }
.acct-menu[hidden] { display: none; }
.acct-menu summary { list-style: none; cursor: pointer; display: block; border-radius: 50%; border: 2px solid var(--border); line-height: 0; }
.acct-menu summary::-webkit-details-marker { display: none; }
.acct-menu summary:hover, .acct-menu[open] summary { border-color: var(--action); }
#acctAvatar { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  background: var(--action-light); color: var(--action); font-size: 0.8rem; font-weight: 800; line-height: 1; }
#acctAvatar img { width: 100%; height: 100%; object-fit: cover; }
.acct-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 960; width: min(300px, calc(100vw - 32px)); padding: 8px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.acct-head { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.acct-mail, .acct-lieu { font-size: 0.8rem; color: var(--text-muted); overflow-wrap: anywhere; }
.acct-level { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--action); }
.acct-item { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--text); text-decoration: none; }
.acct-item:hover { background: var(--action-light); color: var(--action); }
.acct-out { color: var(--status-intrus, #c0392b); }
#acctPwdForm { display: grid; gap: 6px; padding: 4px 10px 8px; }
#acctPwdForm input { padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text); }
.acct-msg { font-size: 0.8rem; }
.acct-msg.ok { color: var(--status-ok, #2e8b57); }
.acct-msg.err { color: var(--status-intrus, #c0392b); }
@media (max-width: 900px) { .nav-panel .acct-pop { position: static; width: auto; margin-top: 6px; box-shadow: none; } }
