@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;700&display=swap');

/* ════════════════════════════════════════════════════════════════
   ROTOR FSM — Design System aligné sur STATOR CRM
   Thème CLAIR par défaut (comme le CRM) + mode sombre via html.dark-mode
════════════════════════════════════════════════════════════════ */

:root {
    /* Accent principal STATOR */
    --primary: #E84C2B;
    --primary-light: #f0663f;
    --primary-dark: #c43b1f;
    --primary-glow: rgba(232, 76, 43, 0.30);
    --primary-subtle: rgba(232, 76, 43, 0.08);
    --or-l: #FFF1EE;                /* teinte hover (CRM --or-l) */
    --secondary: #1C1C1E;           /* fond tooltip */
    --lenoir-blue: #0a1e3d;
    --lenoir-orange: #E84C2B;

    /* Surfaces (palette claire STATOR) */
    --bg-main: #F0EFED;
    --bg-elevated: #FFFFFF;
    --bg-2: #FAFAF8;
    --bg-3: #F5F5F7;
    --bg-4: #F0F0F2;
    --bg-glass: #FFFFFF;
    --glass-bg: #FFFFFF;
    --glass-border: #E8E8EA;
    --glass-border-hover: #D8D8DC;
    --glass-shine: linear-gradient(135deg, rgba(0, 0, 0, 0.015) 0%, transparent 60%);

    /* Texte */
    --text-main: #1C1C1E;
    --text: #1C1C1E;
    --text-muted: #3C3C40;
    --text-dim: #6E6E78;

    /* Statuts (palette STATOR) */
    --accent-cyan: #2563eb;
    --accent-purple: #7c3aed;
    --error: #dc2626;
    --success: #16a34a;
    --warning: #d97706;

    /* Rayons */
    --radius-xl: 16px;
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;

    /* Ombres douces (CRM) */
    --shadow-premium: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 14px 32px rgba(232, 76, 43, 0.12);
    --shadow-glow: 0 0 0 3px rgba(232, 76, 43, 0.10);
    --glass-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);

    --font-main: 'Outfit', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition-smooth: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);

    /* Mobile bottom nav height */
    --mobile-nav-height: 72px;
    --mobile-header-height: 60px;

    /* Scrollbar (CRM) */
    --scroll: #A8A8B4;
    --scroll-h: #888896;
}

/* ═══════════ MODE SOMBRE (palette sombre STATOR) ═══════════ */
html.dark-mode {
    --or-l: #2A1510;
    --secondary: #222229;

    --bg-main: #0D0D11;
    --bg-elevated: #18181E;
    --bg-2: #1C1C23;
    --bg-3: #222229;
    --bg-4: #1E1E25;
    --bg-glass: #18181E;
    --glass-bg: #18181E;
    --glass-border: #2A2A35;
    --glass-border-hover: #3A3A48;
    --glass-shine: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, transparent 60%);

    --text-main: #EAEAF0;
    --text: #EAEAF0;
    --text-muted: #B8B8C4;
    --text-dim: #9898A8;

    --shadow-premium: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 14px 32px rgba(0, 0, 0, 0.45);
    --glass-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);

    --scroll: #4A4A5C;
    --scroll-h: #6A6A80;
}

/* ═══════════ RESET & BASE ═══════════ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ═══════════ CUSTOM SCROLLBARS (CRM) ═══════════ */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--scroll);
    border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-h);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    font-size: 15px;
    transition: background-color .35s ease, color .35s ease;
}

/* --- GLOBAL ANIMATIONS --- */
.animate-in {
    animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.hover-glow {
    transition: all 0.3s ease;
}

.hover-glow:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--primary) !important;
    transform: translateY(-2px);
}

.stat-card.premium-glow:hover {
    border-color: var(--primary) !important;
    box-shadow: 0 14px 32px rgba(232, 76, 43, 0.15);
}


/* ═══════════ BACKGROUND ═══════════ */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--bg-main);
    z-index: -4;
    transition: background .35s ease;
}

/* Les fonds vidéo de l'ancien design sont retirés partout */
.video-background {
    display: none !important;
}

/* ═══════════ INPUT CLEAR BUTTON ═══════════ */
.input-clear {
    position: absolute;
    right: 3rem;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.5rem;
    display: none;
    transition: var(--transition-fast);
}

.input-clear:hover {
    color: var(--error);
    transform: scale(1.2);
}

