/* =====================================================================
   PSC — Design system
   Palette pensée "terrain / suivi géolocalisé" : navy profond + signal teal,
   volontairement à l'écart des defaults IA (pas de crème/terracotta,
   pas de noir+néon). Base 12px imposée par le cahier des charges (16.6).
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Couleurs de base */
    --navy-950: #0B1524;
    --navy-900: #101B2D;
    --navy-800: #182741;
    --navy-700: #23345291;
    --surface: #FFFFFF;
    --app-bg: #F5F7FA;
    --border: #E3E8EF;
    --border-strong: #CBD5E1;

    /* Texte */
    --text-primary: #16202C;
    --text-secondary: #55637A;
    --text-muted: #8B96A8;
    --text-on-dark: #E7ECF5;
    --text-on-dark-muted: #8FA0BC;

    /* Accent signal (géoloc / progression) */
    --signal-500: #0EA5A0;
    --signal-600: #0B8C88;
    --signal-100: #E1F5F3;

    /* États */
    --warning-500: #F59E0B;
    --warning-100: #FEF3D9;
    --danger-500: #DC2626;
    --danger-100: #FDE8E8;
    --success-500: #16A34A;
    --success-100: #E4F6EA;

    /* Typo */
    --font-display: 'Manrope', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;
    --fs-base: 12px;

    /* Layout */
    --sidebar-w: 232px;
    --sidebar-w-collapsed: 68px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(16, 27, 45, 0.06), 0 1px 12px rgba(16, 27, 45, 0.04);
    --shadow-pop: 0 12px 32px rgba(11, 21, 36, 0.16);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { font-size: var(--fs-base); }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--app-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    font-size: 1rem;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5em;
    letter-spacing: -0.01em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

a { color: var(--signal-600); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: var(--font-body); }

/* Focus visible clavier (accessibilité) */
:focus-visible {
    outline: 2px solid var(--signal-500);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   Icônes flat/vectorielles (SVG inline, jamais d'emoji — 16.6)
   --------------------------------------------------------------------- */
.icon {
    width: 1.15em;
    height: 1.15em;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    vertical-align: -0.2em;
}

/* =====================================================================
   ÉCRAN DE CONNEXION
   ===================================================================== */
.auth-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    background: var(--navy-950);
}

@media (min-width: 1024px) {
    .auth-screen { grid-template-columns: 1.1fr 1fr; }
}

.auth-brand {
    display: none;
    position: relative;
    padding: 48px;
    background:
        radial-gradient(circle at 20% 20%, rgba(14,165,160,0.35), transparent 45%),
        radial-gradient(circle at 80% 70%, rgba(14,165,160,0.18), transparent 40%),
        linear-gradient(160deg, var(--navy-950), var(--navy-900));
    color: var(--text-on-dark);
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}
@media (min-width: 1024px) { .auth-brand { display: flex; } }

.auth-brand__mark { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; }
.auth-brand__mark .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--signal-500); box-shadow: 0 0 0 5px rgba(14,165,160,0.18); }

.auth-brand__pins { position: relative; flex: 1; margin: 40px 0; }
.auth-brand__pins svg { width: 100%; height: 100%; }

.auth-brand__quote { font-size: 1.05rem; line-height: 1.6; max-width: 420px; color: var(--text-on-dark); }
.auth-brand__quote span { display: block; margin-top: 10px; font-size: 0.85rem; color: var(--text-on-dark-muted); }

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background: var(--surface);
}

.auth-card { width: 100%; max-width: 360px; }
.auth-card__logo { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--text-primary); }
.auth-card__logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal-500); }

.auth-card h1 { font-size: 1.35rem; margin-bottom: 4px; }
.auth-card__sub { color: var(--text-secondary); margin-bottom: 24px; font-size: 0.95rem; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); font-size: 0.92rem; }
.field input, .field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font-body);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.field input:focus, .field select:focus {
    border-color: var(--signal-500);
    box-shadow: 0 0 0 3px var(--signal-100);
    outline: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.1s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy-900); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--navy-800); }
