/* ============================================================
   ORPC Meyrin-Mandement — Design System
   assets/css/design-system.css
   Source : Charte graphique officielle, avril 2026
   ============================================================ */

/* ── Tokens de base ───────────────────────────────────────── */
:root {
  /* Couleurs primaires */
  --orpc-orange:        #b35900;  /* Primaire — titres, accents, filets */
  --orpc-orange-hover:  #8f4600;  /* Survol foncé */
  --orpc-orange-light:  #f5e6d8;  /* Fond teinté orange */

  /* Ardoises */
  --orpc-ardoise-med:   #3d4050;  /* Ardoise foncé — en-têtes, fonds sombres */
  --orpc-ardoise-clair: #4a4d5e;  /* Ardoise moyen — corps, labels */
  --orpc-ardoise-pale:  #6b6f80;  /* Ardoise pâle — légendes, secondaire */

  /* Neutres */
  --orpc-gris-perle:    #f0f0f2;  /* Fond alterné, fonds de page */
  --orpc-gris-border:   #d8d8dc;  /* Bordures subtiles */
  --orpc-blanc:         #ffffff;  /* Fond principal */

  /* Accent */
  --orpc-bleu-marine:   #1a3fa0;  /* Liens, validation, statut positif */
  --orpc-bleu-hover:    #123078;  /* Survol bleu foncé */

  /* Alias sémantiques */
  --color-primary:       var(--orpc-orange);
  --color-primary-fg:    var(--orpc-blanc);
  --color-secondary:     var(--orpc-ardoise-med);
  --color-secondary-fg:  var(--orpc-blanc);
  --color-body:          var(--orpc-ardoise-clair);
  --color-muted:         var(--orpc-ardoise-pale);
  --color-bg:            var(--orpc-blanc);
  --color-bg-alt:        var(--orpc-gris-perle);
  --color-border:        var(--orpc-gris-border);
  --color-border-accent: var(--orpc-orange);
  --color-link:          var(--orpc-bleu-marine);

  /* Statuts */
  --color-success:       #1a7a40;
  --color-warning:       #b35900;
  --color-danger:        #c0392b;
  --color-info:          var(--orpc-bleu-marine);

  /* ── Typographie ──────────────────────────────────────────── */
  --font-primary: Arial, Helvetica, sans-serif;
  --font-mono:    "Courier New", Courier, monospace;

  /* Échelle (rem, base 16px) */
  --text-xs:   0.75rem;    /* 10–11pt légendes */
  --text-sm:   0.875rem;   /* 11pt tableaux */
  --text-base: 1rem;       /* 12pt corps */
  --text-md:   1.125rem;   /* 13–14pt sous-titres */
  --text-lg:   1.25rem;    /* 14–16pt H1 section */
  --text-xl:   1.5rem;     /* 18–20pt titre document */
  --text-2xl:  1.875rem;   /* 24pt titre diapositive */
  --text-3xl:  2.25rem;    /* 28pt titre principal */

  /* Interlignage */
  --leading-tight:  1.25;
  --leading-normal: 1.5;
  --leading-loose:  1.75;

  /* Graisse */
  --fw-normal: 400;
  --fw-bold:   700;

  /* ── Espacement ───────────────────────────────────────────── */
  --space-1:   4px;
  --space-2:   8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-5:   20px;
  --space-6:   24px;
  --space-8:   32px;
  --space-10:  40px;
  --space-12:  48px;

  /* ── Arrondis ────────────────────────────────────────────── */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-pill: 99px;

  /* ── Bordures ────────────────────────────────────────────── */
  --border-accent: 2px solid var(--orpc-orange);
  --border-subtle: 1px solid var(--orpc-gris-border);

  /* ── Ombres ──────────────────────────────────────────────── */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08), 0 0.5px 1px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.16), 0 2px 6px rgba(0,0,0,0.08);

  /* ── Transitions ─────────────────────────────────────────── */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
}

/* ── Styles des éléments sémantiques ──────────────────────── */

body {
  margin:       0;            /* Reset marge navigateur par défaut (8px) — nav/footer pleine largeur */
  font-family:  var(--font-primary);
  font-size:    var(--text-base);
  font-weight:  var(--fw-normal);
  line-height:  var(--leading-normal);
  color:        var(--color-body);
  background:   var(--color-bg);
}

h1 {
  font-family:   var(--font-primary);
  font-size:     var(--text-xl);
  font-weight:   var(--fw-bold);
  line-height:   var(--leading-tight);
  color:         var(--orpc-orange);
  margin-bottom: var(--space-4);
}