.input-wrapper:focus-within .input-clear {
    display: block;
}

/* ═══════════ SURFACES (ex-glassmorphism → cartes STATOR) ═══════════ */
.glass {
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-premium);
}

/* ═══════════ CARD ═══════════ */
.card {
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-premium);
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* ═══════════ TYPOGRAPHY ═══════════ */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
    line-height: 1.2;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-center {
    text-align: center;
}

/* ═══════════ FORMS ═══════════ */
.form-group {
    margin-bottom: 1.5rem;
}

.label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: color .2s;
}

.form-group:focus-within .label {
    color: var(--primary);
}

.input {
    width: 100%;
    background: var(--bg-2);
    border: 1.5px solid var(--glass-border);
    border-radius: 10px;
    padding: 0.8rem 1.1rem;
    color: var(--text-main);
    font-family: var(--font-main);
    transition: border-color .2s, background .2s, box-shadow .2s;
    outline: none;
    caret-color: var(--primary);
    /* Prevent iOS zoom on input focus (min 16px) */
    font-size: 16px;
}

.input::placeholder {
    color: var(--text-dim);
    font-weight: 400;
    text-align: left;
    opacity: 0.7;
}

/* Force l'alignement à gauche dans les input wrappers (champs MDP) */
.input-wrapper .input,
.p-password {
    text-align: left;
}

.input:focus {
    border-color: rgba(232, 76, 43, 0.65);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-glow);
}

/* ═══════════ BUTTONS (idiome STATOR) ═══════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: transform .15s ease, filter .15s ease, background .15s ease,
        border-color .15s ease, color .15s ease, box-shadow .2s ease;
    border: none;
    text-decoration: none;
    gap: 0.6rem;
    position: relative;
    overflow: hidden;
    font-family: var(--font-main);
    /* Minimum touch target 44px */
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(232, 76, 43, 0.28);
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(0.94);
    box-shadow: 0 8px 22px rgba(232, 76, 43, 0.38);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(232, 76, 43, 0.25);
}

.btn-ghost {
    background: var(--bg-glass);
    color: var(--text-muted);
    border: 1.5px solid var(--glass-border);
}

.btn-ghost:hover {
    background: var(--or-l);
    border-color: rgba(232, 76, 43, 0.45);
    color: var(--primary);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* ═══════════ ICÔNES BLANCHES SUR THÈME CLAIR ═══════════
   Les pictos *_white.svg de l'ancien thème sombre deviennent gris foncé
   sur fond clair. Ils restent blancs sur les fonds accent (btn-primary),
   sur la page de connexion (toujours sombre) et en mode sombre. */
img[src*="_white.svg"] {
    filter: brightness(0) invert(0.28);
}

.btn-primary img[src*="_white.svg"],
.mobile-nav-item.active img[src*="_white.svg"],
.login-page img[src*="_white.svg"],
html.dark-mode img[src*="_white.svg"] {
    filter: none;
}

/* L'avatar Expert IA (fond noir) : blend "screen" sur sombre, "multiply" sur clair */
img[src*="ai_expert"] {
    mix-blend-mode: multiply !important;
}

html.dark-mode img[src*="ai_expert"],
.login-page img[src*="ai_expert"] {
    mix-blend-mode: screen !important;
}

/* ═══════════ TOAST NOTIFICATIONS ═══════════ */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
}
.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    color: var(--text-main);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 1rem;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    font-size: 0.85rem;
    font-weight: 500;
}
.toast.show {
    transform: translateX(0);
    opacity: 1;
}
.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.info { border-left-color: var(--accent-cyan); }

/* ═══════════ LOGIN PAGE ═══════════
   La connexion reste SOMBRE en permanence (comme celle de STATOR CRM),
   indépendamment du thème choisi. Le décor animé (grille, orbes,
   particules) est défini dans index.php ; ici on scope les composants. */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    /* Dynamic viewport height (iOS Safari) */
    padding: 2rem;
    gap: 1.5rem;
    position: relative;
    z-index: 10;
}

.login-card,
.welcome-screen {
    width: 100%;
    max-width: 420px;
    padding: 2.4rem 2.25rem 2rem;
    border-radius: 24px;
    text-align: center;
}

