/* =============================================================================
   shell.css — Layout applicatif Innled QR v1.19.3
   -----------------------------------------------------------------------------
   Contient uniquement la structure du shell :
     - app-frame (grille desktop 288px + 1fr)
     - app-sidebar (dégradé navy, sticky, scroll)
     - sidebar-brand, sidebar-nav, sidebar-user
     - nav-group, nav-group-label, nav-item, nav-icon (pastilles colorees)
     - nav-badge-count
     - app-main, app-topbar, page-content, .pg
   Toutes les valeurs proviennent de tokens.css.
   Icones de navigation : Material Symbols Rounded (ligatures, locale).
   Maquette : handoff §3 — Layout & shell applicatif.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   App frame — grille principale desktop
   --------------------------------------------------------------------------- */
.app-frame {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  font-family: var(--font-sans);
}

/* ---------------------------------------------------------------------------
   Backdrop du tiroir (visible seulement en mobile — voir responsive.css)
   --------------------------------------------------------------------------- */
.app-drawer-backdrop {
  display: none; /* actif via responsive.css @media */
}

/* ---------------------------------------------------------------------------
   Sidebar (desktop : fixe sticky ; mobile : tiroir via responsive.css)
   --------------------------------------------------------------------------- */
.app-sidebar {
  background: var(--sidebar-grad);
  color: var(--on-dark);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 20;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  /* Scrollbar discrete sur la sidebar */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* ---------------------------------------------------------------------------
   Brand (logo + sous-titre)
   --------------------------------------------------------------------------- */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-bottom: 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand img {
  width: 100px;
  height: auto;
  filter: brightness(0) invert(1);
}

.sidebar-brand span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
}

/* ---------------------------------------------------------------------------
   Navigation — groupes
   --------------------------------------------------------------------------- */
.sidebar-nav { flex: 1; }

.nav-group { margin-bottom: 4px; }

.nav-group-label {
  display: block;
  padding: 10px 12px 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.38);
}

/* ---------------------------------------------------------------------------
   Navigation — items
   Maquette : min-height 48px, padding 10/12, radius 13, gap 13, 14px/600.
   Actif : dégradé or, ombre dorée, texte var(--nav-active-ink)/800.
   --------------------------------------------------------------------------- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: var(--nav-item-min); /* 48px */
  padding: 10px 12px;
  border-radius: 13px;
  margin-bottom: 3px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,.88);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background var(--t-fast);
  line-height: 1.25;
}

.nav-item.active {
  background: var(--gold-grad-active);
  box-shadow: 0 10px 22px -10px rgba(201,162,78,.8);
  color: var(--nav-active-ink);
  font-weight: 800;
}

.nav-item:hover:not(.active) {
  background: rgba(255,255,255,.08);
}

/* Badge compteur (bugs non résolus) */
.nav-badge-count {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--danger);
  color: var(--on-dark);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.6;
}

/* ---------------------------------------------------------------------------
   Icone nav — pastille colorée 34×34
   Maquette : radius 10, fond = couleur item, ombre 0 4px 10px -4px <couleur>.
   L'icone est un Material Symbol Rounded (ligature, FILL 1, taille 20px).
   --------------------------------------------------------------------------- */
.nav-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--c, var(--neutral));
  box-shadow: 0 4px 10px -4px var(--c, var(--neutral));
  overflow: hidden;
}

/* Material Symbols Rounded dans la pastille */
.nav-icon .material-symbols-rounded {
  font-size: 20px;
  color: var(--on-dark);
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 20;
  line-height: 1;
}

/* SVG legacy (conserve pendant la migration des templates) */
.nav-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--on-dark);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Icone active (fond clair) : texte sombre */
.nav-item.active .nav-icon .material-symbols-rounded { color: var(--nav-active-ink); }
.nav-item.active .nav-icon svg { stroke: var(--nav-active-ink); }