h2 {
  font-family:   var(--font-primary);
  font-size:     var(--text-lg);
  font-weight:   var(--fw-bold);
  line-height:   var(--leading-tight);
  color:         var(--orpc-ardoise-med);
  margin-bottom: var(--space-3);
}

h3 {
  font-family:   var(--font-primary);
  font-size:     var(--text-md);
  font-weight:   var(--fw-bold);
  line-height:   var(--leading-tight);
  color:         var(--orpc-ardoise-clair);
  margin-bottom: var(--space-2);
}

p {
  font-size:     var(--text-base);
  line-height:   var(--leading-normal);
  color:         var(--color-body);
  margin-bottom: var(--space-4);
}

small,
caption,
figcaption {
  font-size:  var(--text-xs);
  font-style: italic;
  color:      var(--color-muted);
}

a {
  color:           var(--color-link);
  text-decoration: underline;
}
a:hover { color: var(--orpc-bleu-hover); }

code,
pre {
  font-family:   var(--font-mono);
  font-size:     var(--text-sm);
  background:    var(--orpc-gris-perle);
  padding:       var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

/* ── En-tête de document ──────────────────────────────────── */
.doc-header {
  background:    var(--orpc-blanc);
  border-bottom: var(--border-accent);
  padding:       var(--space-4) var(--space-6);
  display:       flex;
  align-items:   center;
  gap:           var(--space-4);
}
.doc-header img { height: 48px; width: auto; }
.doc-header__title {
  font-size:   var(--text-sm);
  color:       var(--orpc-ardoise-med);
  font-weight: var(--fw-bold);
}

/* ── Bande de section ─────────────────────────────────────── */
.section-band {
  background:  var(--orpc-ardoise-med);
  color:       var(--orpc-blanc);
  font-weight: var(--fw-bold);
  font-size:   var(--text-md);
  padding:     var(--space-3) var(--space-6);
}

/* ── Tableau ─────────────────────────────────────────────── */
table { border-collapse: collapse; width: 100%; }
thead tr { background: var(--orpc-ardoise-med); color: var(--orpc-blanc); }
thead th {
  font-weight: var(--fw-bold);
  font-size:   var(--text-sm);
  padding:     var(--space-2) var(--space-3);
  text-align:  left;
}
tbody tr:nth-child(even) { background: var(--orpc-gris-perle); }
tbody td {
  font-size: var(--text-sm);
  padding:   var(--space-2) var(--space-3);
  color:     var(--color-body);
}
.table-total td {
  background:  var(--orpc-orange);
  color:       var(--orpc-blanc);
  font-weight: var(--fw-bold);
}

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
  font-family:   var(--font-primary);
  font-weight:   var(--fw-bold);
  font-size:     var(--text-sm);
  padding:       var(--space-2) var(--space-5);
  border:        none;
  border-radius: var(--radius-pill);
  cursor:        pointer;
  transition:    background var(--transition-fast), transform var(--transition-fast);
  display:       inline-flex;
  align-items:   center;
  justify-content: center;
  gap:           var(--space-2);
  text-decoration: none;
  min-height:    44px;          /* Cible touch ≥ 44×44 (Apple HIG / WCAG 2.5.5) */
}
.btn:active { transform: scale(0.98); }

/* Tablist : sécurité touch même si la classe .btn n'est pas appliquée */
[role="tab"] { min-height: 44px; }