/* Composants scopés login : palette sombre STATOR */
.login-page .login-card,
.login-page .card {
    background: rgba(15, 14, 22, 0.75);
    backdrop-filter: blur(32px) saturate(150%);
    -webkit-backdrop-filter: blur(32px) saturate(150%);
    border: 1px solid rgba(232, 76, 43, 0.18);
    box-shadow:
        0 0 0 1px rgba(232, 76, 43, 0.08) inset,
        0 32px 80px rgba(0, 0, 0, 0.55),
        0 0 60px rgba(232, 76, 43, 0.06);
}

.login-page .card:hover,
.login-page .login-card:hover {
    transform: none;
    border-color: rgba(232, 76, 43, 0.28);
}

.login-page .label {
    color: rgba(255, 255, 255, 0.42);
    font-size: 10.5px;
    letter-spacing: 0.55px;
}

.login-page .form-group:focus-within .label {
    color: rgba(232, 76, 43, 0.85);
}

.login-page .input {
    background: rgba(255, 255, 255, 0.055);
    border: 1.5px solid rgba(255, 255, 255, 0.09);
    color: #fff;
}

.login-page .input::placeholder {
    color: rgba(255, 255, 255, 0.22);
}

.login-page .input:focus {
    border-color: rgba(232, 76, 43, 0.65);
    background: rgba(232, 76, 43, 0.06);
    box-shadow: 0 0 0 3px rgba(232, 76, 43, 0.10);
}

.login-page .btn-primary {
    background: linear-gradient(135deg, #E84C2B 0%, #c43b1f 100%);
    border-radius: 11px;
    box-shadow: 0 4px 22px rgba(232, 76, 43, 0.42);
}

.login-page .btn-primary:hover {
    filter: none;
    box-shadow: 0 8px 30px rgba(232, 76, 43, 0.55), 0 0 0 3px rgba(232, 76, 43, 0.15);
}

.login-page .btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.75);
}

.login-page .btn-ghost:hover {
    background: rgba(232, 76, 43, 0.12);
    border-color: rgba(232, 76, 43, 0.45);
    color: #fff;
}

.login-page h1,
.login-page h2,
.login-page h3,
.login-page h4 {
    color: #fff;
}

.login-page .input-clear,
.login-page .password-toggle {
    color: rgba(255, 255, 255, 0.4);
}

.login-header {
    text-align: center;
}

.brand-icon {
    width: 180px;
    margin: 0 auto 1.5rem;
    transition: var(--transition-smooth);
}

.brand-icon img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(232, 76, 43, 0.25)) brightness(1.1);
}

.login-title {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.95rem;
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.25);
    letter-spacing: 0.05em;
    font-family: var(--font-mono);
}

.password-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.password-toggle:hover {
    color: var(--primary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1.1rem;
    color: var(--text-dim);
    pointer-events: none;
    font-size: 1rem;
}

.input-wrapper .input {
    padding-left: 3rem;
    padding-right: 3rem;
}

.input-wrapper .password-toggle {
    position: absolute;
    right: 0.75rem;
}

/* ═══════════ DASHBOARD LAYOUT ═══════════ */
.dashboard-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    background: var(--bg-elevated);
    border-right: 1px solid var(--glass-border);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    transition: background .35s ease, border-color .35s ease;
}

/* Navigation latérale façon STATOR : items plats, actif = accent plein */
.sidebar .btn-ghost {
    background: transparent;
    border: 1.5px solid transparent;
    color: var(--text-muted);
    box-shadow: none;
}

.sidebar .btn-ghost:hover {
    background: var(--or-l);
    border-color: transparent;
    color: var(--primary);
    transform: none;
}

.sidebar .btn-primary {
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(232, 76, 43, 0.28);
}

.main-content {
    padding: 2.5rem 3rem;
    min-width: 0;
}

/* ═══════════ MOBILE: Header fixe ═══════════ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-height);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    transition: background .35s ease, border-color .35s ease;
}

.mobile-header-logo {
    height: 32px;
    width: auto;
}

.mobile-header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.mobile-header-user {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: right;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════ MOBILE: Bottom Navigation ═══════════ */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-height);
    background: var(--bg-elevated);
    border-top: 1px solid var(--glass-border);
    z-index: 1000;
    /* Safe area for iPhone home bar */
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    transition: background .35s ease, border-color .35s ease;
}

.mobile-bottom-nav-inner {
    display: flex;
    height: 100%;
    align-items: stretch;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font-main);
    text-decoration: none;
    transition: var(--transition-fast);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: 0;
}

.mobile-nav-item.active {
    color: var(--primary);
}

.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 4px 4px;
}

