/* ==========================================================================
   Mode sombre : composants colorés (pastilles, alertes, tableau d'emploi du temps) et bouton de bascule.
   Les couleurs de base (fonds, textes, bordures) viennent des jetons de variables.css.
   Écran uniquement : l'impression reste claire.
   ========================================================================== */

/* ---------- Bouton de bascule clair / sombre (toutes les pages) ---------- */
.theme-toggle{
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.14); color: #fff;
  cursor: pointer; font-size: .95rem; line-height: 1;
  transition: background var(--transition-base), transform var(--transition-base);
}
.theme-toggle:hover{ background: rgba(255,255,255,.28); }
.theme-toggle:focus-visible{ outline: 3px solid var(--color-yellow); outline-offset: 2px; }
/* sur fond clair (admin, pages de connexion) */
.theme-toggle.on-light{ border-color: var(--color-border); background: var(--color-surface); color: var(--color-ink); }
.theme-toggle.on-light:hover{ background: var(--color-violet-light); }
.theme-floating{ position: fixed; top: .8rem; right: .8rem; z-index: 2000; }
.site-tabs .container .theme-toggle{ width: 30px; height: 30px; font-size: .8rem; margin-left: .2rem; flex: 0 0 auto; }

@media screen{
  [data-theme="dark"] body{ background: var(--color-bg); color: var(--color-ink); }
  [data-theme="dark"] img:not(.brand-logo):not([src*="logo"]){ filter: brightness(.92) contrast(1.02); }
  [data-theme="dark"] ::placeholder{ color: #8c819c; }
  [data-theme="dark"] .form-control, [data-theme="dark"] .form-select{ background-color: var(--color-surface-2); border-color: var(--color-border); color: var(--color-ink); }
  [data-theme="dark"] .form-control:focus, [data-theme="dark"] .form-select:focus{ background-color: var(--color-surface-2); color: var(--color-ink); }
  [data-theme="dark"] hr{ border-color: var(--color-border); opacity: 1; }
  [data-theme="dark"] code{ color: #f5a8d0; }

  /* alertes et pastilles : fonds teintés sombres, textes clairs */
  [data-theme="dark"] .pay-alert.is-late, [data-theme="dark"] .parent-alert.error, [data-theme="dark"] .admin-alert.is-error,
  [data-theme="dark"] .pill.retard, [data-theme="dark"] .pill.late, [data-theme="dark"] .grade-pill.low, [data-theme="dark"] .att-badge.absent,
  [data-theme="dark"] .badge-status.status-refuse, [data-theme="dark"] .notes-grid .is-bad{ background: rgba(224,82,70,.2); color: #ff9d94; border-color: rgba(224,82,70,.45); }
  [data-theme="dark"] .pay-alert.is-soon, [data-theme="dark"] .pill.partiel, [data-theme="dark"] .pill.a_venir, [data-theme="dark"] .att-badge.retard,
  [data-theme="dark"] .badge-status.status-en_cours{ background: rgba(255,201,60,.17); color: #f6d27a; border-color: rgba(255,201,60,.4); }
  [data-theme="dark"] .pay-alert.is-ok, [data-theme="dark"] .parent-alert.ok, [data-theme="dark"] .admin-alert.is-success, [data-theme="dark"] .pill.paye,
  [data-theme="dark"] .pill.ok, [data-theme="dark"] .grade-pill.good, [data-theme="dark"] .att-badge.present,
  [data-theme="dark"] .badge-status.status-admis, [data-theme="dark"] .badge-status.status-read{ background: rgba(47,179,128,.2); color: #86e2bc; border-color: rgba(47,179,128,.4); }
  [data-theme="dark"] .att-badge.excuse{ background: rgba(150,100,220,.25); color: #d7bdf7; }
  [data-theme="dark"] .att-stat{ background: var(--color-surface-2); }
  [data-theme="dark"] .att-stat.absent strong{ color: #ff9d94; }
  [data-theme="dark"] .att-stat.retard strong{ color: #f6d27a; }
  [data-theme="dark"] .att-stat.excuse strong{ color: #d7bdf7; }
  [data-theme="dark"] .appel-radio:checked + .appel-present{ background: rgba(47,179,128,.2); border-color: #46c796; color: #86e2bc; }
  [data-theme="dark"] .appel-radio:checked + .appel-absent{ background: rgba(224,82,70,.2); border-color: #ef6b5f; color: #ff9d94; }
  [data-theme="dark"] .appel-radio:checked + .appel-retard{ background: rgba(255,201,60,.17); border-color: #e3b13a; color: #f6d27a; }
  [data-theme="dark"] .appel-radio:checked + .appel-excuse{ background: rgba(150,100,220,.25); border-color: #a785dd; color: #d7bdf7; }
  [data-theme="dark"] .cnt-present b{ color: #86e2bc; } [data-theme="dark"] .cnt-absent b{ color: #ff9d94; }
  [data-theme="dark"] .cnt-retard b{ color: #f6d27a; } [data-theme="dark"] .cnt-excuse b{ color: #d7bdf7; }
  [data-theme="dark"] .moy-table td.low, [data-theme="dark"] .btn-link-danger{ color: #ff9d94; }

  /* tableau d'emploi du temps */
  [data-theme="dark"] .tt-grid thead th{ background: #3a1f55; }
  [data-theme="dark"] .tt-grid .tt-fr{ background: #1d2b4a; box-shadow: inset 4px 0 0 #5a8bf0; }
  [data-theme="dark"] .tt-grid .tt-maths{ background: #3a2f10; box-shadow: inset 4px 0 0 #e0a800; }
  [data-theme="dark"] .tt-grid .tt-sci{ background: #123427; box-shadow: inset 4px 0 0 #36b97c; }
  [data-theme="dark"] .tt-grid .tt-rec{ background: #2a2733; color: #c9c2d6; box-shadow: inset 4px 0 0 #7d7690; }
  [data-theme="dark"] .tt-grid .tt-other{ background: #3a1b2e; box-shadow: inset 4px 0 0 #d4569a; }
  [data-theme="dark"] .tt-grid td small{ color: #b9afc9; }
  [data-theme="dark"] .tt-grid td.tt-empty{ background: repeating-linear-gradient(135deg, var(--color-surface), var(--color-surface) 6px, var(--color-surface-2) 6px, var(--color-surface-2) 12px); }
  [data-theme="dark"] .tt-legend{ color: var(--color-ink-soft); }

  /* admin : tableaux et cartes */
  [data-theme="dark"] .admin-table th{ color: var(--color-ink-soft); }
  [data-theme="dark"] .admin-panel, [data-theme="dark"] .admin-topbar{ border-color: var(--color-border); }

  /* site public */
  [data-theme="dark"] .site-footer{ background: #0f0b16; }
  [data-theme="dark"] .main-nav .nav-link{ color: var(--color-ink-soft); }
  [data-theme="dark"] .main-nav .nav-link:hover, [data-theme="dark"] .main-nav .nav-link.active{ color: var(--color-violet-text); }
  [data-theme="dark"] .navbar-toggler{ border-color: var(--color-border); }
  [data-theme="dark"] .navbar-toggler-icon{ filter: invert(1); }
  [data-theme="dark"] .fee-table tbody tr:nth-child(even){ background: var(--color-surface-2); }
  [data-theme="dark"] .fee-table td.fee-total{ background: rgba(255,201,60,.14); color: #f6d27a; }
  [data-theme="dark"] .fee-table tbody th{ background: var(--color-surface-2); }
  /* logo en couleurs foncées : pastille claire pour rester lisible */
  [data-theme="dark"] .navbar-brand-custom .brand-logo{ background: #f4eff9; border-radius: 50%; padding: 4px; box-sizing: content-box; }
  [data-theme="dark"] .btn-violet{ background: #6a3a8c; }
  [data-theme="dark"] .btn-violet:hover{ background: #7d49a2; }
  [data-theme="dark"] .admin-sidebar{ background: #0f0b16; border-right: 1px solid var(--color-border); }
  [data-theme="dark"] .balance-box .due strong{ color: #ff9d94; }
  /* couleurs écrites directement dans certaines pages (style en ligne) */
  [data-theme="dark"] [style*="#b3261e"]{ color: #ff9d94 !important; }
  [data-theme="dark"] [style*="#7a5a00"]{ color: #f6d27a !important; }
  [data-theme="dark"] [style*="#14633f"]{ color: #86e2bc !important; }
  [data-theme="dark"] [style*="background:#fff"]{ background: var(--color-surface) !important; }
  [data-theme="dark"] [style*="background:#f3eef7"]{ background: var(--color-surface-2) !important; }
  [data-theme="dark"] [style*="background:#fdecea"]{ background: rgba(224,82,70,.2) !important; }
  [data-theme="dark"] [style*="#e3e8ef"]{ border-color: var(--color-border) !important; }
  [data-theme="dark"] [style*="#6b7a8a"]{ color: var(--color-ink-soft) !important; }
}
