/*
 * admin.css — design system du PORTAIL D'ADMINISTRATION Hulotte (SWA dédiée hulotte-admin, docs/16).
 * Autonome (séparé du front public web/css/hulotte.css) mais RÉUTILISE les jetons de marque --h-*
 * pour rester cohérent. Sobre et dense : c'est un outil d'exploitation, pas une page grand public.
 * Prose FR, code EN (CLAUDE.md). Pas de mascotte grand public ici.
 */

@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/atkinson-hyperlegible@latest/latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/atkinson-hyperlegible@latest/latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Baloo 2"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/baloo-2@latest/latin-800-normal.woff2") format("woff2");
}

:root {
  --h-nuit: #1E2A47;
  --h-nuit-2: #2A3A5E;
  --h-fauve: #8A5A34;
  --h-ecorce: #6B4226;
  --h-plumage: #E9C99A;
  --h-creme: #F7EFE2;
  --h-ventre: #F3E3C8;
  --h-or: #E8A33D;
  --h-sarcelle: #2F7F7A;
  --h-terre: #C2552D;
  --h-alerte: #B83A2E;
  --h-encre: #2A1A10;
  --h-blanc: #FFFFFF;

  --a-bg: var(--h-creme);
  --a-surface: var(--h-blanc);
  --a-ink: var(--h-encre);
  --a-muted: var(--h-ecorce);
  /* Action primaire = NUIT (identité Hulotte : --h-primaire vaut nuit en thème clair, pas l'or). */
  --a-primary: var(--h-nuit);
  --a-sur-primary: var(--h-creme);
  /* Accent secondaire = sarcelle (actions/succès Hulotte) ; l'or reste réservé aux accents fins (focus). */
  --a-accent: var(--h-sarcelle);
  --a-focus: var(--h-or);
  --a-danger: var(--h-alerte);
  --a-border: #E2D4BC;

  --a-font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --a-font-title: "Baloo 2", "Atkinson Hyperlegible", system-ui, sans-serif;
  --a-radius: 14px;
  --a-tap: 46px;
  --a-sidebar-w: 248px;
  --a-header-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--a-bg);
  color: var(--a-ink);
  font-family: var(--a-font);
  font-size: 16px;
  line-height: 1.55;
}
h1, h2, h3 { font-family: var(--a-font-title); margin: 0 0 .5rem; color: var(--h-nuit); }
a { color: var(--a-primary); }
.a-muted { color: var(--a-muted); }
.a-container { width: 100%; max-width: 480px; margin: 0 auto; padding: 1.25rem; }

/* ══ Connexion (pages sans coquille) ═══════════════════════════════════════ */
.a-login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; }
.a-login-head { text-align: center; margin-bottom: 1rem; }
.a-login-head img { height: 92px; }
/* Sur fond crème : l'or est proscrit pour du texte (token Hulotte) → sarcelle. */
.a-login-suffix { font-family: var(--a-font-title); font-weight: 800; color: var(--h-sarcelle); letter-spacing: .04em; margin: .4rem 0; }

/* ══ Carte ═════════════════════════════════════════════════════════════════ */
.a-card {
  background: var(--a-surface); border: 1px solid var(--a-border);
  border-radius: var(--a-radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(30,42,71,.06);
}
.a-card h2 { font-size: 1.15rem; }
/* Carte/graphe cliquable : ouvre le détail en grand dans une modale. Retour visuel au survol/focus. */
.a-card--clic { transition: box-shadow .12s, transform .12s, border-color .12s; }
.a-card--clic:hover { box-shadow: 0 4px 14px rgba(30,42,71,.14); border-color: var(--a-primary); transform: translateY(-1px); }
.a-card--clic:focus-visible { outline: 3px solid var(--a-focus); outline-offset: 2px; }
.a-card-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ══ Formulaires ═══════════════════════════════════════════════════════════ */
.a-field { display: block; margin-bottom: .8rem; }
.a-field > span { display: block; font-weight: 700; margin-bottom: .3rem; font-size: .95rem; }
.a-input, .a-select {
  width: 100%; min-height: var(--a-tap); padding: .55rem .7rem;
  border: 1px solid var(--a-border); border-radius: 10px; font: inherit; background: var(--a-surface); color: var(--a-ink);
}
.a-input:focus, .a-select:focus { outline: 3px solid var(--a-focus); outline-offset: 1px; }
.a-error { color: var(--a-danger); font-weight: 700; min-height: 1.2em; margin: .3rem 0; }

/* ══ Boutons ═══════════════════════════════════════════════════════════════ */
.a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--a-tap); padding: .5rem 1rem; border: none; border-radius: 10px;
  font: inherit; font-weight: 700; cursor: pointer; background: var(--a-primary); color: var(--a-sur-primary);
}
.a-btn:hover { filter: brightness(1.12); }
.a-btn:focus-visible { outline: 3px solid var(--a-focus); outline-offset: 2px; }
.a-btn:disabled { opacity: .5; cursor: default; }
.a-btn--ghost { background: transparent; color: var(--a-primary); border: 1px solid var(--a-border); }
.a-btn--accent { background: var(--a-accent); color: #FFFFFF; }
.a-btn--danger { background: var(--a-danger); color: #FFFFFF; }
.a-btn--sm { min-height: 38px; padding: .3rem .7rem; font-size: .9rem; }
/* Bouton-icône carré (actions de tableau) : surface tactile confortable, libellé via aria-label/title. */
.a-btn--icone { min-height: 38px; min-width: 38px; padding: .3rem; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }

/* ══ Tableaux ══════════════════════════════════════════════════════════════ */
.a-table { width: 100%; border-collapse: collapse; }
.a-table th, .a-table td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--a-border); }
.a-table th { font-family: var(--a-font-title); color: var(--h-nuit); font-size: .9rem; }
.a-table tbody tr:hover { background: var(--h-ventre); }
.a-table td.a-actions { white-space: nowrap; display: flex; gap: .4rem; flex-wrap: wrap; }

