/* ════════════════════════════════════════════════════════════════════
   ÉCOLE — Système de design
   Encre profonde + or éditorial. Calme et structuré par défaut ;
   l'accent n'intervient que pour ce qui compte vraiment : actions
   principales, états actifs, chiffres clés.
   ════════════════════════════════════════════════════════════════════ */

:root {
    /* Encre — structure, autorité, texte */
    --encre: #141d33;
    --encre-douce: #2a3655;
    --encre-eclat: #3d4b73;

    /* Or — l'unique signal chaud, utilisé avec parcimonie */
    --or: #b8872f;
    --or-fonce: #96701f;
    --or-clair: #e8c777;
    --or-fond: #fbf3e2;

    /* Sauge — succès, croissance (évite le vert générique) */
    --sauge: #2f6b57;
    --sauge-fond: #e7f3ee;

    /* Neutres — fond légèrement tiède, jamais crème ni blanc pur */
    --fond: #f5f5f3;
    --carte: #ffffff;
    --bordure: #e4e1da;
    --bordure-vive: #d4cfc2;
    --texte: #1c2230;
    --texte-doux: #6b6f7d;
    --texte-tenu: #9a9da8;

    /* Alertes */
    --rouge: #b2433a;
    --rouge-fond: #fbeceb;
    --ambre: #a36a1f;
    --ambre-fond: #fbf0dd;
    --bleu: #35507e;
    --bleu-fond: #ecf1fa;

    /* Compat : l'ancien nom --primaire reste pointé vers l'or, pour les
       pages qui le référencent encore directement via style inline. */
    --primaire: var(--or);
    --primaire-fonce: var(--or-fonce);
    --sidebar-bg: var(--encre);
    --sidebar-texte: #aab2c8;
    --sidebar-actif: var(--encre-douce);
    --surface-alt: #f7f6f3;
    --vert: var(--sauge);

    --rayon: 12px;
    --rayon-sm: 8px;
    --ombre: 0 1px 2px rgba(20,29,51,.04), 0 6px 20px rgba(20,29,51,.06);
    --ombre-hover: 0 2px 4px rgba(20,29,51,.06), 0 14px 32px rgba(20,29,51,.1);

    --police-titre: 'Lexend', 'Segoe UI', system-ui, sans-serif;
    --police-texte: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; font-family: var(--police-texte); background: var(--fond); color: var(--texte);
    font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--police-titre); letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
i[data-lucide] { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--or); outline-offset: 2px; }

/* ── LAYOUT ── */
.layout { display: flex; min-height: 100vh; }
.content { flex: 1; padding: 30px 36px; max-width: 100%; min-width: 0; }

/* Filet de sécurité global : de nombreuses pages placent ces blocs dans une grille ou
   une ligne flexible en `1fr`, qui par défaut ne peut pas rétrécir sous la largeur
   naturelle de son contenu (un graphique, un long nombre...) — d'où des débordements
   horizontaux. min-width:0 lève cette contrainte, sans rien changer visuellement
   tant que le contenu tient déjà dans l'espace disponible. */
.panneau, .sous-panneau, .carte-kpi, .grille-kpi > * { min-width: 0; }