/* ---------------------------------------------------------------------------
   Couleurs des pastilles — une variable --c par item de nav
   Maquette README §3 — ordre exact : PRODUITS / REGLES / DONNEES / ADMIN
   --------------------------------------------------------------------------- */
.nav-icon-home       { --c: var(--gold); }     /* or — Accueil */
.nav-icon-products   { --c: var(--ok-icon); }  /* vert — Produits */
.nav-icon-quality    { --c: var(--info-2); }   /* bleu — Controle qualite */
.nav-icon-finfab     { --c: var(--info-2); }   /* bleu — Fin fabrication */
.nav-icon-logistique { --c: var(--neutral); }  /* gris — Logistique */
.nav-icon-generate   { --c: var(--violet); }   /* violet — Generer */
.nav-icon-catalog    { --c: var(--orange); }   /* orange — Referentiel */
.nav-icon-attributes { --c: var(--teal); }     /* teal — Perso fiche interne */
.nav-icon-qc         { --c: var(--violet); }   /* violet — Regles QC */
.nav-icon-public     { --c: var(--info-2); }   /* bleu — Fiche publique */
.nav-icon-trash      { --c: var(--danger-2); } /* rouge — Corbeille */
.nav-icon-sync       { --c: var(--info-2); }   /* bleu — Sync SQL */
.nav-icon-cms        { --c: var(--teal); }     /* teal — CMS intranet */
.nav-icon-cms-public { --c: var(--info-2); }   /* bleu — CMS public */
.nav-icon-users      { --c: var(--violet); }   /* violet — Utilisateurs */
.nav-icon-bugs       { --c: var(--neutral); }  /* gris — Journal bugs */
.nav-icon-password   { --c: var(--orange); }   /* orange — Mot de passe */
.nav-icon-logout     { --c: var(--neutral); }  /* gris — Deconnexion */

/* ---------------------------------------------------------------------------
   Utilisateur en pied de sidebar
   --------------------------------------------------------------------------- */
.sidebar-user {
  margin-top: auto;
  padding: 14px 12px 0;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--on-dark);
}

.sidebar-user span {
  font-size: 12px;
  color: rgba(255,255,255,.52);
}

.sidebar-sync {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  margin-top: 3px;
}

/* ---------------------------------------------------------------------------
   Zone principale (main)
   --------------------------------------------------------------------------- */
.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  overflow: hidden;
  padding: 0; /* reset app.css padding */
}

/* ---------------------------------------------------------------------------
   Topbar applicative (desktop : sobre + version + avatar)
   Maquette §3 : fond cream, h=56px, version pill, avatar.
   En mobile (voir responsive.css) : fond navy-900, h=60px, logo.
   --------------------------------------------------------------------------- */
.app-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  flex: 0 0 56px;
  padding: 0 28px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}

/* Hamburger : masque sur desktop, visible sur mobile via responsive.css */
.app-burger { display: none; }
.app-burger:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-version-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: var(--r-pill);
  background: rgba(7,27,59,.07);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.app-version-pill strong {
  color: var(--ink);
  font-weight: 800;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(7,27,59,.1);
  border: 1px solid rgba(7,27,59,.12);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  flex-shrink: 0;
}

.topbar-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

