/* ==========================================================================
   Planning Garage — feuille de style
   ========================================================================== */

:root {
    --bg: #eef2f8;
    --card: #ffffff;
    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --accent: #f59e0b;
    --accent-dark: #b45309;
    --sidebar: #0b1220;
    --sidebar-soft: #16213a;
    --success: #16a34a;
    --danger: #dc2626;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .25);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------- Structure ---------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: linear-gradient(180deg, var(--sidebar) 0%, #0e1a30 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, .15);
}

.brand-logo {
    width: auto;
    height: 40px;
    padding: 4px 8px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #fff;
}

.brand-logo img {
    height: 27px;
    width: auto;
    display: block;
}

.brand-text strong { display: block; color: #f8fafc; font-size: 15px; }
.brand-text span { font-size: 11.5px; color: #94a3b8; letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

.nav-titre {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #64748b;
    padding: 14px 10px 6px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #cbd5e1;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}

.nav a:hover { background: rgba(148, 163, 184, .12); color: #f8fafc; }

.nav a.actif {
    background: rgba(245, 158, 11, .16);
    color: #fbbf24;
    font-weight: 600;
    box-shadow: inset 2px 0 0 var(--accent);
}

.nav .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar-footer {
    margin-top: auto;
    padding: 14px 18px;
    font-size: 11.5px;
    color: #64748b;
    border-top: 1px solid rgba(148, 163, 184, .15);
}

.contenu { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar h1 { font-size: 19px; }
.topbar .sous-titre { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.page { padding: 24px 28px 48px; max-width: 1500px; width: 100%; }

/* ---------- Cartes ------------------------------------------------------- */
.carte {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.carte + .carte { margin-top: 18px; }

.carte-entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.carte-entete h2 { font-size: 15px; }
.carte-entete p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

.carte-corps { padding: 18px; }

.grille-cartes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 15px 16px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 13px;
}

.kpi .valeur { font-size: 24px; font-weight: 700; line-height: 1.1; }
.kpi .libelle { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.kpi-ico {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 19px;
    background: #f1f5f9;
    color: var(--ink-soft);
    flex: 0 0 42px;
}

/* ---------- Colonnes ----------------------------------------------------- */
.duo { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1050px) { .duo { grid-template-columns: 1fr; } }

/* ---------- Boutons ------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}

.btn:hover { background: #f8fafc; border-color: #94a3b8; }

.btn-primary {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    border-color: #ea8c0b;
    color: #201a09;
    box-shadow: 0 4px 14px -6px rgba(245, 158, 11, .9);
}

.btn-primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, #f59e0b, #f97316); }

.btn-sombre { background: var(--sidebar); border-color: var(--sidebar); color: #fff; }
.btn-sombre:hover { background: #16213a; border-color: #16213a; }

.btn-danger { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn-danger:hover { background: #fee2e2; border-color: #fca5a5; }

.btn-mini { padding: 4px 9px; font-size: 12px; border-radius: 8px; }

.btn-lien {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--muted); font-size: 12.5px; text-decoration: underline;
}
.btn-lien:hover { color: var(--danger); }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Formulaires -------------------------------------------------- */
.formulaire { display: grid; gap: 15px; }
.form-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 15px; }

.champ { display: flex; flex-direction: column; gap: 5px; }
.champ label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.champ .aide { font-size: 11.5px; color: var(--muted); }

input[type="text"], input[type="date"], input[type="month"], input[type="number"],
input[type="email"], input[type="password"], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .18);
}

textarea { min-height: 80px; resize: vertical; }

.case { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.case input[type="checkbox"] { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--accent-dark); }
.case .case-texte { font-size: 12.5px; color: var(--ink-soft); }
.case .case-texte strong { display: block; font-size: 13px; color: var(--ink); }

/* ---------- Alertes ------------------------------------------------------ */
.alerte {
    display: flex;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alerte-succes { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alerte-erreur { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alerte-attention { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alerte-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.alerte ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Tableaux ----------------------------------------------------- */
.tableau { width: 100%; border-collapse: collapse; font-size: 13px; }

.tableau th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
    white-space: nowrap;
}

.tableau td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tableau tbody tr:last-child td { border-bottom: none; }
.tableau tbody tr:hover { background: #fbfdff; }
.tableau .nombre { font-variant-numeric: tabular-nums; }
.tableau .droite { text-align: right; }

.enveloppe { overflow-x: auto; }

.vide { padding: 34px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.vide strong { display: block; color: var(--ink-soft); margin-bottom: 4px; font-size: 14px; }

/* ---------- Badges ------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-neutre { background: #f1f5f9; color: #475569; }
.badge-indigo { background: #e0e7ff; color: #3730a3; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-sky { background: #e0f2fe; color: #075985; }
.badge-violet { background: #ede9fe; color: #5b21b6; }
.badge-rose { background: #ffe4e6; color: #9f1239; }
.badge-slate { background: #e2e8f0; color: #334155; }
.badge-cyan { background: #cffafe; color: #155e75; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-teal { background: #ccfbf1; color: #115e59; }
.badge-fuchsia { background: #fae8ff; color: #86198f; }
.badge-lime { background: #ecfccb; color: #3f6212; }

.puce { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.puce-indigo { background: #6366f1; } .puce-amber { background: #f59e0b; }
.puce-emerald { background: #10b981; } .puce-sky { background: #0ea5e9; }
.puce-violet { background: #8b5cf6; } .puce-rose { background: #f43f5e; }
.puce-slate { background: #64748b; } .puce-cyan { background: #06b6d4; }
.puce-orange { background: #f97316; } .puce-yellow { background: #eab308; }
.puce-teal { background: #14b8a6; } .puce-fuchsia { background: #d946ef; }
.puce-lime { background: #84cc16; }

/* ---------- Avatar ------------------------------------------------------- */
.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: #e2e8f0;
    color: #334155;
    font-size: 11.5px;
    font-weight: 700;
    flex: 0 0 30px;
}

.agent-cellule { display: flex; align-items: center; gap: 9px; }
.agent-cellule .meta { font-size: 11.5px; color: var(--muted); }

.ordre-pastille {
    display: inline-grid;
    place-items: center;
    width: 22px; height: 22px;
    border-radius: 7px;
    background: #0b1220;
    color: #fbbf24;
    font-size: 11px;
    font-weight: 700;
    flex: 0 0 22px;
}

/* ---------- Calendrier --------------------------------------------------- */
.calendrier-enveloppe { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }

.calendrier { border-collapse: separate; border-spacing: 0; font-size: 12px; width: 100%; }

.calendrier th, .calendrier td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 0;
    text-align: center;
    min-width: 42px;
}

.calendrier thead th {
    background: #f8fafc;
    padding: 6px 3px;
    font-size: 10.5px;
    color: var(--muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 2;
}

.calendrier thead th .num { display: block; font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }

.calendrier .col-agent {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 3;
    text-align: left;
    padding: 7px 10px 7px 12px;
    min-width: 190px;
    border-right: 1px solid var(--line-strong);
}

.calendrier thead .col-agent { z-index: 4; background: #f8fafc; }

.calendrier td.cellule { padding: 3px; height: 38px; }
.calendrier td.weekend { background: #f8fafc; }
.calendrier td.aujourdhui { background: #fffbeb; box-shadow: inset 0 0 0 1px #fcd34d; }
.calendrier td.libre { color: #cbd5e1; }

.case-jour {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 4px 3px;
    border-radius: 7px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .01em;
    cursor: default;
}

.case-jour.permanence { background: #e0e7ff; color: #3730a3; }
.case-jour.rotation-amber { background: #fef3c7; color: #92400e; }
.case-jour.rotation-emerald { background: #d1fae5; color: #065f46; }
.case-jour.rotation-sky { background: #e0f2fe; color: #075985; }
.case-jour.rotation-violet { background: #ede9fe; color: #5b21b6; }
.case-jour.rotation-rose { background: #ffe4e6; color: #9f1239; }
.case-jour.rotation-slate { background: #e2e8f0; color: #334155; }
.case-jour.rotation-cyan { background: #cffafe; color: #155e75; }
.case-jour.rotation-orange { background: #ffedd5; color: #9a3412; }
.case-jour.rotation-yellow { background: #fef9c3; color: #854d0e; }
.case-jour.rotation-teal { background: #ccfbf1; color: #115e59; }
.case-jour.rotation-fuchsia { background: #fae8ff; color: #86198f; }
.case-jour.rotation-lime { background: #ecfccb; color: #3f6212; }
.case-jour.rotation-indigo { background: #e0e7ff; color: #3730a3; }
.case-jour.absence { background: #ffe4e6; color: #9f1239; font-size: 9px; }

.legende { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legende span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Barre d'outils ---------------------------------------------- */
.outils { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.outils .champ { min-width: 150px; }

.segmented { display: inline-flex; background: #f1f5f9; border-radius: 10px; padding: 3px; gap: 2px; }
.segmented a { padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.segmented a.actif { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

.mois-titre { font-size: 15px; font-weight: 650; min-width: 170px; text-align: center; text-transform: capitalize; }

/* ---------- Divers ------------------------------------------------------- */
.entete-section { margin-bottom: 16px; }
.entete-section h2 { font-size: 17px; }
.entete-section p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.etapes-cycle { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.etape-cycle {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 13px; border-radius: 11px;
    background: #f8fafc; border: 1px solid var(--line);
    font-size: 12px;
}
.etape-cycle .j { font-size: 10.5px; font-weight: 700; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .06em; }
.etape-cycle .site { font-weight: 650; color: var(--ink); }
.fleche { color: var(--line-strong); font-size: 15px; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages a, .pagination .pages span {
    display: inline-grid; place-items: center;
    min-width: 30px; height: 30px; padding: 0 8px;
    border-radius: 8px; border: 1px solid var(--line); background: #fff;
}
.pagination .pages .actif { background: var(--sidebar); color: #fff; border-color: var(--sidebar); }

.texte-doux { color: var(--muted); }.texte-petit { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.inline { display: inline; }

/* ---------- Suppression d'une affectation dans le calendrier ------------- */
.cellule-boite { position: relative; display: block; line-height: 1; }

.suppr-cellule {
    position: absolute;
    top: -5px;
    right: -3px;
    width: 15px;
    height: 15px;
    padding: 0;
    line-height: 12px;
    border-radius: 50%;
    border: 1px solid #fecaca;
    background: #fff;
    color: var(--danger);
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease;
}

.calendrier td:hover .suppr-cellule { opacity: 1; }
.suppr-cellule:hover { background: #fee2e2; }

/* ---------- Édition directe du planning --------------------------------- */
.cellule { cursor: pointer; transition: background .12s ease; }
.cellule:hover { background: #fff7ed; }
.calendrier td.cellule.en-deplacement { opacity: .4; }
.calendrier td.cellule.cible-survol { background: #fef3c7; box-shadow: inset 0 0 0 2px var(--accent); }

.aide-edition {
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    background: #f8fafc;
    font-size: 12.5px;
    color: var(--muted);
    border-radius: 0 0 var(--radius) var(--radius);
}

.modale {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modale[hidden] { display: none; }

.modale-fond {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
}

.modale-boite {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 16px;
    padding: 18px 20px 20px;
    box-shadow: 0 24px 60px -20px rgba(15, 23, 42, .55);
    animation: apparaitre .15s ease-out;
}

@keyframes apparaitre {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.modale-entete {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.modale-entete h3 { font-size: 16px; }

.modale-fermer {
    border: none;
    background: #f1f5f9;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 18px;
    line-height: 1;
    color: #475569;
    cursor: pointer;
    flex: 0 0 30px;
}

.modale-fermer:hover { background: #e2e8f0; }

.modale-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.modale-actions .btn-danger { margin-right: auto; }

.notifications {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}

.toast {
    padding: 11px 14px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 12px 30px -12px rgba(15, 23, 42, .5);
    animation: apparaitre .18s ease-out;
}

.toast-succes { background: #065f46; color: #ecfdf5; }
.toast-erreur { background: #991b1b; color: #fef2f2; }
.toast-attention { background: #92400e; color: #fffbeb; }

@media (max-width: 700px) {
    .modale-boite { max-width: none; }
    .notifications { left: 16px; right: 16px; max-width: none; }
}

/* ---------- Impression des écrans de l'application ----------------------- */
@media print {
    .sidebar,
    .topbar .actions,
    .barre-impression,
    .suppr-cellule,
    .btn,
    .segmented { display: none !important; }

    .app, .contenu { display: block; }

    body { background: #fff; }

    .topbar {
        position: static;
        padding: 0 0 10px;
        border-bottom: 1px solid #d1d5db;
    }

    .page { padding: 0; max-width: none; }

    .carte {
        box-shadow: none;
        border-color: #d1d5db;
        break-inside: avoid;
    }

    .carte + .carte { margin-top: 12px; }

    .calendrier-enveloppe { overflow: visible; }
    .calendrier { font-size: 9pt; }
    .calendrier thead th { position: static; }

    a { text-decoration: none; color: inherit; }
}