.mobile-nav-item:active {
    transform: scale(0.92);
}

/* Les icônes blanches de la bottom-nav suivent la couleur du thème */
.mobile-nav-item img[src*="_white.svg"] {
    filter: brightness(0) invert(0.28);
}

.mobile-nav-item.active img[src*="_white.svg"] {
    filter: brightness(0) saturate(100%) invert(42%) sepia(57%) saturate(2360%) hue-rotate(348deg) brightness(94%) contrast(93%);
}

html.dark-mode .mobile-nav-item img[src*="_white.svg"] {
    filter: brightness(0) invert(0.65);
}

html.dark-mode .mobile-nav-item.active img[src*="_white.svg"] {
    filter: brightness(0) saturate(100%) invert(42%) sepia(57%) saturate(2360%) hue-rotate(348deg) brightness(94%) contrast(93%);
}

.mobile-nav-icon {
    font-size: 1.35rem;
    line-height: 1;
    transition: transform 0.2s;
}

.mobile-nav-item.active .mobile-nav-icon {
    transform: scale(1.15);
}

.mobile-nav-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

/* ═══════════ Bouton logo mobile (remplace hamburger) ═══════════ */
.mobile-logo-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    height: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
    position: relative;
    z-index: 1050;
}

.mobile-logo-btn img {
    pointer-events: none;
    /* L'image ne bloque pas le clic du bouton parent */
}

.mobile-logo-btn:active {
    opacity: 0.75;
}

/* ═══════════ Bouton fermer sidebar (X rouge) ═══════════ */
.sidebar-close-btn {
    display: none;
    /* masqué sur desktop */
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    background: rgba(220, 38, 38, 0.10);
    border: 1px solid rgba(220, 38, 38, 0.25);
    border-radius: 50%;
    color: var(--error);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.sidebar-close-btn:hover,
.sidebar-close-btn:active {
    background: rgba(220, 38, 38, 0.22);
    transform: scale(1.1);
}

/* ═══════════ Mobile menu toggle — désactivé (logo prend le relais) ═══════════ */
.mobile-menu-toggle {
    display: none !important;
}

/* ═══════════ STATS (cartes KPI STATOR) ═══════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.stat-item {
    background: var(--bg-glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background .35s ease, border-color .35s ease;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-premium);
}

.stat-item:hover {
    border-color: var(--glass-border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.stat-label {
    color: var(--text-dim);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    transition: var(--transition-smooth);
}

/* ═══════════ WEEKLY PROGRESS BAR ═══════════ */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-4);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.75rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #ff8060);
    border-radius: 10px;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35));
    animation: progressShimmer 2s ease-in-out infinite;
}