.btn-primary            { background: var(--orpc-orange);      color: var(--orpc-blanc); }
.btn-primary:hover      { background: var(--orpc-orange-hover); }
.btn-secondary          { background: var(--orpc-ardoise-med); color: var(--orpc-blanc); }
.btn-secondary:hover    { background: #2d303d; }
.btn-outline            { background: transparent; color: var(--orpc-orange); border: 2px solid var(--orpc-orange); }
.btn-outline:hover      { background: var(--orpc-orange-light); }
.btn-ghost              { background: transparent; color: var(--color-body); }
.btn-ghost:hover        { background: var(--orpc-gris-perle); }
.btn-danger             { background: var(--color-danger); color: var(--orpc-blanc); }
.btn-danger:hover       { background: #a93228; }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-md); }

/* ── Formulaires ─────────────────────────────────────────── */
.form-label {
  font-weight:   var(--fw-bold);
  font-size:     var(--text-sm);
  color:         var(--orpc-ardoise-med);
  display:       block;
  margin-bottom: var(--space-1);
}
.form-input {
  font-family:   var(--font-primary);
  font-size:     var(--text-base);
  color:         var(--color-body);
  background:    #f5f5f7;
  border:        1.5px solid transparent;
  border-radius: var(--radius-md);
  padding:       var(--space-2) var(--space-3);
  width:         100%;
  min-height:    44px;          /* Cible touch ≥ 44×44 (Apple HIG / WCAG 2.5.5) */
  box-sizing:    border-box;
  transition:    border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus {
  outline:      none;
  background:   var(--orpc-blanc);
  border-color: var(--orpc-orange);
  box-shadow:   0 0 0 4px rgba(179,89,0,0.12);
}
.form-input.error {
  background:   var(--orpc-blanc);
  border-color: var(--color-danger);
  box-shadow:   0 0 0 4px rgba(192,57,43,0.10);
}
.form-hint  { font-size: var(--text-xs); color: var(--color-muted); margin-top: var(--space-1); font-style: italic; }
.form-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: var(--space-1); }

/* ── Cartes ──────────────────────────────────────────────── */
.card {
  background:    var(--orpc-blanc);
  border-radius: var(--radius-md);
  box-shadow:    var(--shadow-sm);
  padding:       var(--space-5);
}
.card-accent { border-left: 3px solid var(--orpc-orange); }

/* ── Badges & Statuts (style macOS arrondi) ──────────────── */
.badge {
  display:        inline-flex;
  align-items:    center;
  gap:            var(--space-1);
  font-size:      var(--text-xs);
  font-weight:    var(--fw-bold);
  padding:        3px 10px;
  border-radius:  var(--radius-pill);   /* pill — style macOS */
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.badge-orange  { background: var(--orpc-orange-light); color: var(--orpc-orange); }
.badge-slate   { background: #e0e0e4;                   color: var(--orpc-ardoise-med); }
.badge-blue    { background: #dce5f7;                   color: var(--orpc-bleu-marine); }
.badge-success { background: #d4edda;                   color: var(--color-success); }
.badge-danger  { background: #fde8e6;                   color: var(--color-danger); }

/* Indicateur de statut (point coloré + texte) */
.status-dot {
  display:     inline-flex;
  align-items: center;
  gap:         var(--space-1);
  font-size:   var(--text-sm);
  color:       var(--orpc-ardoise-clair);
  font-weight: var(--fw-bold);
}
.status-dot__indicator {
  width:         8px;
  height:        8px;
  border-radius: 50%;
  flex-shrink:   0;
}

/* ── Pied de page de document ────────────────────────────── */
.doc-footer {
  font-size:   var(--text-xs);
  font-style:  italic;
  color:       var(--color-muted);
  border-top:  var(--border-subtle);
  padding-top: var(--space-3);
  margin-top:  var(--space-8);
}

/* ── Mot de passe affiché dans un flash one-shot ─────────── */
/* Utilisé dans create/reset_mdp : police mono, fond orange pâle,
   user-select:all pour copie en un clic. */
.mdp-flash {
  font-family:    'Courier New', Courier, monospace;
  background:     var(--orpc-orange-light);
  color:          var(--orpc-ardoise-med);
  padding:        0.1em 0.4em;
  border-radius:  4px;
  font-weight:    600;
  user-select:    all;
  letter-spacing: 0.05em;
}

/* V2.2 — Carte propriétaire grisée (abri non attaché à campagne active) */
.card--disabled {
    opacity: 0.55;
    filter: grayscale(0.4);
}
.card--disabled .card-accent { background: transparent; }

/* ── Conteneur principal admin (V2.4 T7, max-width ajustée 2026-05-26) ──
   max-width 1091px content + padding 16px × 2 = 1123px box totale en desktop
   (alignement visuel avec contenu nav-admin demandé par Yvan). */
.admin-container {
    max-width: 1091px;
    margin:    0 auto;
    padding:   var(--space-6) var(--space-4);
}

@media (max-width: 1150px) {
    .admin-container { padding: var(--space-6) var(--space-6); }
}

@media (max-width: 768px) {
    .admin-container { padding: var(--space-4) var(--space-3); }
}

/* =========================================================================
   V2.5 — Footer global + bandeau cookies
   ========================================================================= */

/* Layout flex column sur <body> : pousse le footer en bas si contenu court */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Tout enfant direct de body qui n'est ni footer ni bandeau prend l'espace.
   width:100% corrige le shrink-to-fit imposé par body en flex-column sur
   les containers à max-width + content-box (sinon .admin-container se
   contracte à la max-content du contenu interne — bug V2.5 dashboard). */
body > main,
body > .page-container,
body > .dashboard-container,
body > .admin-container,
body > .container,
body > section,
body > nav + *:not(footer):not(.cookie-banner):not(script) {
  flex: 1 0 auto;
  width: 100%;
  box-sizing: border-box;   /* corrige le débordement padding (leçon 2026-06-04) */
}

/* Footer global */
.site-footer {
  background: var(--orpc-ardoise-med);
  color: #fff;
  padding: var(--space-6);
  margin-top: auto; /* poussé en bas par flex column */
  flex-shrink: 0;
}
.site-footer__container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-6);
  max-width: 1280px;
  margin: 0 auto var(--space-4);
}
.site-footer__col--left {
  flex: 1 1 auto;
  min-width: 0;
}
.site-footer__title {
  font-weight: 600;
  margin: 0 0 var(--space-2);
  color: #fff; /* override règle globale p { color: var(--color-body) } */
}
.site-footer__address {
  font-style: normal;
  line-height: 1.6;
  margin: 0;
  font-size: 0.9rem;
}

/* Liens verticaux à droite — sans soulignement par défaut, underline au hover/focus */
.site-footer__links {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.site-footer__links li {
  margin: 0;
}
.site-footer__links a,
.site-footer__links button[data-cookie-manage] {
  color: #fff;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.site-footer__links a:hover,
.site-footer__links a:focus,
.site-footer__links button[data-cookie-manage]:hover,
.site-footer__links button[data-cookie-manage]:focus {
  color: var(--orpc-orange-light); /* WCAG AA : beige clair sur ardoise ≈ 9:1 */
  text-decoration: underline; /* affordance au survol/focus uniquement */
}

/* Lien mailto dans l'adresse (gauche) — soulignement par défaut, comportement classique */
.site-footer__address a {
  color: #fff;
  text-decoration: underline;
}
.site-footer__address a:hover,
.site-footer__address a:focus {
  color: var(--orpc-orange-light);
}

.site-footer__copyright {
  text-align: center;
  margin: 0;
  opacity: 0.85;
  font-size: 0.85rem;
  color: #fff; /* override règle globale p { color: var(--color-body) } */
}

/* Masque le bouton "Gérer mes cookies" tant que le bandeau de consentement
   est déjà ouvert — sinon le clic semble ne rien faire (action redondante). */
body.has-cookie-banner .site-footer__links li:has(button[data-cookie-manage]) {
  display: none;
}

@media (max-width: 768px) {
  .site-footer__container {
    flex-direction: column;
    gap: var(--space-4);
  }
  .site-footer__links {
    text-align: left;
  }
  .site-footer {
    padding: var(--space-4);
  }
}

/* Bouton stylisé comme un lien inline (utilisé pour "Gérer mes cookies" dans un paragraphe) */
.inline-link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--color-link);
  text-decoration: underline;
  cursor: pointer;
}
.inline-link-button:hover,
.inline-link-button:focus {
  color: var(--orpc-bleu-hover);
}

/* Variable utilisée pour pousser le contenu vers le haut quand le bandeau est visible */
:root {
  --cookie-banner-height: 180px;
}

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--orpc-bleu-marine);
  color: #fff;
  padding: var(--space-4) var(--space-6);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  max-width: 100%;
  box-sizing: border-box;
}

/* Visibilité togglée par la classe ajoutée au <body> */
body.has-cookie-banner .cookie-banner {
  transform: translateY(0);
}

/* Le bandeau couvre éventuellement le bas du footer pendant le consentement
   (acceptable : le bouton "Gérer mes cookies" du footer est masqué dans ce cas,
   l'utilisateur consente via le bandeau lui-même). Pas de margin/padding bottom
   sur le body ou le footer → le scroll s'arrête au footer. */

.cookie-banner__text {
  margin: 0 0 var(--space-3);
  max-width: 800px;
  line-height: 1.5;
  color: #fff; /* override règle globale p { color: var(--color-body) } */
}
.cookie-banner__text a {
  color: #fff;
  text-decoration: underline;
}
.cookie-banner__text a:hover,
.cookie-banner__text a:focus {
  color: var(--orpc-orange-light);
}
.cookie-banner__actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  :root {
    --cookie-banner-height: 260px;
  }
  .cookie-banner__text {
    font-size: 0.9rem;
  }
  .cookie-banner__actions {
    flex-direction: column;
  }
  .cookie-banner__actions .btn {
    width: 100%;
  }
}

/* =========================================================================
   V2.6 — Chrome admin : entête (topbar) + sidebar repliable
   Pattern : sidebar position:fixed + body padding-left (border-box).
   Desktop : ouverte par défaut ; html.sidebar-collapsed la replie.
   Mobile (≤768) : tiroir off-canvas fermé ; html.sidebar-mobile-open l'ouvre.
   ========================================================================= */
:root {
  --sidebar-w: 256px;
  --topbar-h:  60px;
}

/* box-sizing border-box sur body SEUL (body n'a aucun padding par défaut → sûr,
   n'altère pas le calcul content-box de .admin-container). Permet padding-left
   = largeur sidebar sans provoquer de scroll horizontal. */
body { box-sizing: border-box; transition: padding-left var(--transition-base); }

/* Décalage du contenu (desktop, sidebar ouverte par défaut).
   Scopé à body:has(.admin-topbar) → n'affecte QUE les pages admin ;
   login / propriétaire / mentions-légales (sans topbar) restent intacts. */
@media (min-width: 769px) {
  body:has(.admin-topbar) { padding-left: var(--sidebar-w); }
  html.sidebar-collapsed body:has(.admin-topbar) { padding-left: 0; }
}

/* Anti-shrink + border-box pour le contenu admin (la topbar remplace l'ancien
   <nav>, donc on cible « tout frère après .admin-topbar » hors chrome/footer). */
body > .admin-topbar ~ *:not(.admin-sidebar):not(.sidebar-overlay):not(.site-footer):not(.cookie-banner):not(script) {
  flex: 1 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* ── Topbar (entête) ── */
.admin-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--topbar-h);
  padding: var(--space-2) var(--space-4);
  background: var(--orpc-ardoise-med);
  border-bottom: 3px solid var(--orpc-orange);
  color: #fff;
}
.admin-topbar__brand {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: var(--fw-bold); white-space: nowrap; color: #fff;
}
.admin-topbar__brand img { height: 38px; width: auto; }
.admin-topbar__title { font-size: var(--text-md); }
.admin-topbar__user {
  margin-left: auto;
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-xs); color: var(--orpc-gris-perle); white-space: nowrap;
}
.admin-topbar__login { display: inline-flex; align-items: center; gap: var(--space-1); }
.admin-topbar__user .badge { font-size: 10px; }

