/*
 * ALPHANAV — Sidebar hub 2-niveaux
 * Rail 56px d'icônes + fly-out par section (280px).
 * Opt-in via Settings > Apparence > Navigation.
 * Toutes les couleurs sont via var() — dark mode natif.
 */

/* ═══════════════════════════════════════════
   RAIL — bande verticale fixe gauche
   ═══════════════════════════════════════════ */
.alphanav-rail {
  width: 56px;
  height: calc(100vh - 56px); /* offset header fixe 56px */
  flex-direction: column;
  align-items: center;
  padding: 8px 0 12px;
  gap: 2px;
  background: var(--sidebar-bg, var(--bg-surface));
  border-right: 1px solid var(--border-default);
  position: fixed;
  left: 0;
  top: 56px; /* sous le header fixe */
  z-index: 40;
  overflow: visible; /* fly-outs débordent hors du rail */
  flex-shrink: 0;
}

/* Décaler le contenu principal quand AlphaNav est actif (desktop uniquement) */
@media (min-width: 1024px) {
  .alphanav-rail ~ * .app-shell > :not(#alphanav),
  body:has(#alphanav) .app-shell > div:last-child {
    margin-left: 0; /* géré via flex — le rail prend sa place naturellement */
  }
}

/* ═══════════════════════════════════════════
   HUB BUTTONS — icônes de section
   ═══════════════════════════════════════════ */
.alphanav-hub {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text-tertiary);
  position: relative;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
  text-decoration: none;
  flex-shrink: 0;
}

.alphanav-hub svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.alphanav-hub:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.alphanav-hub.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.alphanav-hub.flyout-open {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Indicateur visuel : hub avec fly-out ouvert */
.alphanav-hub.flyout-open::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 2px 0 0 2px;
}

/* ═══════════════════════════════════════════
   BADGE sur les hubs (agrégat de section)
   ═══════════════════════════════════════════ */
.alphanav-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-contrast, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}

/* ═══════════════════════════════════════════
   CMD+K PILL
   ═══════════════════════════════════════════ */
.alphanav-cmdk {
  width: 40px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 10px;
  color: var(--text-tertiary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: background 120ms ease, color 120ms ease;
  flex-shrink: 0;
}

.alphanav-cmdk svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.alphanav-cmdk-hint {
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
}

.alphanav-cmdk:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════
   SPACER — pousse Cmd+K et Settings en bas
   ═══════════════════════════════════════════ */
.alphanav-spacer {
  flex: 1;
}

/* form wrapper du switch nav — invisible dans le flex du rail */
.alphanav-rail form.contents {
  display: contents;
}

/* Bouton switch → menu classique */
.alphanav-switch-nav {
  opacity: 0.45;
  transition: opacity 120ms;
}
.alphanav-switch-nav:hover {
  opacity: 1;
  background: var(--bg-surface-hover);
}

/* ═══════════════════════════════════════════
   FLY-OUT PANEL
   ═══════════════════════════════════════════ */
.alphanav-flyout {
  position: fixed;
  left: 56px;
  top: 56px; /* aligné avec le bas du header */
  width: 256px;
  height: calc(100vh - 56px);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  padding: 12px 6px 20px;
  display: flex; /* toujours flex — visibility gère la visibilité */
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  z-index: 39;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.06);
  /* État caché par défaut — transition sur visibility+opacity+transform */
  visibility: hidden;
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition: opacity 130ms cubic-bezier(0.22, 1, 0.36, 1),
              transform 130ms cubic-bezier(0.22, 1, 0.36, 1),
              visibility 0s 130ms; /* delay visibility sur fermeture */
}

.alphanav-flyout.open {
  visibility: visible;
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  transition: opacity 130ms cubic-bezier(0.22, 1, 0.36, 1),
              transform 130ms cubic-bezier(0.22, 1, 0.36, 1),
              visibility 0s; /* pas de delay sur ouverture */
}

@media (prefers-reduced-motion: reduce) {
  .alphanav-flyout,
  .alphanav-flyout.open {
    transition: none;
    transform: none;
  }
}

/* Titre de section dans le fly-out */
.alphanav-flyout-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 4px 10px 10px;
  margin: 0;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   FLY-OUT ITEMS
   ═══════════════════════════════════════════ */
.alphanav-flyout-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 90ms ease, color 90ms ease;
  position: relative;
  flex-shrink: 0;
}

.alphanav-flyout-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.alphanav-flyout-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alphanav-flyout-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.alphanav-flyout-item.active {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.alphanav-flyout-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Badge dans l'item du fly-out */
.alphanav-flyout-badge {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ═══════════════════════════════════════════
   TOOLTIP natif sur les hubs (CSS pur)
   Délai 350ms pour éviter le flash au survol rapide
   ═══════════════════════════════════════════ */
.alphanav-hub[title]:hover::before {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  animation: alphanav-tooltip-in 80ms 350ms ease-out forwards;
}

@keyframes alphanav-tooltip-in {
  to { opacity: 1; }
}

/* Masquer tooltip si fly-out est ouvert (évite doublon) */
.alphanav-hub.flyout-open[title]:hover::before {
  display: none;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — masquer rail < 1024px
   (bottom nav mobile prend le relais)
   ═══════════════════════════════════════════ */
@media (max-width: 1023px) {
  .alphanav-rail {
    display: none !important;
  }

  .alphanav-flyout {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════
   DARK MODE — tout via var() déjà
   aucune règle supplémentaire nécessaire
   ═══════════════════════════════════════════ */