@keyframes progressShimmer {

    0%,
    100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

/* ═══════════ ANIMATIONS ═══════════ */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-in {
    animation: fadeInSlide 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-in-delay-1 {
    animation: fadeInSlide 0.7s 0.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-in-delay-2 {
    animation: fadeInSlide 0.7s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-in-delay-3 {
    animation: fadeInSlide 0.7s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ═══════════ ALERTS ═══════════ */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-left: 4px solid transparent;
    animation: fadeInSlide 0.5s ease forwards;
    font-size: 0.9rem;
}

.alert-error {
    background: #FEE2E2;
    color: #B91C1C;
    border-left-color: var(--error);
}

.alert-success {
    background: #DCFCE7;
    color: #15803D;
    border-left-color: var(--success);
}

.alert-info {
    background: #DBEAFE;
    color: #1D4ED8;
    border-left-color: var(--accent-cyan);
}

html.dark-mode .alert-error {
    background: rgba(220, 38, 38, 0.14);
    color: #fca5a5;
}

html.dark-mode .alert-success {
    background: rgba(22, 163, 74, 0.14);
    color: #86efac;
}

html.dark-mode .alert-info {
    background: rgba(37, 99, 235, 0.14);
    color: #93c5fd;
}

/* La page de connexion (sombre) garde des alertes translucides */
.login-page .alert-error {
    background: rgba(220, 38, 38, 0.14);
    color: #fca5a5;
}

.login-page .alert-success {
    background: rgba(22, 163, 74, 0.14);
    color: #86efac;
}

/* ═══════════ STATUS BADGE (base commune) ═══════════ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* ═══════════ TOOLTIPS ═══════════ */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    color: #fff;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 100;
    animation: fadeInScale 0.2s ease;
}

/* ═══════════ SELECTION ═══════════ */
::selection {
    background: var(--primary);
    color: #fff;
}

/* ═══════════ FOOTER ═══════════ */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    letter-spacing: 0.05em;
    border-top: 1px solid var(--glass-border);
    margin-top: 3rem;
}

.app-footer a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.app-footer a:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

/* ═══════════ CHECKBOX ═══════════ */
.sync-check,
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ═══════════ FOCUS VISIBLE ═══════════ */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ═══════════ LOADING SPINNER ═══════════ */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(232, 76, 43, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* ════════════════════════════════════════
   RESPONSIVE — TABLETTE (≤1024px)
════════════════════════════════════════ */
@media (max-width: 1024px) {
    .main-content {
        padding: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}


/* ════════════════════════════════════════
   RESPONSIVE — MOBILE (≤768px)
   Redesign complet en app native-like
════════════════════════════════════════ */
@media (max-width: 768px) {

    /* ── Base ── */
    body {
        font-size: 14px;
    }

    /* ── Header mobile ── */
    .mobile-header {
        display: flex;
    }

    /* Bottom Nav mobile */
    .mobile-bottom-nav {
        display: block;
    }

    /* Vider la visibilité de la navbar du bas quand la sidebar latérale est ouverte */
    body.sidebar-is-open .mobile-bottom-nav {
        display: none !important;
    }

    /* ── Masquer la sidebar desktop ── */
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0;
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        width: min(85vw, 300px);
        padding: 1.5rem 1.25rem;
        padding-top: 2rem;
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.12);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1090;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .sidebar-overlay.open {
        display: block;
    }

    /* Afficher le bouton fermeture sidebar */
    .sidebar-close-btn {
        display: flex;
    }

    /* ── Main content ── */
    .main-content {
        padding: 1rem;
        padding-top: calc(var(--mobile-header-height) + 0.75rem);
        padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 0.75rem);
        min-height: 100dvh;
    }

    /* ── Stats grid : 2 colonnes compactes ── */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
        margin-bottom: 1.25rem;
    }

    .stat-item {
        padding: 1rem 0.9rem;
        border-radius: var(--radius-md);
    }

    .stat-label {
        font-size: 0.65rem;
        margin-bottom: 0.3rem;
    }

    .stat-value {
        font-size: 1.65rem;
    }

    /* ── Cards ── */
    .card {
        padding: 1.25rem;
        border-radius: var(--radius-lg);
    }

    /* ── Login page ── */
    .login-page {
        padding: 1.25rem;
        gap: 1.25rem;
    }

    .login-card {
        padding: 1.75rem 1.5rem;
        border-radius: 20px;
    }

    .login-title {
        font-size: 1.8rem;
    }

    .login-subtitle {
        font-size: 0.85rem;
    }

    /* ── Inputs plus grands (touch-friendly) ── */
    .input {
        padding: 1rem 1.25rem;
        font-size: 16px;
        /* Prevent iOS zoom */
        border-radius: 10px;
    }

    .input-wrapper .input {
        padding-left: 3.25rem;
        /* Espace pour l'icône de login */
        padding-right: 3.25rem;
        /* Espace pour l'œil ou l'icône droite */
    }

    .input-wrapper .p-password {
        padding-left: 1rem;
        /* Les champs MDP profil n'ont pas d'icône à gauche */
    }

    /* ── Boutons ── */
    .btn {
        font-size: 0.8rem;
        padding: 0.9rem 1.5rem;
        min-height: 48px;
        /* Touch target iOS/Material */
    }

    /* ── Graphiques : 1 colonne sur mobile ── */
    .charts-grid {
        grid-template-columns: 1fr !important;
    }

    /* ── Formulaire de saisie : 1 colonne ── */
    .saisie-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    /* ── Grille 2 colonnes profile → 1 colonne ── */
    .profile-grid-2 {
        grid-template-columns: 1fr !important;
    }

    /* ── Grille 2 cols mot de passe → 1 colonne (FIX screenshot) ── */
    #passwordForm>div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* ── Tables : scroll horizontal ── */
    .table-scroll-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
        margin: 0 -0.25rem;
    }

    /* ── Alerts ── */
    .alert {
        padding: 0.85rem 1rem;
        font-size: 0.82rem;
    }

    /* ── App footer ── */
    .app-footer {
        margin-top: 1.5rem;
        padding: 1.5rem 1rem;
        font-size: 0.65rem;
    }

    /* ── Progress bar sidebar (masquée sur mobile, dans bottom nav) ── */
    .sidebar-progress-mobile-hint {
        display: block !important;
    }
}