.btn-accent { background: var(--signal-500); color: #fff; }
.btn-accent:hover { background: var(--signal-600); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--app-bg); }
.btn-danger { background: var(--danger-500); color: #fff; }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.alert-danger { background: var(--danger-100); color: #8A1F1F; }
.alert-warning { background: var(--warning-100); color: #7A5107; }
.alert-success { background: var(--success-100); color: #14532D; }

.lang-switch { display: flex; gap: 4px; margin-top: 22px; }
.lang-switch a {
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
}
.lang-switch a.active { background: var(--navy-900); color: #fff; }

/* Préloader après validation des identifiants (16.6) */
.preloader-overlay {
    position: fixed; inset: 0;
    background: var(--navy-950);
    display: flex; align-items: center; justify-content: center;
    z-index: 999; opacity: 0; pointer-events: none;
    transition: opacity 0.25s var(--ease);
}
.preloader-overlay.is-active { opacity: 1; pointer-events: all; }
.preloader-rings { position: relative; width: 64px; height: 64px; }
.preloader-rings span {
    position: absolute; inset: 0;
    border: 2.5px solid transparent;
    border-top-color: var(--signal-500);
    border-radius: 50%;
    animation: psc-spin 0.9s linear infinite;
}
.preloader-rings span:nth-child(2) { inset: 10px; border-top-color: rgba(255,255,255,0.5); animation-duration: 1.3s; animation-direction: reverse; }
@keyframes psc-spin { to { transform: rotate(360deg); } }
.preloader-label { position: absolute; margin-top: 90px; color: var(--text-on-dark-muted); font-size: 0.85rem; text-align: center; width: 200px; left: 50%; transform: translateX(-50%); top: 100%; }

/* Animation de fin de session (16.6) */
.logout-overlay {
    position: fixed; inset: 0; background: var(--navy-950);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: var(--text-on-dark); gap: 14px; z-index: 999;
    animation: psc-fade-in 0.2s var(--ease);
}
@keyframes psc-fade-in { from { opacity: 0; } to { opacity: 1; } }
.logout-overlay .check {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--signal-500); display: flex; align-items: center; justify-content: center;
    animation: psc-pop 0.35s var(--ease);
}
@keyframes psc-pop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* =====================================================================
   APPLICATION — SHELL (sidebar + topbar + contenu)
   ===================================================================== */
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar : navigation entièrement visible sans scroll (16.6) */
.sidebar {
    width: var(--sidebar-w);
    background: var(--navy-950);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: hidden; /* jamais de scroll dans la sidebar */
    padding: 18px 12px;
    gap: 4px;
}

.sidebar__logo { display: flex; align-items: center; gap: 9px; padding: 6px 8px 18px; font-family: var(--font-display); font-weight: 800; font-size: 1rem; }
.sidebar__logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--signal-500); box-shadow: 0 0 0 4px rgba(14,165,160,0.2); }

.sidebar__company { font-size: 0.78rem; color: var(--text-on-dark-muted); padding: 0 8px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 10px; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden; }
.sidebar__link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--text-on-dark-muted); font-weight: 600; font-size: 0.88rem;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
    white-space: nowrap;
}
.sidebar__link:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar__link.active { background: var(--signal-500); color: #fff; }
.sidebar__link .icon { width: 1.05em; height: 1.05em; }

.sidebar__footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; margin-top: 6px; }
.sidebar__user { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.sidebar__avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--signal-500); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.sidebar__user-meta { overflow: hidden; }
.sidebar__user-name { font-size: 0.85rem; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user-role { font-size: 0.75rem; color: var(--text-on-dark-muted); }

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

.topbar {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-family: var(--font-display); font-weight: 800; font-size: 1rem; }
.topbar__actions { display: flex; align-items: center; gap: 14px; }

.content { padding: 22px; flex: 1; }

/* Bandeau alerte licence (J-15/J-7/J-1) */
.license-banner {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px; font-size: 0.88rem; font-weight: 600;
    background: var(--warning-100); color: #7A5107;
    border-bottom: 1px solid #F0D998;
}
.license-banner.is-critical { background: var(--danger-100); color: #8A1F1F; border-color: #F3B9B9; }

/* Cartes / grilles KPI */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 767px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    box-shadow: var(--shadow-card);
}
.card-kpi__label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-kpi__value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; margin-top: 6px; }
.card-kpi__delta { font-size: 0.78rem; font-weight: 700; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; }
.card-kpi__delta.up { color: var(--success-500); }
.card-kpi__delta.down { color: var(--danger-500); }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-card); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th { text-align: left; padding: 11px 16px; background: var(--app-bg); color: var(--text-secondary); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--app-bg); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.badge-success { background: var(--success-100); color: #14532D; }
.badge-warning { background: var(--warning-100); color: #7A5107; }
.badge-danger { background: var(--danger-100); color: #8A1F1F; }
.badge-neutral { background: var(--app-bg); color: var(--text-secondary); border: 1px solid var(--border); }

/* Progression d'objectif */
.progress { height: 8px; background: var(--app-bg); border-radius: 20px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--signal-500); border-radius: 20px; transition: width 0.6s var(--ease); }

/* Wizard de première configuration */
.wizard-screen { min-height: 100vh; background: var(--app-bg); display: flex; align-items: center; justify-content: center; padding: 24px; }
.wizard-card { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 32px; }
.wizard-steps { display: flex; gap: 6px; margin-bottom: 24px; }
.wizard-steps__item { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.wizard-steps__item.done, .wizard-steps__item.current { background: var(--signal-500); }
.wizard-eyebrow { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--signal-600); margin-bottom: 6px; }

/* Utilitaires */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--text-secondary); }
.text-small { font-size: 0.85rem; }

/* Préréglages de thème (Module 11, personnalisation) — surchargent l'accent signal */
body.theme-indigo { --signal-500: #6366F1; --signal-600: #4F46E5; --signal-100: #E7E7FE; }
body.theme-amber  { --signal-500: #D97706; --signal-600: #B45309; --signal-100: #FDECC8; }
body.theme-rose   { --signal-500: #E11D48; --signal-600: #BE123C; --signal-100: #FCE1E7; }

/* Impression (Module 10 : export PDF via impression navigateur) */
.print-page { max-width: 900px; margin: 0 auto; padding: 32px; background: #fff; }
.print-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--navy-950); padding-bottom: 14px; margin-bottom: 20px; }
.print-header h1 { font-size: 1.3rem; margin: 0; }
.print-meta { font-size: 0.8rem; color: var(--text-secondary); text-align: right; }
.print-toolbar { max-width: 900px; margin: 16px auto; display: flex; justify-content: flex-end; }
@media print {
    .print-toolbar { display: none; }
    .print-page { padding: 0; }
    body { background: #fff; }
}

/* Responsive shell : sidebar en navigation basse sur mobile */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; bottom: 0; top: auto; width: 100%; height: 62px; flex-direction: row; align-items: center; padding: 6px 10px; z-index: 40; border-top: 1px solid rgba(255,255,255,0.08); }
    .sidebar__logo, .sidebar__company, .sidebar__footer { display: none; }
    .sidebar__nav { flex-direction: row; justify-content: space-around; overflow-x: auto; }
    .sidebar__link { flex-direction: column; gap: 2px; font-size: 0.68rem; padding: 6px 8px; }
    .main { padding-bottom: 62px; }
    .content { padding: 16px; }
}