/* ── Bouton toggle (44px = cible tactile WCAG 2.5.5, leçon 2026-05-08) ── */
.admin-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  color: #fff; cursor: pointer;
}
.admin-toggle:hover { background: rgba(255,255,255,.12); }

/* ── Sidebar fixe pleine hauteur ── */
.admin-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); z-index: 20;
  background: var(--orpc-ardoise-med);
  border-right: 1px solid rgba(255,255,255,.08);
  overflow-y: auto;
  padding: calc(var(--topbar-h) + var(--space-2)) 0 var(--space-4);
  transform: translateX(0);
  transition: transform var(--transition-base);
}
@media (min-width: 769px) {
  html.sidebar-collapsed .admin-sidebar { transform: translateX(-100%); }
}
.admin-sidebar a {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  color: #fff; text-decoration: none; font-size: var(--text-sm);
  border-left: 3px solid transparent;
}
.admin-sidebar a:hover { background: rgba(255,255,255,.08); }
.admin-sidebar a.nav-active {
  background: var(--orpc-orange); color: #fff;
  font-weight: var(--fw-bold); border-left-color: #fff;
}
.admin-sidebar a i, .admin-sidebar a svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Overlay (mobile uniquement) ── */
.sidebar-overlay { display: none; }

/* ── Mobile (≤768px) : tiroir off-canvas fermé par défaut + overlay ── */
@media (max-width: 768px) {
  body { padding-left: 0; }
  .admin-sidebar {
    top: var(--topbar-h); padding-top: var(--space-2);
    z-index: 50; box-shadow: 2px 0 12px rgba(0,0,0,.3);
    transform: translateX(-100%);
  }
  html.sidebar-mobile-open .admin-sidebar { transform: translateX(0); }
  html.sidebar-mobile-open .sidebar-overlay {
    display: block; position: fixed; inset: 0; top: var(--topbar-h);
    background: rgba(0,0,0,.45); z-index: 40;
  }
  .admin-topbar__title       { display: none; } /* gain de place mobile */
  .admin-topbar__login .badge { display: none; }
}