/* ══ Badges / pastilles ════════════════════════════════════════════════════ */
.a-badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.a-badge--ok { background: #D9ECE9; color: var(--h-sarcelle); }
.a-badge--warn { background: #FBE7CF; color: var(--h-terre); }
.a-badge--off { background: #F0E6D4; color: var(--a-muted); }

/* ══ Jauge quota ═══════════════════════════════════════════════════════════ */
.a-gauge { height: 12px; border-radius: 999px; background: var(--a-border); overflow: hidden; }
.a-gauge > span { display: block; height: 100%; background: var(--a-primary); }
.a-gauge.is-rouge > span { background: var(--a-danger); }
.a-gauge.is-orange > span { background: var(--h-or); }

/* ══ Stats (tableau de bord) ═══════════════════════════════════════════════ */
.a-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.a-stat { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius); padding: 1rem; }
.a-stat b { font-family: var(--a-font-title); font-size: 1.8rem; color: var(--h-nuit); display: block; }
.a-stat span { color: var(--a-muted); }

/* ══ Graphe d'usage (SVG vanilla — pas de librairie) ═══════════════════════ */
.a-chart { width: 100%; height: auto; display: block; }
.a-chart .grid { stroke: var(--a-border); stroke-width: 1; }
.a-chart .axis { fill: var(--a-muted); font-size: 11px; font-family: var(--a-font); }
.a-chart .serie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.a-chart .dot { opacity: .9; pointer-events: none; }
.a-chart .dot-hit { cursor: pointer; }
/* Infobulle de valeur au survol d'une pastille (survol géré en JS). Positionnée au curseur. */
.a-tip { position: fixed; z-index: 80; pointer-events: none; background: var(--h-nuit); color: var(--h-creme);
  padding: .4rem .6rem; border-radius: 8px; font-size: .85rem; line-height: 1.35; box-shadow: 0 4px 14px rgba(30,42,71,.3); max-width: 240px; }
.a-tip b { font-family: var(--a-font-title); }
.a-tip .a-muted { color: var(--h-plumage); }
.a-tip-pt { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: middle; }
.a-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .8rem; }
.a-legend label { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; cursor: pointer; user-select: none; }
.a-legend .swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex: 0 0 auto; }
.a-legend input { margin: 0; }
/* Graphe + légende côte à côte : SVG flexible à gauche, légende en colonne à droite. */
.a-chart-row { display: flex; gap: 1.2rem; align-items: flex-start; }
.a-chart-area { flex: 1 1 auto; min-width: 0; }   /* min-width:0 : laisse le SVG se réduire dans le flex */
.a-legend--cote { flex: 0 0 200px; flex-direction: column; flex-wrap: nowrap; gap: .5rem; margin-top: 0; }
@media (max-width: 760px) {
  .a-chart-row { flex-direction: column; }
  .a-legend--cote { flex-basis: auto; flex-direction: row; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .8rem; }
}