/* ── SIDEBAR ── */
.sidebar {
    width: 258px; background: linear-gradient(185deg, var(--encre) 0%, #0f1526 100%);
    color: var(--sidebar-texte); display: flex; flex-direction: column; flex-shrink: 0; min-height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; font-family: var(--police-titre); font-weight: 700; font-size: 15px; color: #fff; }
.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 9px; padding: 7px 11px; border-radius: 8px;
    font-size: 12.8px; font-weight: 500; margin-bottom: 1px; line-height: 1.3; color: var(--sidebar-texte);
    transition: background .12s ease, color .12s ease;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.actif { background: var(--or); color: var(--encre); font-weight: 700; }
.sidebar-nav a.actif i[data-lucide] { color: var(--encre); }
.sidebar-nav a i[data-lucide] { width: 15px; height: 15px; flex-shrink: 0; }

.sidebar-section-label { font-family: var(--police-titre); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: #6b7390; padding: 14px 13px 5px; }
.sidebar-section-label:first-child { padding-top: 6px; }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user .avatar-init { width: 34px; height: 34px; border-radius: 50%; background: var(--or); color: var(--encre); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex-shrink: 0; overflow: hidden; }
.sidebar-user .avatar-init img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .infos { flex: 1; min-width: 0; }
.sidebar-user .infos a { display: block; }
.sidebar-user .nom { font-size: 12.5px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role { font-size: 11px; opacity: .65; }
.sidebar-user > a { color: var(--sidebar-texte); flex-shrink: 0; }
.sidebar-user > a:hover { color: #fff; }

.sidebar input[type="search"] {
    border-radius: 8px; border: 1px solid rgba(255,255,255,.14) !important;
    background: rgba(255,255,255,.07) !important; color: #fff !important;
}
.sidebar input[type="search"]::placeholder { color: #8891ab; }
.sidebar input[type="search"]:focus { outline: none; border-color: var(--or) !important; background: rgba(255,255,255,.11) !important; }

/* ── PAGE HEADER ── */
.page-header {
    margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px;
    background: linear-gradient(120deg, var(--encre) 0%, #27345a 100%);
    border-radius: 16px; padding: 26px 28px; color: #fff; position: relative; overflow: hidden;
}
.page-header::after {
    content: ''; position: absolute; top: -40%; right: -8%; width: 280px; height: 280px; border-radius: 50%;
    background: radial-gradient(circle, rgba(184,135,47,.18) 0%, transparent 72%); pointer-events: none;
}
.page-header h1 { font-size: 1.55em; margin: 0 0 6px; color: #fff; font-weight: 700; display: flex; align-items: center; gap: 9px; position: relative; }
.page-header .sous-titre { color: rgba(255,255,255,.72); font-size: 13px; margin: 0; position: relative; }
.page-header .sous-titre a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.page-header .btn-secondaire { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.22); }
.page-header .btn-secondaire:hover { background: rgba(255,255,255,.2); }
.page-header .badge { font-size: 12px; }
.page-header > form { position: relative; }

/* ── PANNEAUX / CARTES ── */
.panneau { background: var(--carte); border-radius: var(--rayon); border: 1px solid var(--bordure); margin-bottom: 18px; box-shadow: var(--ombre); }
.panneau-entete {
    display: flex; align-items: center; gap: 8px; padding: 15px 20px; border-bottom: 1px solid var(--bordure);
    font-family: var(--police-titre); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--encre-douce);
}
.barre-outils-liste {
    display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center;
    background: #fff; border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 13px 16px;
}
.barre-outils-liste input[type="search"] { flex: 1; min-width: 180px; padding: 9px 14px; border-radius: var(--rayon-sm); border: 1px solid var(--bordure); font-size: 13px; background: var(--surface-alt); }
.barre-outils-liste select { padding: 9px 12px; border-radius: var(--rayon-sm); border: 1px solid var(--bordure); font-size: 13px; background: var(--surface-alt); }

/* ── KPI ── */
.grille-kpi { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.carte-kpi {
    background: var(--carte); border-radius: var(--rayon); border: 1px solid var(--bordure); padding: 19px 20px;
    display: flex; align-items: center; gap: 14px; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
a.carte-kpi:hover, .carte-kpi.carte-kpi-lien:hover { transform: translateY(-2px); box-shadow: var(--ombre-hover); text-decoration: none; color: inherit; border-color: var(--bordure-vive); }
.carte-kpi .icone { width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.carte-kpi > div:not(.icone) { min-width: 0; }
.carte-kpi strong { display: block; font-family: var(--police-titre); font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--texte); overflow-wrap: break-word; }
.carte-kpi span { font-size: 12px; color: var(--texte-doux); overflow-wrap: break-word; }

/* ── BOUTONS ── */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 17px; border-radius: var(--rayon-sm); border: none;
    font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; font-family: var(--police-texte);
    transition: background .12s ease, box-shadow .12s ease, transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primaire { background: var(--or); color: var(--encre); box-shadow: 0 1px 2px rgba(150,112,31,.25); }
.btn-primaire:hover { background: var(--or-fonce); color: #fff; }
.btn-secondaire { background: #fff; color: var(--texte); border: 1px solid var(--bordure-vive); }
.btn-secondaire:hover { background: var(--surface-alt); border-color: var(--encre-eclat); }
.btn-danger { background: var(--rouge-fond); color: var(--rouge); }
.btn-danger:hover { background: #f6dcda; }
.btn-large { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ── TABLEAU ── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-family: var(--police-titre); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-doux); padding: 11px 16px; border-bottom: 1.5px solid var(--bordure); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid #efede7; font-size: 13.3px; color: var(--texte); }
.table tr:last-child td { border-bottom: none; }
.table tr.ligne-cliquable { cursor: pointer; transition: background .1s ease; }
.table tr.ligne-cliquable:hover { background: var(--surface-alt); }
/* Un tableau dans un panneau défile horizontalement plutôt que de casser la mise en page sur petit écran */
.panneau:has(.table) { overflow-x: auto; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 4px 11px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .01em; }
.badge-planifie { background: var(--bleu-fond); color: var(--bleu); }
.badge-en_cours { background: var(--or-fond); color: var(--or-fonce); }
.badge-en_attente { background: var(--ambre-fond); color: var(--ambre); }
.badge-suspendu { background: var(--rouge-fond); color: var(--rouge); }
.badge-termine { background: var(--sauge-fond); color: var(--sauge); }
.badge-annule { background: #f0efea; color: #80818c; }

/* ── BARRE DE PROGRESSION ── */
.progression { background: #eae7df; border-radius: 20px; height: 8px; overflow: hidden; width: 100%; }
.progression-remplie { background: var(--or); height: 100%; border-radius: 20px; }

/* ── FORMULAIRES ── */
.formulaire label { display: block; font-size: 12.5px; font-weight: 600; margin: 13px 0 5px; color: var(--encre-douce); }
.formulaire label:first-child { margin-top: 0; }
.formulaire input, .formulaire select, .formulaire textarea {
    width: 100%; padding: 9px 12px; border-radius: var(--rayon-sm); border: 1px solid var(--bordure-vive); font-size: 13.5px;
    font-family: inherit; background: #fff; color: var(--texte); transition: border-color .12s ease, box-shadow .12s ease;
}
.formulaire input::placeholder, .formulaire textarea::placeholder { color: #a7a39a; }
.formulaire input:focus, .formulaire select:focus, .formulaire textarea:focus { outline: none; border-color: var(--or); box-shadow: 0 0 0 3px rgba(184,135,47,.14); }
.formulaire-ligne { display: flex; gap: 12px; }
.formulaire-ligne > div { flex: 1; }

/* ── LOGIN ── */
.page-login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(circle at 20% 20%, #1d2846 0%, var(--encre) 45%, #0c1021 100%); padding: 20px; }
.carte-login { background: #fff; border-radius: 18px; padding: 38px 36px; width: 100%; max-width: 384px; box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.carte-login-entete { text-align: center; margin-bottom: 26px; }
.logo-login { width: 54px; height: 54px; background: var(--or); border-radius: 15px; display: flex; align-items: center; justify-content: center; color: var(--encre); margin: 0 auto 16px; }
.carte-login-entete h1 { font-family: var(--police-titre); font-size: 19px; margin: 0 0 5px; color: var(--texte); }
.carte-login-entete p { color: var(--texte-doux); font-size: 13px; margin: 0; }
.carte-login-pied { text-align: center; font-size: 11.5px; color: var(--texte-doux); margin-top: 20px; }
.carte-login input { width: 100%; padding: 10px 12px; border-radius: var(--rayon-sm); border: 1px solid var(--bordure-vive); background: #fff; color: var(--texte); font-size: 13.5px; }
.carte-login input:focus { outline: none; border-color: var(--or); box-shadow: 0 0 0 3px rgba(184,135,47,.14); }
.carte-login label { display: block; font-size: 12.5px; font-weight: 600; margin: 13px 0 5px; color: var(--encre-douce); }

/* ── ALERTES / FLASH ── */
.alerte { padding: 11px 15px; border-radius: var(--rayon-sm); font-size: 13px; margin-bottom: 14px; }
.alerte-erreur { background: var(--rouge-fond); color: var(--rouge); }
.conteneur-flash { position: fixed; top: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 36px); }
.flash { padding: 13px 19px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: 0 10px 28px rgba(0,0,0,.18); }
.flash-succes { background: var(--sauge); color: #fff; }
.flash-erreur { background: var(--rouge); color: #fff; }

/* ── PASTILLES DE CRITICITÉ ── */
.pastille { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.pastille-normal { background: var(--sauge); }
.pastille-risque { background: var(--ambre); }
.pastille-critique { background: var(--rouge); }

/* ── BARRE MOBILE (bouton menu) — masquée sur desktop ── */
.barre-mobile { display: none; }
.sidebar-fond { display: none; }

/* ════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════ */

/* Tablette : la grille KPI se resserre, le contenu respire un peu moins */
@media (max-width: 1080px) {
    .grille-kpi { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .content { padding: 26px 28px; }
}

@media (max-width: 860px) {
    .layout { flex-direction: column; }

    /* Barre fixe en haut, avec le bouton hamburger — seul élément toujours visible sur mobile */
    .barre-mobile {
        display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 220;
        background: var(--encre); color: #fff; padding: 13px 16px;
        padding-top: calc(13px + env(safe-area-inset-top, 0px));
        box-shadow: 0 2px 10px rgba(0,0,0,.12);
    }
    .bouton-hamburger { background: none; border: none; color: #fff; padding: 4px; cursor: pointer; display: flex; }
    .bouton-hamburger i[data-lucide] { width: 23px; height: 23px; }
    .barre-mobile-nom { font-family: var(--police-titre); font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    /* Le menu devient un tiroir qui glisse depuis la gauche, par-dessus le contenu */
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 82vw; max-width: 300px;
        transform: translateX(-100%); transition: transform .28s cubic-bezier(.3,.9,.4,1); z-index: 230;
        overflow-y: auto; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 10px 0 40px rgba(0,0,0,.25);
    }
    body.menu-ouvert .sidebar { transform: translateX(0); }

    /* Fond sombre derrière le tiroir, pour le refermer en touchant à côté */
    .sidebar-fond {
        display: block; position: fixed; inset: 0; background: rgba(12,16,28,.55); z-index: 220;
        opacity: 0; pointer-events: none; transition: opacity .25s ease; backdrop-filter: blur(1px);
    }
    body.menu-ouvert .sidebar-fond { opacity: 1; pointer-events: auto; }
    body.menu-ouvert { overflow: hidden; }

    .content { padding: 18px 16px 32px; }
    .grille-kpi { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
    .carte-kpi { padding: 15px; gap: 11px; }
    .carte-kpi .icone { width: 38px; height: 38px; }
    .carte-kpi strong { font-size: 20px; }

    .page-header { padding: 20px 20px; border-radius: 14px; }
    .page-header h1 { font-size: 1.28em; }
    .page-header > form, .page-header > div:not(:first-child) { width: 100%; }
    /* De nombreuses pages placent leurs boutons d'action dans un div flex en ligne,
       sans retour à la ligne prévu — on le force ici, une fois pour toutes. */
    .page-header > div { flex-wrap: wrap; }
    .page-header .btn, .page-header .btn-secondaire { flex: 1 1 auto; justify-content: center; }

    .formulaire-ligne { flex-direction: column; gap: 0; }

    .barre-outils-liste { padding: 11px 13px; }
    .barre-outils-liste input[type="search"] { min-width: 100%; }
    .barre-outils-liste select { flex: 1; min-width: 0; }
}

@media (max-width: 480px) {
    .grille-kpi { grid-template-columns: minmax(0,1fr); }
    .carte-login { padding: 30px 24px; border-radius: 14px; }
}

/* ── UTILITAIRES ── */
.fw-semibold { font-weight: 600; }
.icone-lucide { width: 18px; height: 18px; vertical-align: middle; margin-right: 4px; }
@media print { .no-print { display: none !important; } }
.cache { display: none !important; }
