/* ============================================================
   theme.css — SYSTÈME DE DESIGN (jetons) — source UNIQUE des couleurs
   ------------------------------------------------------------
   - :root = thème CLAIR ; html[data-theme="dark"] = thème SOMBRE
     (mêmes noms, autres valeurs : tout ce qui utilise var(--jeton)
     suit le thème automatiquement).
   - Chargé par layout_haut() (layout.php), avant console.css.
   - SÉPARÉ DE L'ERP le 12/11/2026 (refonte de la console, lot 1) :
     palette du logo 2N-DEV (violet #7E2FB8, encre #2A3245, blanc).
     Ce fichier n'est plus une copie du theme.css de l'ERP :
     NE PAS recopier l'ancien fichier de l'ERP par-dessus.
   - Règle : on ne retire jamais un nom de jeton (des pages des autres
     agents les utilisent) ; on change la valeur, on en ajoute.
   - Contrastes calculés (WCAG 2) le 12/11/2026, seuil 4,5 pour 1 :
     clair  : texte 14,8 ; secondaire 6,1 (5,3 sur --surface-3) ;
              discret 5,3 (4,6 sur --surface-3) ; lien 6,1 ;
              blanc sur --primary 7,0 ; blanc sur --danger 4,8.
     sombre : texte 16,3 ; secondaire 7,8 (6,1 sur --surface-3) ;
              discret 6,4 (5,0 sur --surface-3) ; lien 9,0 ;
              blanc sur --primary 4,7 ; --primary sur --surface 3,7
              (éléments graphiques, seuil 3).
   ============================================================ */

:root {
    /* --- Surfaces --- */
    --bg: #f5f4fa;            /* fond de page */
    --surface: #ffffff;       /* cartes / panneaux */
    --surface-2: #f0eef7;     /* zones secondaires (en-têtes de tableau, sous-cartes) */
    --surface-3: #e6e3ef;     /* fonds de puces neutres, jauges */

    /* --- Texte --- */
    --text: #1b2030;
    --text-muted: #555c72;    /* texte secondaire : 5,25 sur --surface-3 */
    --text-faint: #5f6579;    /* texte discret (pied de page, notes) : 4,58 au pire */
    --title: #2a3245;         /* encre du logo : titres */

    /* --- Bordures --- */
    --border: #e0ddeb;
    --border-soft: #eeecf4;

    /* --- Marque / accents --- */
    --primary: #7e2fb8;       /* violet 2N : boutons principaux, zone active */
    --primary-2: #6b24a0;     /* survol */
    --on-primary: #ffffff;    /* texte sur fond primaire */
    --accent: #6b24a0;        /* violet de TEXTE (valeurs, noms cliquables) */
    --link: #1d4ed8;

    /* --- Verre (barres flottantes) --- */
    --glass: rgba(255, 255, 255, .86);
    --glass-bord: rgba(42, 50, 69, .10);
    --flou: 14px;

    /* --- Châssis : anciens noms gardés (plus utilisés par la barre depuis le lot 1) --- */
    --topbar-bg: #ffffff;
    --topbar-text: #2a3245;
    --topbar-hover: #f0eef7;
    --sidebar-bg: #2a3245;
    --sidebar-text: #e6e3ef;
    --sidebar-active: #3a4360;

    /* --- Six familles d'état (fond doux / encre ; plein = points, bordures, jauges) --- */
    --success: #15803d; --success-soft: #dcfce7; --success-ink: #166534;
    --danger:  #dc2626; --danger-soft:  #fee2e2; --danger-ink:  #991b1b;
    --warning: #f59e0b; --warning-soft: #fef3c7; --warning-ink: #92400e;
    --info:    #2563eb; --info-soft:    #dbeafe; --info-ink:    #1e40af;
    --ia:      #7e2fb8; --ia-soft:      #f3e8fc; --ia-ink:      #5b1f8a;
    --off:     #64748b; --off-soft:     #eef0f5; --off-ink:     #475569;
    --purple:  #7e2fb8;       /* = famille IA (texte sur --surface-3 : 5,6) */
    /* Cyan : « RDV pris » du CRM, distinct du violet de l'IA et du bleu « Contacté » */
    --cyan:    #0e7490; --cyan-soft:    #e0f7fa; --cyan-ink:    #155e75;

    /* --- Rayons / ombres / focus --- */
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 2px 10px rgba(27, 32, 48, .06);
    --shadow-lg: 0 12px 34px rgba(27, 32, 48, .14);
    --ring: 0 0 0 3px rgba(126, 47, 184, .30);

    /* --- Largeur max du contenu --- */
    --maxw: 1280px;

    /* --- ALIAS de compatibilité (anciens noms déjà utilisés dans les pages) --- */
    --navy: var(--accent);        --navy-dark: var(--primary-2);
    --ink: var(--text);           --muted: var(--text-muted);    --muted-2: var(--text-faint);
    --green: var(--success);      --green-soft: var(--success-soft);  --green-ink: var(--success-ink);
    --red: var(--danger);         --red-soft: var(--danger-soft);     --red-ink: var(--danger-ink);
    --amber: var(--warning);      --amber-soft: var(--warning-soft);  --amber-ink: var(--warning-ink);
    --blue: var(--info);          --blue-soft: var(--info-soft);      --blue-ink: var(--info-ink);
}