/* ══ Coquille : sidebar + header ═══════════════════════════════════════════ */
.a-has-shell { display: block; }
.a-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--a-sidebar-w); z-index: 40;
  display: flex; flex-direction: column; background: var(--h-nuit); color: var(--h-creme);
  border-right: 3px solid var(--h-or);
}
.a-side-brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.12); min-height: var(--a-header-h); }
.a-side-logo { height: 30px; }
.a-side-suffix { font-family: var(--a-font-title); font-weight: 800; color: var(--h-or); }
.a-side-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem; display: flex; flex-direction: column; gap: .25rem; }
.a-side-link { display: flex; align-items: center; gap: .7rem; color: var(--h-creme); text-decoration: none; font-weight: 700; padding: .6rem .8rem; border-radius: 12px; }
.a-side-link i { width: 1.25rem; text-align: center; opacity: .9; }
.a-side-link:hover { background: rgba(255,255,255,.12); }
/* Actif : sarcelle (action Hulotte) + liseré or fin à gauche — l'or en accent, jamais en grand aplat. */
.a-side-link.active { background: var(--h-sarcelle); color: #FFFFFF; box-shadow: inset 3px 0 0 var(--h-or); }
.a-side-link.active i { opacity: 1; }
.a-side-foot { border-top: 1px solid rgba(255,255,255,.12); padding: .8rem .9rem; display: flex; flex-direction: column; gap: .6rem; }
.a-side-user { display: flex; align-items: center; gap: .55rem; font-size: .9rem; opacity: .9; word-break: break-word; }
.a-side-user i { color: var(--h-or); }
.a-side-logout { display: flex; align-items: center; gap: .5rem; background: transparent; border: 1px solid rgba(255,255,255,.25); color: var(--h-creme); border-radius: 10px; padding: .5rem .7rem; font: inherit; font-weight: 700; cursor: pointer; }
.a-side-logout:hover { background: rgba(255,255,255,.12); }

.a-main { margin-left: var(--a-sidebar-w); }
.a-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .8rem; min-height: var(--a-header-h); padding: 0 1.2rem; background: var(--a-surface); border-bottom: 1px solid var(--a-border); }
.a-header-title { font-family: var(--a-font-title); font-weight: 800; color: var(--h-nuit); font-size: 1.2rem; }
.a-burger { display: none; background: transparent; border: none; font-size: 1.3rem; color: var(--h-nuit); cursor: pointer; }
.a-main-body { padding: 1.3rem; max-width: 1100px; }
/* Pages à large tableau (ex. catalogue) : occuper toute la largeur disponible. */
.a-main-body.a-main-body--large { max-width: none; }

.a-scrim { position: fixed; inset: 0; background: rgba(30,42,71,.4); z-index: 39; }

/* ══ Modale (confirmation + panneau de détail — jamais de confirm() natif, règle #14) ══ */
.a-modal-scrim { position: fixed; inset: 0; background: rgba(30,42,71,.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.a-modal { background: var(--a-surface); border-radius: var(--a-radius); border: 1px solid var(--a-border); max-width: 440px; width: 100%; padding: 1.3rem; }
.a-modal h3 { font-size: 1.2rem; }
.a-modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
/* Variante large pour un panneau de contenu (détail compte) : plus large + corps scrollable. */
.a-modal--large { max-width: 640px; max-height: 88vh; display: flex; flex-direction: column; padding: 0; }
/* Variante large pour l'analyse d'un graphe en grand (page Audience) : laisse de la place au SVG. */
.a-modal--graphe { max-width: min(960px, 94vw); }
.a-modal--large .a-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--a-border); }
.a-modal--large .a-modal-head h2 { margin: 0; font-size: 1.2rem; }
.a-modal--large .a-modal-body { padding: 1.1rem 1.3rem; overflow-y: auto; }
.a-modal-close { background: transparent; border: none; cursor: pointer; font-size: 1.25rem; line-height: 1; color: var(--a-muted); padding: .2rem .4rem; border-radius: 8px; }
.a-modal-close:hover { background: var(--h-ventre); color: var(--a-ink); }

/* ══ Toast ═════════════════════════════════════════════════════════════════ */
.a-toast { position: fixed; left: 50%; bottom: 1.3rem; transform: translateX(-50%); z-index: 70; background: var(--h-nuit); color: var(--h-creme); padding: .7rem 1.1rem; border-radius: 12px; box-shadow: 0 4px 16px rgba(30,42,71,.3); max-width: 90vw; }

/* ══ Badge version ═════════════════════════════════════════════════════════ */
#a-version-badge { position: fixed; right: 8px; bottom: 6px; z-index: 50; font: 400 12px/1 monospace; opacity: .6; pointer-events: none; }

@media (max-width: 860px) {
  .a-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .a-sidebar.open { transform: none; }
  .a-main { margin-left: 0; }
  .a-burger { display: inline-flex; }
}