/* ════════════════════════════════════════
   RESPONSIVE — PETIT MOBILE (≤390px)
   Appareils compacts (iPhone SE, 13 Mini)
════════════════════════════════════════ */
@media (max-width: 390px) {

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .card {
        padding: 1rem;
    }

    .login-card {
        padding: 1.25rem 1rem;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .btn {
        min-height: 50px;
        font-size: 0.75rem;
    }

    /* Masquer le texte des boutons sidebar pour gagner de l'espace */
    .mobile-nav-label {
        font-size: 0.55rem;
    }

    .mobile-nav-icon {
        font-size: 1.2rem;
    }
}


/* ════════════════════════════════════════
   iOS SAFE AREA + PWA FIXES
════════════════════════════════════════ */
@supports (-webkit-touch-callout: none) {
    body {
        min-height: -webkit-fill-available;
    }

    /* Empêcher le bouncing scroll sur iOS en mode PWA */
    .main-content {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* Mode plein écran PWA (iOS/Android standalone) */
@media (display-mode: standalone) {
    .mobile-header {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--mobile-header-height) + env(safe-area-inset-top));
    }

    .main-content {
        padding-top: calc(var(--mobile-header-height) + env(safe-area-inset-top) + 0.75rem);
    }

    .mobile-bottom-nav {
        height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    }
}

/* ═══════════ COMPAT ANCIEN THÈME ═══════════
   L'ancienne classe html.light-mode correspond désormais au thème par
   défaut : on la neutralise pour les clients qui l'ont encore en cache. */
html.light-mode body {
    --bg-main: #F0EFED;
}

/* ═══════════ PREMIUM ICONS ═══════════ */
.premium-icon {
    height: 26px;
    width: auto;
    vertical-align: middle;
    transition: transform 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
    background: transparent !important; /* Garantie de fond transparent */
}

.sidebar .premium-icon,
.card .premium-icon,
.table .premium-icon,
.mobile-bottom-nav .premium-icon,
.btn-ghost .premium-icon {
    mix-blend-mode: normal;
}

.sidebar .premium-icon {
    height: 30px;
    margin-right: 12px;
}

.mobile-nav-icon .premium-icon {
    height: 40px;
}

.action-icon {
    height: 32px !important;
}

.btn-ghost:hover .premium-icon {
    transform: scale(1.15);
}
/* ----------- AUTOCOMPLETE DROPDOWN ----------- */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    z-index: 2000;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 5px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.autocomplete-item {
    padding: 0.8rem 1.25rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--or-l);
    color: var(--primary);
}

/* ═══════════ COCKPIT SPECIALS ═══════════ */
.stat-card {
    border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.info { border-left-color: var(--accent-cyan); }

.premium-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: rgba(232, 76, 43, 0.10);
    color: var(--primary);
    border: 1px solid rgba(232, 76, 43, 0.22);
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 10px rgba(232, 76, 43, 0.08); }
    50% { box-shadow: 0 0 25px rgba(232, 76, 43, 0.18); }
    100% { box-shadow: 0 0 10px rgba(232, 76, 43, 0.08); }
}

.cockpit-pulse {
    animation: pulse-glow 3s infinite ease-in-out;
}

/* --- LOADING ANIMATION --- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spin {
    animation: spin 1s linear infinite;
}

/* ════════════════════════════════════════════════════════════════
   ZONE DE GEL PDF — NE PAS MODIFIER
   Le rapport PDF est capturé par html2canvas dans #pdf-full-wrapper.
   On y fige les ANCIENNES valeurs de variables pour que le rendu du
   PDF reste strictement identique, quel que soit le thème de l'app.
════════════════════════════════════════════════════════════════ */
#pdf-full-wrapper {
    --primary: #ffb300;
    --primary-light: #ffca28;
    --primary-glow: rgba(255, 179, 0, 0.35);
    --primary-subtle: rgba(255, 179, 0, 0.08);
    --secondary: #0a1e3d;
    --bg-main: #0a0e1b;
    --bg-elevated: #111827;
    --bg-glass: rgba(17, 24, 39, 0.85);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text: #000;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent-cyan: #0ea5e9;
    --error: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;
}

#pdf-full-wrapper img {
    filter: none !important;
    mix-blend-mode: normal !important;
}