/* ============================================================
   THÈME SOMBRE — mêmes jetons, autres valeurs
   ============================================================ */
html[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d1020;
    --surface: #161a2e;
    --surface-2: #1d2238;
    --surface-3: #272d47;

    --text: #eceef6;
    --text-muted: #a7aec6;
    --text-faint: #959db8;
    --title: #f2f3fa;

    --border: #2a3050;
    --border-soft: #222842;

    --primary: #9b4fd6;       /* violet éclairci : blanc 4,7 ; sur --surface 3,7 */
    --primary-2: #8e44c9;
    --on-primary: #ffffff;
    --accent: #c9a2f2;        /* violet de texte sur fond sombre : 8,1 */
    --link: #8fbeff;

    --glass: rgba(22, 26, 46, .80);
    --glass-bord: rgba(236, 238, 246, .10);

    --topbar-bg: #161a2e;
    --topbar-text: #eceef6;
    --topbar-hover: #1d2238;
    --sidebar-bg: #0d1020;
    --sidebar-text: #c9cee0;
    --sidebar-active: #272d47;

    --success-soft: #0f2e22; --success-ink: #5be49b;
    --danger-soft:  #3a1518; --danger-ink:  #ff9a9a;
    --warning-soft: #33270b; --warning-ink: #fbbf24;
    --info-soft:    #12233f; --info-ink:    #8fbeff;
    --ia: #9b4fd6; --ia-soft: #2a1b45; --ia-ink: #d9bdf7;
    --off: #8a93ad; --off-soft: #20263c; --off-ink: #b4bbd0;
    --purple: #c9a2f2;
    --cyan: #22b8cf; --cyan-soft: #123540; --cyan-ink: #7dd3e8;

    --shadow: 0 2px 12px rgba(0, 0, 0, .40);
    --shadow-lg: 0 16px 44px rgba(0, 0, 0, .55);
    --ring: 0 0 0 3px rgba(201, 162, 242, .40);
}

/* Fond de page global (utilise le jeton) */
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }

/* ============================================================
   Base responsive sûre (n'altère pas les largeurs existantes)
   ============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, video, canvas { max-width: 100%; }

/* ------------------------------------------------------------
   POINTS DE RUPTURE DE LA CONSOLE (lot 1, 12/11/2026)
   - 360 px  : très petit téléphone
   - 600 px  : téléphone (champs à 16 px)
   - 900 px  : jusque-là, menu des zones dans la barre du bas
   - 1280 px : grand écran (--maxw)
   ------------------------------------------------------------ */

@media (max-width: 600px) {
    /* MINE connue : coupe tout débordement sans barre de défilement
       (une sonde de débordement doit la neutraliser). Gardée telle quelle. */
    html, body { overflow-x: hidden; max-width: 100%; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select, textarea { font-size: 16px; }
    .table-container, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { max-width: 100%; }
    button, .btn, .btn-action, .cfg-btn { min-height: 40px; }
}

@media (max-width: 360px) {
    :root { --radius: 10px; --radius-lg: 14px; }
    .cfg-grid-2 { grid-template-columns: 1fr !important; }   /* code mort de l'ERP, gardé */
}

/* ============================================================
   CODE MORT HÉRITÉ DE L'ERP (12/11/2026) : aucune classe ci-dessous
   n'est utilisée par la console (.cfg-*, .modal-window, .mw-*,
   modal_tools.js absent). Gardé, pas retiré (aucune suppression
   sans Quentin). Ruptures 601-820 et 768 : propres à ce code mort.
   ============================================================ */
@media (min-width: 601px) and (max-width: 820px) {
    .cfg-grid-2 { grid-template-columns: repeat(2, 1fr); }
}

.modal-window { resize: both; }
.floating-modal, .modal-window, .ui-modal { min-width: 240px; min-height: 120px; }

.mw-tools { display: inline-flex; gap: 6px; align-items: center; }
.mw-tools .mw-b {
    background: rgba(125,125,125,.22); color: inherit; border: none;
    width: 24px; height: 24px; border-radius: 6px; padding: 0;
    font-size: 13px; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.mw-tools .mw-b:hover { background: rgba(125,125,125,.42); }
.mw-tools-floating { position: absolute; top: 6px; right: 8px; z-index: 5; }

.floating-modal.mw-max, .modal-window.mw-max, .ui-modal.mw-max {
    left: 2vw !important; top: 2vh !important;
    width: 96vw !important; height: 96vh !important;
    transform: none !important; margin: 0 !important;
}

.mw-dock { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column-reverse; gap: 8px; z-index: 100060; }
.mw-chip {
    background: var(--primary); color: #fff; border: none; border-radius: 10px;
    padding: 8px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer;
    box-shadow: var(--shadow-lg); max-width: 230px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mw-chip:hover { filter: brightness(1.08); }

@media (max-width: 768px) {
    .floating-modal, .modal-window, .ui-modal { resize: none; }
    .floating-modal.mw-max, .modal-window.mw-max, .ui-modal.mw-max {
        left: 2.5% !important; top: 3% !important; width: 95% !important; height: 92vh !important;
    }
}
