/* ═══════════════════════════════════════════════════════════════════════
   Sidebar (.sidebar / .sb-* / .mobile-overlay)
   Extrait de css/hostome-ui.css (bloc "Shell partage", ajoute le 2026-07-27,
   mission ELIMINATE_APP_CSS_DEPENDENCY_FROM_ALL_PRODUCTION_PAGES) lors de la
   Phase 5 (SEPARATE_AND_ORCHESTRATE_APPLICATION_SHELL). Declarations
   deplacees a l'identique (aucune valeur modifiee). Les deux occurrences de
   `.sidebar` dans une @media (max-width: 860px) ci-dessous proviennent de
   DEUX blocs distincts du fichier source, a des positions differentes ; leur
   ordre relatif est préservé ici (la seconde occurrence continue de
   l'emporter en cascade sur `left`/`z-index`/`transition`, exactement comme
   dans le fichier d'origine). Le bloc @media d'origine couplait `.sidebar`
   et `.topbar`/`.menu-toggle` ensemble : chaque media query a été rejouée à
   l'identique dans son fichier cible plutôt que réécrite.
   ═══════════════════════════════════════════════════════════════════════ */

/* Mission HOSTOME_GLOBAL_SIDEBAR_FINAL_FIX (2026-08-24) : ce fichier
   contenait lui-même deux déclarations `.sidebar{}` de base (hors media
   query) - une historique jamais documentée par l'en-tête ci-dessus
   (qui ne parle que des DEUX occurrences DANS @media(max-width:860px),
   un doublon différent, intentionnel, toujours préservé plus bas).
   Celle-ci était displacée par la seconde (mêmes propriétés + gap/height/
   position:sticky/overflow-y en plus, valeurs qui l'emportaient déjà en
   cascade) - fusionnée ici en une seule déclaration reflétant exactement
   ce qui s'appliquait réellement avant fusion (aucune valeur visuelle
   changée), l'ancienne seconde occurrence (plus bas dans ce fichier)
   est supprimée. */