/* Logo/nom dans topbar mobile (masque sur desktop) */
.topbar-brand-mobile { display: none; line-height: 1.2; }
.topbar-brand-mobile strong {
  display: block;
  font-size: 15px;
  font-weight: 900;
  color: var(--on-dark);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.topbar-brand-mobile span {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .12em;
}

/* ---------------------------------------------------------------------------
   Zone de contenu (scrollable)
   --------------------------------------------------------------------------- */
.page-content {
  flex: 1;
  overflow: auto;
  background: var(--cream);
}

/* Wrapper de padding standard pour chaque page migrée */
.pg {
  padding: var(--pad-app); /* 30px 34px 44px */
}

/* ===========================================================================
   BANDEAU BLEU COMMUN — sur toutes les pages intranet (v2.20.0)
   Logo + titre (+ sous-titre, + sélecteur de famille). Plein largeur : annule
   le padding de .page-content (14px 28px). Rendu dans base.html.
   =========================================================================== */
.rules-band {
  position: relative;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: -14px -28px 22px; padding: 34px 30px;
  background: var(--hero-grad);
}
/* Filigrane NN innled : borné par la hauteur du bandeau (top/bottom) pour ne
   jamais déborder — SANS overflow:hidden sur le bandeau, sinon le menu déroulant
   famille (qui dépasse sous le bandeau) est coupé. */
.rules-band::after {
  content: ""; position: absolute; top: 10px; bottom: 10px; right: 26px; width: 240px;
  z-index: 0; pointer-events: none;
  background: url('/static/icons/innled-watermark-nn.png') no-repeat center right / contain;
  filter: brightness(0) invert(1);
  opacity: .07;
}
.rules-band > * { position: relative; z-index: 1; }
.rules-band__titles { flex: 1; min-width: 240px; }
/* Préfixe body:not(...) pour battre la règle globale `body:not() h1` (titre sombre sinon). */
body:not(.login-page):not(.public-product-page) .rules-band__titles h1 { margin: 0; font-size: 30px; font-weight: 800; color: var(--on-dark); letter-spacing: -.015em; }
body:not(.login-page):not(.public-product-page) .rules-band__titles p { margin: 6px 0 0; font-size: 14px; color: #9fb8d6; }
.page-band__eyebrow { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-light); margin-bottom: 5px; }

/* Sélecteur de famille (dropdown natif <details>) */
.rules-famsel { position: relative; flex-shrink: 0; }
.rules-famsel > summary {
  display: flex; align-items: center; gap: 11px; cursor: pointer; list-style: none;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  border-radius: 13px; padding: 7px 8px 7px 15px;
}
.rules-famsel > summary::-webkit-details-marker { display: none; }
.rules-famsel__col { display: flex; flex-direction: column; line-height: 1.2; }
.rules-famsel__label { font-family: var(--font-mono); font-size: 8px; letter-spacing: .14em; text-transform: uppercase; color: #9fb8d6; }
.rules-famsel__current { font-size: 15px; font-weight: 800; color: var(--on-dark); margin-top: 1px; }
.rules-famsel__caret { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; background: var(--gold-grad-active); color: var(--nav-active-ink); }
.rules-famsel__menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 210px; max-height: 320px; overflow: auto;
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: var(--r-field); box-shadow: var(--sh-panel); padding: 6px;
}
.rules-famsel__item { display: block; padding: 9px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; }
.rules-famsel__item:hover { background: var(--surface-subtle); }
.rules-famsel__item.is-current { background: rgba(217,168,67,.14); color: var(--gold-extra-dark); }

@media (max-width: 760px) {
  .rules-band { margin: -14px -16px 16px; padding: 16px 16px; }
  body:not(.login-page):not(.public-product-page) .rules-band__titles h1 { font-size: 20px; }
  .rules-famsel { width: 100%; }
}

/* ===========================================================================
   Bouton bascule thème clair/sombre (topbar)
   =========================================================================== */
.topbar-theme {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-sans); font-size: 12.5px; font-weight: 700;
  cursor: pointer;
}
.topbar-theme:hover { background: var(--surface-subtle); }
.topbar-theme .material-symbols-rounded { font-size: 18px; color: var(--gold-deep); }

/* Contraste topbar en mode sombre (les fonds rgba navy deviennent invisibles). */
:root[data-theme="dark"] .app-version-pill { background: rgba(255,255,255,.07); }
:root[data-theme="dark"] .topbar-avatar { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.16); }
:root[data-theme="dark"] .app-topbar { border-bottom-color: rgba(255,255,255,.10); }
