/* ═══════════════════════════════════════════════════════════════════════════
   portail.css — Styles dark mode partagés entre tous les modules
   À importer dans chaque vue : <link rel="stylesheet" href="/styles/portail.css">
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts — Design system Camp Bruchési ─────────────────────────── */
/* DM Sans    : corps de texte, labels, données (UI opérationnelle)          */
/* Outfit     : titres de pages et sections dans l'interface                 */
/* IBM Plex Mono : données numériques, codes, tableaux denses               */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=Outfit:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ── Variables globales (dark mode) ─────────────────────────────────────── */
:root {
  /* Couleurs de base */
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --surface2: #242424;
  --border:   #2e2e2e;
  --border2:  #3a3a3a;
  --text:     #e8e6e0;
  --muted:    #737068;
  --muted2:   #9a9590;

  /* Accents par module */
  --accent-finances:  #4ade80;
  --accent-cafeteria: #fb923c;
  --accent-activites: #60a5fa;
  --accent-portail:   #a78bfa;

  /* Sémantique */
  --success:    #4ade80;  --success-bg: rgba(74,222,128,.10); --success-border: rgba(74,222,128,.25);
  --warning:    #fbbf24;  --warning-bg: rgba(251,191,36,.10); --warning-border: rgba(251,191,36,.25);
  --danger:     #f87171;  --danger-bg:  rgba(248,113,113,.10); --danger-border: rgba(248,113,113,.25);
  --info:       #60a5fa;  --info-bg:    rgba(96,165,250,.10); --info-border:   rgba(96,165,250,.25);

  /* Typographie — Design system */
  --sans:  'DM Sans', system-ui, -apple-system, sans-serif;      /* corps, labels, données */
  --title: 'Outfit', system-ui, sans-serif;                       /* titres de pages et sections */
  --mono:  'IBM Plex Mono', 'Courier New', monospace;             /* données numériques, codes */
  --serif: var(--title); /* alias rétrocompatible → pointe sur Outfit */

  /* Tokens de couleur — Design system (partagés light + dark) */
  --color-cream:      #fdefe3;
  --color-sand:       #f4d3a9;
  --color-orange:     #eb7f3d;
  /* Le texte POSÉ sur l'orange. Blanc sur #eb7f3d donne 2,75:1 et 3,76:1 sur le survol
     #c96a2e — sous le seuil WCAG AA de 4,5:1. L'encre donne 6,33:1 et 4,63:1.
     Global, pour que chaque vue module y ait droit sans le redéfinir. (2026-08-31) */
  --c-on-accent:      #1a1a1a;
  --color-sky:        #8bc6f1;
  --color-sky-pale:   #ccedff;
  --color-text:       #1a1a1a;
  --color-text-muted: #5a5a5a;
  --color-danger:     #c0392b;
  --color-success:    #2d6a4f;
  --color-border:     rgba(0,0,0,0.10);

  /* Géométrie */
  --radius:    8px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Sidebar */
  --sidebar-w: 240px;

  /* Tableaux — surchargeable par les modules à thème clair */
  --table-thead-bg:   var(--surface2);
  --table-th-color:   var(--muted);
  --table-td-border:  var(--border);
  /* Défaut clair/subtil : évite un survol quasi noir (#242424) sur les vues claires
     qui n'ont pas surchargé ce token. Les modules à thème clair le redéfinissent déjà. */
  --table-hover-bg:   rgba(0,0,0,.045);
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ── Layout portail ─────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar commune */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand-name {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 400;
}
.sidebar-brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.sidebar-nav { padding: .75rem 0; flex: 1; }
.sidebar-section-label {
  padding: .5rem 1.25rem .25rem;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin-top: .5rem;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .6rem 1.25rem;
  cursor: pointer;
  color: var(--muted2);
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: all .15s;
  text-decoration: none;
}
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active {
  background: var(--surface2);
  color: var(--text);
  border-left-color: var(--accent, var(--accent-portail));
}
.sidebar-item .item-icone { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

/* Contenu principal */
.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.section { flex: 1; padding: 2rem; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.section-titre {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.2;
}

/* ── Composants communs ──────────────────────────────────────────────────── */

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: var(--sans);
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--text); color: var(--bg); }
.btn-primary:hover { opacity: .85; }
.btn-accent    { background: var(--accent, var(--accent-portail)); color: #0a0a0a; }
.btn-accent:hover  { opacity: .88; }
.btn-ghost     { background: none; border: 1px solid var(--border2); color: var(--text); }
.btn-ghost:hover   { background: var(--surface2); }
.btn-danger    { background: none; border: 1px solid var(--danger-border); color: var(--danger); }
.btn-danger:hover  { background: var(--danger-bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Métriques */
.metrics { display: grid; gap: 12px; margin-bottom: 1.75rem; }
.metrics-4 { grid-template-columns: repeat(4, 1fr); }
.metrics-3 { grid-template-columns: repeat(3, 1fr); }
.metrics-2 { grid-template-columns: repeat(2, 1fr); }
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}
.metric-label { font-size: 11px; color: var(--muted); margin-bottom: 5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.metric-value { font-size: 1.6rem; font-weight: 600; line-height: 1; }

/* Tableaux */
.tbl-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.tbl-wrap.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--table-thead-bg); }
th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--table-th-color);
  border-bottom: 1px solid var(--table-td-border);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
th.r { text-align: right; }
th.c { text-align: center; }
td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--table-td-border);
  vertical-align: middle;
}
td.r { text-align: right; }
td.c { text-align: center; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--table-hover-bg); }
.ligne-total td { font-weight: 600; background: var(--table-thead-bg); border-top: 1px solid var(--table-td-border); }
td.vide { color: var(--table-th-color); text-align: center; padding: 2rem; font-style: italic; }