.sidebar {
  width: 236px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  flex-shrink: 0;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: width 0.25s ease, transform 0.25s ease, padding 0.25s ease;
  z-index: 300;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.mobile-overlay {
  display: none;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100dvh;
    width: 236px;
    transform: translateX(-100%);
    box-shadow: 4px 0 18px rgba(0,0,0,0.12);
    overflow-y: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Desktop collapsed contract (mission HOSTOME_GLOBAL_SHELL_SIDEBAR_UNIFICATION,
   2026-08-24) - THE SINGLE canonical source of the icon-only rail. Before
   this mission the SAME geometry was copy-pasted, independently and
   inconsistently, into 14 css/pages/*.css files plus an inline <style> in
   index.html - some copies never hid the labels (text visually clipped
   inside the narrowed rail - Dashboard), one (calendar.css) had a stray
   extra unconditional copy of the base width:0 rule placed AFTER its own
   correct desktop override, permanently winning the cascade by source
   order and hiding the sidebar entirely on desktop, and 4 pages (inbox,
   extras, properties, settings) had no override at all - collapse did
   nothing. All page-specific copies are removed; this is now the only
   place this geometry is defined. Labels/badges/chevrons/submenus are
   STRUCTURALLY hidden (display:none), never merely clipped - the primary
   collapsed mechanism is never text-clipping. */
body.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  border-right: 0;
  overflow: hidden;
}

body.sidebar-collapsed .main {
  width: 100%;
}

@media (min-width: 861px) {
  body.sidebar-collapsed .sidebar {
    width: 60px;
    min-width: 60px;
    padding: 14px 8px;
    border-right: 1px solid var(--line);
    overflow: hidden;
  }
  body.sidebar-collapsed .sb-brand-name,
  body.sidebar-collapsed .sb-label,
  body.sidebar-collapsed .sb-badge,
  body.sidebar-collapsed .sb-chevron,
  body.sidebar-collapsed .sb-foot-meta,
  body.sidebar-collapsed .sb-foot-org,
  body.sidebar-collapsed .sb-profile-ellipsis {
    display: none;
  }
  /* Collapsed sidebar preference (mandat section 10) : no inline submenu
     expansion, top-level icons only - no flyout/tooltip system exists yet
     in this codebase to build a richer alternative. */
  body.sidebar-collapsed .sb-submenu {
    display: none !important;
  }
  body.sidebar-collapsed .sb-brand {
    justify-content: center;
    padding: 6px 4px 4px;
  }
  body.sidebar-collapsed .sb-item {
    justify-content: center;
    gap: 0;
    padding: 8px;
  }
  body.sidebar-collapsed .sb-foot {
    justify-content: center;
  }
  body.sidebar-collapsed .sb-divider {
    margin: 0 4px;
  }
  /* Parent active state when a child page is open (mandat section 41) :
     renderItem() already applies .submenu-open to the parent whenever
     itself or a descendant is the active page (see sidebar.js), but only
     .is-active carries the visible pill background/color in expanded
     mode - .submenu-open alone is otherwise a chevron-rotation hook only.
     Collapsed mode has no expanded submenu to show the child's own active
     state in, so the top-level icon must carry it here instead. */
  body.sidebar-collapsed .sb-item.submenu-open {
    background: var(--hostome-selected-bg, var(--t1));
    color: var(--hostome-selected-fg, #fff);
  }
  body.sidebar-collapsed .sb-item.submenu-open .sb-ico {
    color: var(--hostome-selected-fg, #fff);
  }
}

[data-theme="dark"] body.sidebar-collapsed .sb-item.submenu-open {
  background: var(--hostome-selected-bg, rgba(124, 178, 255, 0.20)) !important;
  color: var(--hostome-selected-fg, #EAF2FF) !important;
}

[data-theme="dark"] body.sidebar-collapsed .sb-item.submenu-open .sb-ico {
  color: var(--hostome-selected-fg, #EAF2FF) !important;
}

/* Defensive : if the collapsed state is ever restored from persistence
   while the viewport is already mobile-width (e.g. a resize race), never
   collapse the mobile off-canvas panel to a sliver - keep it full-width
   and off-canvas exactly like the non-collapsed mobile sidebar. */
@media (max-width: 860px) {
  body.sidebar-collapsed .sidebar {
    width: 236px;
    padding: 14px;
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
  }
}

.sb-profile-wrap,
.sb-foot {
  margin-top: auto;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 4px;
  text-decoration: none;
}

.sb-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: 'Instrument Serif', Georgia, serif;
  font-style: italic;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 4px 10px -3px var(--accent-ring), inset 0 1px 0 rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.sb-brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--t1);
}

.sb-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--t2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  position: relative;
  cursor: pointer;
}

.sb-item:hover {
  background: var(--surface-3);
  color: var(--t1);
}

.sb-item.is-active {
  background: var(--hostome-selected-bg, var(--t1));
  color: var(--hostome-selected-fg, #fff);
  font-weight: 600;
}

.sb-item.is-active .sb-ico {
  color: var(--hostome-selected-fg, #fff);
}

/* Canonical selected-nav surface (mission GLOBAL-UI-DARK-THEME).
   Light: --hostome-selected-bg = var(--t1) → a solid dark pill (unchanged).
   Dark: the old rule painted the pill with var(--accent) which, before this
   mission, resolved to the legacy Hostome ORANGE - the operator's dark-mode
   finding. It is now a restrained blue-tinted surface + bright blue-white
   text via the theme-aware --hostome-selected-* tokens. Kept !important so it
   still beats the per-page copies of `.sb-item.is-active { background:
   var(--t1) }` that load after this file (var(--t1) is near-white in dark). */
[data-theme="dark"] .sb-item.is-active {
  background: var(--hostome-selected-bg, rgba(124, 178, 255, 0.20)) !important;
  color: var(--hostome-selected-fg, #EAF2FF) !important;
  /* Re-diagnostic: a 16% tint alone read as barely-selected. Solid accent
     edge bar makes the active item unmistakable without a bright fill. */
  box-shadow: inset 3px 0 0 var(--hostome-selected-border, var(--hostome-primary, #7CB2FF)) !important;
}

[data-theme="dark"] .sb-item.is-active .sb-ico {
  color: var(--hostome-primary, #7CB2FF) !important;
}

[data-theme="dark"] .sb-item.is-active .sb-badge {
  background: var(--hostome-primary, #7CB2FF);
  color: var(--hostome-primary-contrast, #0A1524);
}

.sb-ico {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--t3);
  flex-shrink: 0;
}

.sb-item:hover .sb-ico {
  color: var(--t1);
}

.sb-label {
  flex: 1;
}

.sb-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sb-item.is-active .sb-badge {
  background: #fff;
  color: var(--t1);
}

.sb-chevron {
  font-size: 11px;
  color: var(--t4);
  flex-shrink: 0;
  transition: transform 0.2s;
}

.sb-item.submenu-open .sb-chevron {
  transform: rotate(180deg);
}

.sb-item.has-submenu {
  cursor: pointer;
}

.sb-submenu {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 2px 30px;
}

.sb-submenu.is-open {
  display: flex;
}

.sb-subitem {
  border-radius: 6px;
  color: var(--t3);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-subitem:hover {
  background: var(--surface-3);
  color: var(--t1);
}

.sb-subitem.is-active {
  color: var(--accent);
  font-weight: 600;
}

.sb-divider {
  height: 1px;
  background: var(--line);
  margin: 0 8px;
}

.sb-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-3);
}

.sb-foot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2A2A30, #0C0C10);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.sb-foot-meta {
  flex: 1;
  min-width: 0;
}

.sb-foot-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-foot-org {
  font-size: 11.5px;
  color: var(--t3);
  margin-top: 1px;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    transition: transform 0.25s ease;
    z-index: 500;
  }
}

/* Mission HOSTOME_M38_DYNAMIC_SIDEBAR_AND_ACCOUNT_PROFILES.
   "Bientôt disponible" (mandat section 7) : rendu visible, jamais
   display:none, jamais un lien mort - un badge discret + curseur/couleur
   neutres communiquent l'état sans le confondre avec un item actif. Même
   principe que le bouton "Facturation" déjà désactivé de settings.html,
   étendu ici au composant sidebar partagé. */
.sb-item.is-coming-soon,
.sb-subitem.is-coming-soon {
  cursor: default;
  opacity: 0.62;
}
.sb-item.is-coming-soon:hover,
.sb-subitem.is-coming-soon:hover {
  background: transparent;
  color: inherit;
}
.sb-badge--soon {
  background: var(--surface-3);
  color: var(--t3);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  padding: 0 8px;
}
[data-theme="dark"] .sb-item.is-active .sb-badge--soon {
  background: var(--surface-3);
  color: var(--t3);
}

/* Marqueur optionnel/payant (mandat section 16) - "✦" discret, jamais un
   verrou ni un prix codé en dur ; communique le statut de service
   optionnel, pas un refus d'accès. */
.sb-premium-mark {
  color: var(--accent);
  font-size: 11px;
  line-height: 1;
  margin-left: 2px;
}

/* Entrée Administration Hostome (mandat section 10) - visuellement
   distincte des modules métier client, jamais un simple lien parmi
   d'autres. Le contrôle d'accès réel reste exclusivement côté serveur
   (hostome_require_platform_role() sur /api/admin/*) ; ceci n'est qu'une
   séparation visuelle de commodité. */
.sb-item.sb-item--admin {
  background: var(--hostome-navy, #09204d);
  color: #fff;
  border-radius: 8px;
}
.sb-item.sb-item--admin .sb-ico,
.sb-item.sb-item--admin .sb-label {
  color: #fff;
}
.sb-item.sb-item--admin:hover {
  background: var(--hostome-navy, #09204d);
  filter: brightness(1.15);
}

.sb-profile-wrap {
  position: relative;
  margin-top: auto;
}

.sb-profile-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 600;
}

.sb-profile-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t1);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
  background: none;
  font-family: inherit;
  text-align: left;
}

.sb-profile-item:hover {
  background: var(--surface-3);
}

.sb-profile-item i {
  color: var(--t3);
  width: 14px;
  text-align: center;
}

.sb-profile-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.sb-profile-logout {
  color: var(--rose);
}

.sb-profile-logout i {
  color: var(--rose);
}
