/* ═══════════════════════════════════════════════════════════════════════════
   Arkensai · admin-pages.css · v2.5 · 2026-07-12
   ═══════════════════════════════════════════════════════════════════════════

   CHANGELOG
   ─────────
   v2.5 (2026-07-12) — Sélecteur mobile élargi pour cacher les liens
     admin.html / editorial.html / admin_mcp.html. La v2.4 ne matchait
     que dans .admin-sidebar__nav avec href sans slash initial — le
     lien du dropdown d'index.html (href="/editorial.html") passait
     donc à travers. Sélecteur passé en a[href$="..."] sans restriction
     de container. Voir bloc en fin de fichier.

   v2.4 (2026-07-12) — Masquage mobile des liens desktop-only (v2.4
     insuffisante, remplacée par v2.5 — même intention, sélecteur trop
     restrictif dans la v2.4).

   v2.3 (2026-06-27) — Pattern app shell identique à index.html
     · html/body : height 100% + overflow hidden (pas de scroll de page)
     · .admin-main : overflow-y auto + height 100% (scroll délégué)
     · Sur mobile : .admin-layout en flex column, sidebar sticky en haut,
       main prend le reste avec scroll interne (flex:1 1 auto + min-height:0).
     · Conséquence : PAS de pull-to-refresh (cohérent index.html), PAS de
       blocage de scroll par overscroll-behavior.

   v2.2 (2026-06-27) — Retour à scroll natif (mais pull-to-refresh actif)
   v2.1 (2026-06-27) — overscroll-behavior contain (bloquait scroll, KO)
   v2.0 (2026-06-27) — Refonte propre du CSS

   CSS partagé entre les 4 pages d'administration :
     · prefs.html      (préférences utilisateur)
     · usage.html      (consommation et quotas)
     · editorial.html  (studio éditorial)
     · admin.html      (console admin client)

   CHANGELOG
   ─────────
   v2.0 (2026-06-27) — REPRISE PROPRE après échec des v1.1-v1.9
     · Base : v1.0 (desktop OK)
     · UN SEUL bloc mobile bien pensé, calqué sur le pattern d'index.html
       qui fonctionne. Pas de patches accumulés contradictoires.

   DÉPENDANCES :
     1. design-tokens.css
     2. theme-arkensai.css

   ═══════════════════════════════════════════════════════════════════════════ */


/* ═══════════════════════════════════════════════════════════════════════════
   1. RESET LOCAL
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--f-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--c-fg);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Pattern "app shell" identique à index.html : le body ne scrolle pas.
     Le scroll est délégué à .admin-main (cf. section RESPONSIVE).
     → Pas de pull-to-refresh natif Chrome Android
     → Pas de blocages de scroll par overscroll-behavior */
  height: 100%;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: none; padding: 0; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }


/* ═══════════════════════════════════════════════════════════════════════════
   2. ICÔNES (sprite SVG)
   ═══════════════════════════════════════════════════════════════════════════ */

.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 22px; height: 22px; }
.icon--xl { width: 28px; height: 28px; }


/* ═══════════════════════════════════════════════════════════════════════════
   3. LAYOUT DESKTOP (≥ 901px)
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100%;
  overflow: hidden;
}

.admin-main {
  padding: var(--sp-8) var(--sp-8) var(--sp-10);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  /* Le scroll de la page se fait dans CE container (pattern app shell). */
  overflow-y: auto;
  height: 100%;
}