/* Formulaires */
.champ { display: flex; flex-direction: column; gap: 5px; }
.champ label { font-size: 12px; color: var(--muted); font-weight: 500; }
input[type="text"].inp,
input[type="number"].inp,
input[type="date"].inp,
input[type="time"].inp,
input[type="email"].inp,
input[type="password"].inp,
select.sel,
textarea.inp {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .15s;
}
input[type="number"].inp { text-align: right; }
input.inp:focus, select.sel:focus, textarea.inp:focus { border-color: var(--accent, var(--accent-portail)); }
input.inp::placeholder { color: var(--muted); }

/* Badges */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-border);  }
.badge-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-border);    }
.badge-muted   { background: var(--surface2); color: var(--muted); border: 1px solid var(--border2); }

/* Cartes */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.card-grid   { display: grid; gap: 14px; }
.card-grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card-grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Onglets pill */
.tabs-pill {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  width: fit-content;
  flex-wrap: wrap;
}
.tab-pill {
  padding: 5px 14px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted2);
  border: none;
  background: none;
  font-family: var(--sans);
  transition: all .15s;
}
.tab-pill:hover { color: var(--text); }
.tab-pill.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* Alertes */
.alerte {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 1rem;
  border: 1px solid;
}
.alerte-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alerte-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alerte-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-border); }
.alerte-info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info-border); }

/* Séparateur */
.sep { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* Utilitaires */
.flexi   { display: flex; align-items: center; gap: 8px; }
.flexi-sb { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.texte-muted { color: var(--muted); }
.texte-sm    { font-size: 12px; }
.mb1 { margin-bottom: .5rem; }
.mb2 { margin-bottom: 1rem; }
.mb3 { margin-bottom: 1.5rem; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar      { display: none; }
  .metrics-4    { grid-template-columns: repeat(2, 1fr); }
  .metrics-3    { grid-template-columns: repeat(2, 1fr); }
  .section      { padding: 1rem; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Champs de saisie à 16 px sur les petits écrans — RÈGLE GLOBALE DU PORTAIL.

   Sous 16 px, iOS Safari zoome la page dès qu'on touche un champ, et ne dézoome
   jamais : chaque recherche dans le CRM ou saisie à la cafétéria laissait l'iPad
   zoomé. Mesuré le 2026-08-27 : les 5 classes de champ du CRM étaient à 13-14 px
   (.form-input 14, .search-input / .topbar-search-input / .quick-input 13).

   La densité de 12-14 px reste intacte au-dessus de 1024 px : la règle ne vit que
   là où le zoom se produit.

   ⚠️ Le `!important` est INDISPENSABLE ici, ce n'est pas de la paresse : tous les
   champs du portail sont stylés PAR CLASSE (.form-input, .search-input, .rc-input,
   .quick-input…), spécificité (0,1,0), qui bat un sélecteur d'élément (0,0,1) quel
   que soit l'ordre de chargement. Sans lui, cette règle est purement décorative —
   vérifié le 2026-08-27 avant de la livrer. C'est un contournement de bug
   plateforme qu'aucune vue de module ne doit pouvoir annuler.
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ─────────────────────────────────────────────────────────────────────────────
   Lien « ← Portail » ≥ 44 px de haut sur mobile — RÈGLE GLOBALE DU PORTAIL.

   Revue de navigabilité mobile du 2026-08-16 : mesuré à 17-24 px de haut sur les
   26 vues qui portent ce lien (`.topbar-back`, `.act-back-link`) — sous la cible
   tactile minimale de 44 px que ce fichier impose déjà aux boutons de rangée.
   C'est le SEUL contrôle universel (chaque écran en a un) qui restait sous la
   norme depuis cette revue.

   `!important` pour la même raison que la règle des 16 px ci-dessus : chaque vue
   déclare sa PROPRE règle `.topbar-back` (même spécificité 0,1,0) APRÈS ce
   fichier dans l'ordre de chargement — sans lui, cette règle est invisible.
   ───────────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .topbar-back, .act-back-link, .pg-back { min-height: 44px !important; }
}