/* ═══════════════════════════════════════════════════════════════════════════
   4. SIDEBAR DESKTOP
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-sidebar {
  background: var(--c-bg-elevated);
  border-right: 1px solid var(--c-line);
  padding: var(--sp-6) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.admin-sidebar__brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--c-line);
}
.admin-sidebar__brand-name {
  font-family: var(--f-display);
  font-size: 22px;
  font-weight: 500;
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--c-fg);
}
.admin-sidebar__brand-sub {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--c-fg-subtle);
  margin-top: 4px;
}

.admin-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: var(--c-fg-muted);
  transition: background var(--d-fast), color var(--d-fast);
}
.admin-nav-item:hover {
  background: var(--c-bg-hover);
  color: var(--c-fg);
}
.admin-nav-item.is-active {
  background: var(--c-bg-muted);
  color: var(--c-accent);
}
.admin-nav-item .icon {
  width: 16px;
  height: 16px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   5. PAGE HEADER
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-page-header {
  margin-bottom: var(--sp-8);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.admin-page-title {
  font-family: var(--f-display);
  font-weight: 400;
  font-style: italic;
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  letter-spacing: -0.025em;
  color: var(--c-fg);
  margin: 0;
}

.admin-page-sub {
  margin-top: var(--sp-2);
  font-size: var(--fs-md);
  color: var(--c-fg-muted);
  max-width: 640px;
  line-height: var(--lh-normal);
}

.admin-page-header__actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}


/* ═══════════════════════════════════════════════════════════════════════════
   6. SECTIONS & CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-section {
  margin-bottom: var(--sp-10);
}
.admin-section__title {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-fg-subtle);
  margin: 0 0 var(--sp-3);
}

.admin-card {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-5);
  margin-bottom: var(--sp-4);
}
.admin-card__title {
  font-family: var(--f-sans);
  font-size: var(--fs-lg);
  font-weight: 500;
  color: var(--c-fg);
  margin: 0 0 var(--sp-1);
}
.admin-card__sub {
  font-size: var(--fs-sm);
  color: var(--c-fg-muted);
  margin: 0 0 var(--sp-4);
  line-height: var(--lh-normal);
}
.admin-card__body { margin-top: var(--sp-3); }


/* ═══════════════════════════════════════════════════════════════════════════
   7. BOUTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  height: 36px;
  transition: all var(--d-fast);
  white-space: nowrap;
}
.admin-btn--primary  { background: var(--c-accent); color: #fff; }
.admin-btn--primary:hover { background: var(--c-accent-hover); }
.admin-btn--ghost    { background: transparent; color: var(--c-fg); border: 1px solid var(--c-line); }
.admin-btn--ghost:hover  { background: var(--c-bg-hover); border-color: var(--c-line-strong); }
.admin-btn--danger   { background: transparent; color: var(--c-accent); border: 1px solid var(--c-line); }
.admin-btn--danger:hover { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.admin-btn--icon     { width: 36px; height: 36px; padding: 0; justify-content: center; color: var(--c-fg-muted); border-radius: var(--radius); }
.admin-btn--icon:hover   { background: var(--c-bg-hover); color: var(--c-fg); }
.admin-btn:disabled  { opacity: 0.5; cursor: not-allowed; }


/* ═══════════════════════════════════════════════════════════════════════════
   8. FORMULAIRES
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-3);
}
.admin-field__label { font-size: 12.5px; font-weight: 500; color: var(--c-fg); }
.admin-field__hint  { font-size: 11.5px; color: var(--c-fg-subtle); margin-top: 2px; }

.admin-input, .admin-select, .admin-textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--c-fg);
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  transition: border-color var(--d-fast), box-shadow var(--d-fast);
  font-family: inherit;
}
.admin-input:focus, .admin-select:focus, .admin-textarea:focus {
  outline: 0;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
.admin-textarea { resize: vertical; min-height: 80px; line-height: var(--lh-normal); }
.admin-select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   9. TOGGLE
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-toggle { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.admin-toggle input { opacity: 0; width: 0; height: 0; }
.admin-toggle__slider {
  position: absolute; inset: 0;
  background: var(--c-line); border-radius: 12px;
  transition: background var(--d-fast); cursor: pointer;
}
.admin-toggle__slider::before {
  content: ""; position: absolute;
  height: 16px; width: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform var(--d-fast);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.admin-toggle input:checked + .admin-toggle__slider { background: var(--c-accent); }
.admin-toggle input:checked + .admin-toggle__slider::before { transform: translateX(16px); }


/* ═══════════════════════════════════════════════════════════════════════════
   10. TABLE
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table thead { background: var(--c-bg); }
.admin-table th {
  text-align: left; font-weight: 500;
  font-family: var(--f-mono); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--c-fg-subtle);
  padding: var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--c-line);
}
.admin-table td { padding: var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--c-line); color: var(--c-fg); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: var(--c-bg-hover); }


/* ═══════════════════════════════════════════════════════════════════════════
   11. BADGES
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 500;
  font-family: var(--f-mono); letter-spacing: 0.04em;
  background: var(--c-bg); color: var(--c-fg-muted);
  border: 1px solid var(--c-line);
}
.admin-badge--ok    { color: var(--c-eco);    border-color: var(--c-eco);    background: rgba(46, 125, 50, 0.06); }
.admin-badge--warn  { color: #B86E00;         border-color: #B86E00;         background: rgba(184, 110, 0, 0.06); }
.admin-badge--err   { color: var(--c-accent); border-color: var(--c-accent); background: rgba(161, 29, 42, 0.06); }
.admin-badge--info  { color: var(--c-fg);     border-color: var(--c-line-strong); }
.admin-badge .icon  { width: 11px; height: 11px; }


/* ═══════════════════════════════════════════════════════════════════════════
   12. MODALES
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 8, 9, 0.45);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4);
  animation: admin-modal-fade-in var(--d-fast) ease;
}
@keyframes admin-modal-fade-in { from { opacity: 0; } to { opacity: 1; } }

.admin-modal {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 540px; max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  animation: admin-modal-slide-in var(--d-base) ease;
}
@keyframes admin-modal-slide-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.admin-modal__header { padding: var(--sp-5) var(--sp-5) var(--sp-3); border-bottom: 1px solid var(--c-line); display: flex; align-items: center; justify-content: space-between; }
.admin-modal__title  { font-family: var(--f-display); font-size: 18px; font-style: italic; font-weight: 500; color: var(--c-fg); margin: 0; }
.admin-modal__body   { padding: var(--sp-4) var(--sp-5); }
.admin-modal__actions { padding: var(--sp-3) var(--sp-5) var(--sp-5); display: flex; justify-content: flex-end; gap: var(--sp-2); border-top: 1px solid var(--c-line); }


/* ═══════════════════════════════════════════════════════════════════════════
   13. UTILITAIRES
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.admin-row   { display: flex; align-items: center; gap: var(--sp-3); }
.admin-row--between { justify-content: space-between; }
.admin-row--end     { justify-content: flex-end; }
.admin-grow  { flex: 1; }
.admin-divider { height: 1px; background: var(--c-line); border: 0; margin: var(--sp-5) 0; }
.admin-mono   { font-family: var(--f-mono); font-size: 12.5px; color: var(--c-fg-muted); }
.admin-muted  { color: var(--c-fg-muted); }
.admin-subtle { color: var(--c-fg-subtle); }
.admin-status      { font-size: 12.5px; color: var(--c-fg-muted); font-style: italic; }
.admin-status--ok  { color: var(--c-eco); }
.admin-status--err { color: var(--c-accent); }


/* ═══════════════════════════════════════════════════════════════════════════
   14. FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-footer {
  margin-top: var(--sp-10);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--c-line);
  text-align: center;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--c-fg-subtle);
}
.admin-footer em { font-style: italic; font-family: var(--f-display); color: var(--c-fg-muted); }


/* ═══════════════════════════════════════════════════════════════════════════
   ════════════════════════════════════════════════════════════════════════
   15. RESPONSIVE — UN SEUL BLOC PROPRE
   ════════════════════════════════════════════════════════════════════════

   Stratégie : COMME index.html qui marche.
   - <= 900px : sidebar passe en haut horizontale, layout 1 colonne
   - <= 600px : titre réduit, sous-titre réduit, plus de padding
   - <= 420px : brand "Arkensai" masqué pour libérer l'espace

   PRINCIPE-CLÉ : chaque enfant de .admin-main a max-width: 100% et
   box-sizing: border-box pour empêcher tout débordement (filet de
   sécurité strict).
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .admin-layout {
    display: flex;
    flex-direction: column;
    /* height: 100% hérité de la règle desktop */
  }
  .admin-sidebar {
    flex: 0 0 auto;          /* sidebar = hauteur naturelle, pas de shrink */
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    border-right: 0;
    border-bottom: 1px solid var(--c-line);
    flex-direction: row;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
  }
  .admin-sidebar__brand {
    flex: 0 1 auto;
    min-width: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
  }
  .admin-sidebar__brand-name {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .admin-sidebar__brand-sub { display: none; }

  .admin-sidebar__nav {
    flex: 0 0 auto;
    flex-direction: row;
    margin-left: auto;
    gap: 2px;
  }
  .admin-nav-item { padding: 8px; white-space: nowrap; }
  .admin-nav-item .icon { width: 18px; height: 18px; }
  .admin-nav-item__label { display: none; }

  .admin-main {
    padding: 20px 16px 32px;
    max-width: 100%;
    width: 100%;
    flex: 1 1 auto;          /* prend le reste de la hauteur après sidebar */
    overflow-y: auto;        /* le scroll s'y fait (pattern app shell) */
    min-height: 0;           /* crucial pour que flex permette l'overflow */
    -webkit-overflow-scrolling: touch;  /* scroll fluide iOS */
  }

  /* FILET DE SÉCURITÉ : aucun enfant direct de main ne déborde */
  .admin-main > *,
  .admin-card,
  .admin-section {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* ≤ 600px : ajustements typo */
@media (max-width: 600px) {
  .admin-page-title { font-size: 26px; line-height: 1.15; }
  .admin-page-sub   { font-size: 13px; line-height: 1.5; }
  .admin-page-header { margin-bottom: 20px; }
  .admin-card { padding: 16px; }
  .admin-card__title { font-size: 15px; }
  .admin-card__sub   { font-size: 12.5px; }
  .admin-section__title { font-size: 9.5px; margin-bottom: 8px; }
  .admin-section { margin-bottom: 24px; }
}

/* ≤ 420px (Galaxy S22 ~360px) : on masque le brand pour libérer la nav */
@media (max-width: 420px) {
  .admin-sidebar__brand { display: none; }
  .admin-sidebar { justify-content: flex-end; padding: 8px 12px; }
  .admin-sidebar__nav { margin-left: 0; }
  .admin-page-title { font-size: 22px; }
  .admin-main { padding-left: 14px; padding-right: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   v2.5 (2026-07-12) — Sélecteur élargi (correction du sélecteur v2.4)
   ─────────────────────────────────────────────────────────────────────────
   La v2.4 n'attrapait que les liens dans .admin-sidebar__nav avec href
   exact "editorial.html" — ce qui laissait passer :
     · le lien du dropdown-item d'index.html : href="/editorial.html"
       (slash initial + container différent)
     · tout lien situé hors d'une .admin-sidebar__nav
   On passe donc au sélecteur d'attribut $= ("se termine par"), sans
   restriction au container. Résultat : tous les liens vers ces 3 pages
   sont neutralisés sur mobile, quels que soient leur container et leur
   chemin (relatif ou absolu).
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  a[href$="admin.html"],
  a[href$="editorial.html"],
  a[href$="admin_mcp.html"] {
    display: none !important;
  }
}
