:root {
    /* --- COULEURS & THEMES --- */
    --primary-color: #4318ff; /* Valeur par défaut modifiable par JS */
    
    /* Theme Light */
    --bg-body: #f4f7fe;
    --bg-card: #ffffff;
    --text-main: #2b3674;
    --text-muted: #a3aed0;
    --border: #e2e8f0;
    --nav-bg: #111c44;
    --shadow: 0px 18px 40px rgba(112, 144, 176, 0.12);
    --input-bg: #f4f7fe;

    /* Variables de dimensions & transitions */
    --radius-main: 20px;
    --radius-sm: 10px;
    --transition-fast: 0.2s ease;
    --transition-med: 0.3s ease-in-out;
}

[data-theme="dim"] {
    --bg-body: #1a1c2e;
    --bg-card: #24294d;
    --text-main: #ffffff;
    --text-muted: #a3aed0;
    --border: #33396b;
    --nav-bg: #0b1437;
    --shadow: 0px 18px 40px rgba(0, 0, 0, 0.2);
    --input-bg: #1a1c2e;
}

[data-theme="dark"] {
    --bg-body: #0b1437;
    --bg-card: #111c44;
    --text-main: #ffffff;
    --text-muted: #8f9bba;
    --border: #1b254b;
    --nav-bg: #0b1437;
    --shadow: none;
    --input-bg: #0b1437;
}

/* --- RESET & GLOBAL --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-font-smoothing: antialiased; /* Rendu de police plus net sur Mac */
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar Design Soft (Webkit) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
    opacity: 0.5;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

body, html {
    overflow-x: hidden; 
    width: 100%;
    max-width: 100%;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    min-height: 100vh;
    /* Ajustement dynamique pour la nav mobile et safe area iOS */
    /* AJOUT : Padding top augmenté pour compenser le Header Fixed */
    padding-top: 90px; 
    padding-bottom: calc(90px + env(safe-area-inset-bottom)); 
}

a { text-decoration: none; color: inherit; transition: var(--transition-fast); }
ul { list-style: none; }
button { font-family: inherit; }

/* --- HEADER (FIXÉ & AMÉLIORÉ) --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px; /* Padding réduit pour gagner de la place */
    
    /* MODIFICATION CRITIQUE : POSITION FIXED */
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    
    z-index: 1500; /* Z-index très haut pour rester au dessus */
    background: rgba(244, 247, 254, 0.95); /* Plus opaque pour la lisibilité */
    
    /* Effet de flou pour la transparence (Glassmorphism) */
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    transition: padding var(--transition-med);
    border-bottom: 1px solid rgba(0,0,0,0.05); /* Légère séparation */
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

/* Support dark mode header background */
[data-theme="dark"] .main-header, [data-theme="dim"] .main-header {
    background: rgba(11, 20, 55, 0.95);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 1; /* Autorise le rétrécissement */
    min-width: 0; /* Important pour que le flexbox ne déborde pas */
    max-width: 65%; 
}

.logo-circle {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0; /* Le logo ne s'écrase jamais */
}

.header-left h1 {
    font-size: clamp(0.9rem, 1.5vw, 1.1rem); /* Taille de police dynamique */
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Ajoute "..." si ça déborde */
}
.header-left span { font-weight: 800; }

.header-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 8px 20px;
    border-radius: 30px;
    box-shadow: var(--shadow);
    flex-wrap: nowrap; /* Garde les outils sur une ligne */
    flex-shrink: 0; /* Les outils ne s'écrasent pas */
}

.header-tools i {
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.header-tools i:hover { color: var(--primary-color); transform: scale(1.1); }

.avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

/* --- DROPDOWNS --- */
.dropdown-wrapper, .nav-dropdown-wrapper { position: relative; display: flex; align-items: center; }

.drop-content {
    display: none;
    position: absolute;
    top: 140%;
    right: 0;
    background: var(--bg-card);
    min-width: 200px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 1000;
    border: 1px solid var(--border);
    overflow: hidden;
    padding: 5px 0;
}

.drop-content.show { display: block; animation: slideDown 0.2s ease-out; }

.drop-content a {
    display: block;
    padding: 12px 20px;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: 0.2s;
}

.drop-content a:hover { background: var(--bg-body); color: var(--primary-color); }

/* Menu Palette Spécifique */
.drop-content.color-selector {
    padding: 15px;
    display: none; 
    gap: 10px;
    justify-content: center;
    min-width: auto;
    flex-wrap: wrap; /* Sécurité pour petit écrans */
}
.drop-content.color-selector.show { display: flex; }

.color-opt {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(0,0,0,0.05);
    transition: transform 0.2s;
}
.color-opt:hover { transform: scale(1.2); }

/* --- NAVIGATION DESKTOP --- */
.desktop-nav {
    margin: 0 30px 25px;
    background: var(--nav-bg);
    border-radius: 16px;
    padding: 0 20px;
}

/* Cache scrollbar nav desktop */
.desktop-nav::-webkit-scrollbar { height: 0px; background: transparent; }

.nav-links { display: flex; align-items: center; }

.nav-item {
    background: none;
    border: none;
    padding: 18px 25px;
    color: white;
    font-size: 0.95rem;
    opacity: 0.7;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.3s;
    position: relative;
    flex-shrink: 0; /* Empêche le texte de passer à la ligne */
}

.nav-item:hover, .nav-item.active { opacity: 1; }
.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 25px;
    right: 25px;
    height: 4px;
    background: white;
    border-radius: 4px 4px 0 0;
}

/* --- DASHBOARD GRID & KPI --- */
.dashboard-grid {
    padding: 0 30px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.kpi-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.kpi-card {
    min-height: 130px; /* Utilisation de min-height pour la responsivité textuelle */
    height: auto;
    border-radius: 20px;
    padding: 25px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.kpi-card:hover { transform: translateY(-5px); box-shadow: 0 20px 40px rgba(0,0,0,0.15); }

.kpi-card p { font-size: 0.9rem; opacity: 0.9; margin-bottom: 5px; z-index: 1; position: relative;}
.kpi-card h3 { font-size: 2rem; font-weight: 700; margin: 0; z-index: 1; position: relative; line-height: 1.2; }
.dual-val { font-size: 0.85rem; margin-top: 8px; display: flex; gap: 8px; opacity: 0.9; z-index: 1; position: relative; flex-wrap: wrap;}

/* Gradients */
.bg-blue { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.bg-orange { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); }
.bg-red { background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%); }
.bg-cyan { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }

/* Patterns de fond */
.pattern {
    position: absolute;
    right: -10px;
    bottom: -10px;
    width: 80px;
    height: 80px;
    opacity: 0.2;
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
}
.mountains { background-image: url('https://cdn-icons-png.flaticon.com/512/3014/3014275.png'); }
.buildings { background-image: url('https://cdn-icons-png.flaticon.com/512/888/888063.png'); }
.clouds { background-image: url('https://cdn-icons-png.flaticon.com/512/414/414927.png'); }
.waves { background-image: url('https://cdn-icons-png.flaticon.com/512/3313/3313498.png'); }

/* --- MAIN LAYOUT (3 Colonnes) --- */
.data-layout {
    display: grid;
    grid-template-columns: 1.4fr 1.2fr 1fr;
    gap: 25px;
    align-items: start; /* Évite l'étirement des cartes */
}

/* Card Styles */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-main);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    border: 1px solid transparent; 
    width: 100%;
    /* Gestion overflow pour charts */
    overflow: hidden; 
}

/* Headers de cartes */
.clickable-header { cursor: pointer; transition: 0.2s; }
.clickable-header:hover { border-color: var(--primary-color); }

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap; /* Sécurité responsivité */
    gap: 10px;
}

.card-head h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-head i {
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
    font-size: 1.1rem;
}
.card-head i:hover { color: var(--primary-color); }

/* --- LISTES & ITEMS --- */
.list-std { width: 100%; }

.list-std li {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-main);
}

.list-std li:last-child { border-bottom: none; }

.list-std li > span:first-child, 
.list-std li > div:first-child { 
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden; /* Pour gérer le texte trop long */
}

/* Gestion du text overflow */
.list-std li span, .list-std li div {
    max-width: 100%;
}

/* Icons colorés */
.text-primary { color: var(--primary-color); margin-right: 10px; font-size: 1.1rem; flex-shrink: 0; }
.text-red { color: #ff0844; margin-right: 10px; font-size: 1.1rem; flex-shrink: 0; }

/* Checkbox Style */
.check {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

.check.active {
    background: #05cd99;
    border-color: #05cd99;
    color: white;
}

.check.active::after {
    content: '✓';
    font-size: 12px;
    font-weight: bold;
}

/* Badges pourcentage */
.badge {
    background: var(--input-bg);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

/* No margin utility */
.no-margin { margin: 0 10px 0 0 !important; }

/* --- INPUTS & FORMS (CORRIGÉ & MOBILE READY) --- */
.add-todo {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
}

.add-todo input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 15px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: 0.2s;
    min-width: 0; /* Important pour Flexbox */
}

.add-todo input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 24, 255, 0.1);
}

.add-todo button {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    flex-shrink: 0;
}

.add-todo button:hover { background: #3311cc; transform: translateY(-2px); }

/* --- CHART CONTAINERS --- */
.chart-box {
    position: relative;
    /* Remplacement de height fixe par min-height pour flexibilité */
    min-height: 200px;
    width: 100%;
    /* Permet au canvas de s'adapter sans déborder */
    display: flex; 
    align-items: center;
    justify-content: center;
}
.doughnut-fix {
    min-height: 180px; 
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Important pour que les charts ne cassent pas la largeur sur mobile */
canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* --- MOBILE NAVIGATION (OPTIMIZED) --- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95); /* Opacité augmentée pour masquer le fond */
    /* Mode sombre auto géré par les variables si appliquées au parent */
    [data-theme="dark"] & { background: rgba(17, 28, 68, 0.95); }
    [data-theme="dim"] & { background: rgba(36, 41, 77, 0.95); }
    
    display: none; 
    /* MODIFICATION MAJEURE : Meilleure gestion de l'espacement */
    justify-content: space-evenly; 
    padding: 12px 10px; /* Un peu de padding sur les côtés */
    
    /* GESTION SAFE AREA (Encoche iPhone) */
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    z-index: 1900; /* Juste en dessous des modales */
    border-top: 1px solid var(--border);
    
    /* Glassmorphism */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.m-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.3s ease;
    /* Zone de clic élargie pour le doigt */
    text-align: center;
    position: relative; /* Pour le z-index */
    z-index: 1901;

    /* MODIFICATION : FLUIDITÉ ET CONTRAINTES */
    /* clamp(min, ideal, max) permet de rétrécir proprement */
    font-size: clamp(0.6rem, 2.5vw, 0.75rem); 
    padding: 5px 0; 
    
    /* Gère la largeur max pour ne pas étirer sur les gros téléphones */
    flex: 1; 
    min-width: 0;
    max-width: 80px; /* Empêche les boutons de devenir énormes en paysage */
    
    /* Ajout de bordures arrondies pour l'effet active */
    border-radius: 12px;
    
    /* CORRECTION IOS: Force la reconnaissance du clic */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* EFFET CLIC (Feedback Tactile) */
.m-nav:active {
    transform: scale(0.95);
}

.m-nav i { 
    /* L'icône ne dépassera jamais 1.5rem et rétrécira jusqu'à 1.1rem */
    font-size: clamp(1.1rem, 6vw, 1.5rem); 
    margin-bottom: 2px; 
    transition: transform 0.2s;
}

/* ETAT ACTIF (Amélioré avec un fond) */
.m-nav.active { 
    color: var(--primary-color); 
    font-weight: 700;
    /* Fond subtil pour montrer la sélection */
    background: rgba(67, 24, 255, 0.08); 
}

/* --- RESPONSIVE MEDIA QUERIES (COMPLETES) --- */

@media (max-width: 1400px) {
    .dashboard-grid { max-width: 100%; }
}

@media (max-width: 1200px) {
    /* Passage à 2 colonnes pour le layout principal */
    .data-layout { grid-template-columns: 1fr 1fr; }
    /* La colonne de droite (souvent la 3eme) passe en dessous */
    .col-section:last-child { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
}

@media (max-width: 992px) {
    /* Header simplifié */
    .main-header { padding: 12px 15px; } /* Encore moins de padding sur mobile */
    .header-tools { padding: 8px 15px; gap: 8px; }
    
    /* Navigation PC disparait */
    .desktop-nav { display: none; }
    
    /* Apparition Nav Mobile */
    .mobile-bottom-nav { display: flex; }
    
    /* KPI en 2x2 */
    .kpi-section { grid-template-columns: 1fr 1fr; gap: 15px; }
    
    /* Layout complet en 1 colonne fluide */
    .data-layout { display: flex; flex-direction: column; gap: 20px; }
    .col-section:last-child { display: flex; flex-direction: column; }
    
    .dashboard-grid { padding: 0 15px; } /* Marges latérales réduites */
    
    /* Modales full width safe */
    .modal-content { width: 95%; margin-bottom: 80px; }
    
    /* Ajustement titre header */
    .header-left h1 { font-size: 1rem; }
    .logo-circle { width: 35px; height: 35px; font-size: 1rem; }
}

@media (max-width: 480px) {
    .kpi-section { grid-template-columns: 1fr; } /* 1 KPI par ligne sur très petit écran */
    .kpi-card { height: auto; padding: 20px; min-height: 110px; }
    .kpi-card h3 { font-size: 1.8rem; }
    
    /*Header encore plus compact*/
    .header-tools { padding: 6px 10px; }
    .header-left { max-width: 60%; }
    .header-left h1 { display: none; } /* On cache le titre long sur tout petit écran si besoin, ou on réduit */
    
    /* Pour éviter le zoom auto sur iPhone */
    input, select, textarea { font-size: 16px !important; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- STYLES SPECIFIQUES PAGE STOCKS --- */

/* Action Bar (Recherche & Filtres) */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    gap: 15px;
    flex-wrap: wrap; /* Indispensable pour responsive */
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-body);
    padding: 10px 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    flex: 1;
    min-width: 250px;
}

.search-box input {
    border: none;
    background: transparent;
    margin-left: 10px;
    width: 100%;
    outline: none;
    color: var(--text-main);
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap; /* Boutons passent à la ligne si besoin */
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.2s;
    white-space: nowrap;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-2px); }

.filter-select {
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    max-width: 100%;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Tableaux Modernes */
.table-wrapper { padding: 0; overflow: hidden; } 
.table-wrapper .card-head { margin: 20px 20px 10px; }

.responsive-table {
    width: 100%;
    overflow-x: auto; /* Scroll horizontal sur mobile */
    -webkit-overflow-scrolling: touch; /* Scroll fluide iOS */
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* Force le scroll sur petit écran pour garder la structure */
}

th {
    text-align: left;
    padding: 15px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap; /* Empêche les titres de se casser */
}

td {
    padding: 15px 20px;
    color: var(--text-main);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap; /* Lignes propres sur mobile */
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,0.01); }

/* Item Info (Image + Texte) */
.item-info { display: flex; align-items: center; gap: 12px; }
.item-img {
    width: 40px; height: 40px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.bg-light-blue { background: rgba(67, 24, 255, 0.1); color: var(--primary-color); }
.bg-light-orange { background: rgba(246, 211, 101, 0.1); color: #f39c12; }
.bg-light-red { background: rgba(255, 8, 68, 0.1); color: #ff0844; }

.item-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item-code { display: block; font-size: 0.75rem; color: var(--text-muted); }

/* Status Badges */
.status-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    white-space: nowrap;
}
.status-badge.success { background: rgba(5, 205, 153, 0.1); color: #05cd99; }
.status-badge.warning { background: rgba(243, 156, 18, 0.1); color: #f39c12; }
.status-badge.danger { background: rgba(255, 8, 68, 0.1); color: #ff0844; }

.action-icons i {
    cursor: pointer;
    margin-right: 10px;
    font-size: 1rem;
    transition: 0.2s;
}
.action-icons i:hover { transform: scale(1.2); }

/* Responsive Specifique Table */
@media (max-width: 768px) {
    .action-bar { flex-direction: column; align-items: stretch; }
    .action-buttons { justify-content: space-between; }
    .search-box { width: 100%; min-width: 0; }
}

/* --- MODAL STYLES (AMELIORÉS) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none; 
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    backdrop-filter: blur(4px);
    /* Gestion du scroll interne si la modale est trop grande */
    padding: 20px; 
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.modal-overlay.show {
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    width: 90%;
    max-width: 700px; 
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s;
    position: relative;
    border: 1px solid var(--border);
    
    max-height: 85vh; /* Un peu moins que 90 pour laisser place à la nav mobile au cas où */
    overflow-y: auto; 
    display: flex;
    flex-direction: column;
}

/* On s'assure que le footer reste accessible ou scrollable */
.modal-footer {
    margin-top: auto; 
    padding-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h3 { font-size: 1.2rem; color: var(--text-main); line-height: 1.4; }

.close-modal {
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    padding: 5px;
}
.close-modal:hover { color: #ff0844; }

/* Grid formulaire */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Responsive Grid Form */
@media (max-width: 600px) {
    .form-grid { grid-template-columns: 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-group input, .form-group select {
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    outline: none;
    width: 100%;
}

.form-group input:focus { border-color: var(--primary-color); }

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
}
.btn-secondary:hover { background: var(--bg-body); color: var(--text-main); }

/* --- PAGE PROJETS --- */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.project-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 220px;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}

.p-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.p-type {
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
}

.bg-light-green { background: rgba(5, 205, 153, 0.1); color: #05cd99; }

.client-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 5px 0 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.p-dates {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* Progress Bar */
.p-progress { margin-bottom: 20px; }
.flex-between { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 5px; font-weight: 600; }
.progress-track {
    height: 8px;
    background: var(--bg-body);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.5s ease;
}
.bg-red { background: #ff0844; }
.bg-green { background: #05cd99; }
.text-green { color: #05cd99; }

/* Footer Card */
.p-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.team-avatars { display: flex; }
.team-avatars img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
    margin-left: -10px;
}
.team-avatars img:first-child { margin-left: 0; }

.p-budget { font-weight: 700; color: var(--text-main); }

/* --- MODAL DETAIL PROJET (Tabs) --- */
.large-modal { max-width: 800px; }

.modal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto; /* Scroll horizontal si trop d'onglets */
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

/* Liste des taches dans le modal */
.task-list-detail { list-style: none; }
.task-list-detail li {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--bg-body);
    border-radius: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap; /* Sécurité mobile */
}

.task-check { margin-right: 15px; font-size: 1.2rem; cursor: pointer; }
.task-content { flex: 1; min-width: 200px; }
.task-title { display: block; font-weight: 600; font-size: 0.9rem; word-break: break-word; }
.task-title.strike { text-decoration: line-through; opacity: 0.6; }
.task-assignee { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.task-assignee img { width: 18px; height: 18px; border-radius: 50%; }

/* Finance Summary */
.finance-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.fin-box { padding: 15px; border-radius: 12px; text-align: center; background: var(--bg-body); }
.fin-box span { font-size: 0.8rem; opacity: 0.8; display: block; }
.fin-box h4 { font-size: 1.2rem; margin-top: 5px; word-break: break-word; }

.mt-20 { margin-top: 20px; }
.mb-15 { margin-bottom: 15px; }
.text-sm { font-size: 0.85rem; }
.simple-table { width: 100%; margin-top: 10px; border-collapse: collapse; }
.simple-table td { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Mobile Responsive Projets */
@media (max-width: 768px) {
    .project-grid { grid-template-columns: 1fr; }
    .finance-summary { grid-template-columns: 1fr; }
}

/* --- STACKED MODAL (Modale sur Modale) --- */
.modal-overlay.stacked {
    z-index: 2050; 
    background: rgba(0, 0, 0, 0.3); 
}

/* Petit bouton style pour le header du modal */
.btn-xs {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
}
.btn-xs:hover { opacity: 0.9; }

/* --- STYLES VENTES SPECIFIQUES --- */

/* Table de lignes de facture (Dans le modal) */
.invoice-lines-wrapper {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-body);
    padding: 10px;
    overflow-x: auto; /* Important pour les petits écrans */
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px; /* Force scroll si trop petit */
}

.invoice-table th {
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 5px 10px;
    white-space: nowrap;
}

.invoice-table td {
    padding: 5px;
}

.invoice-table input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
}

.invoice-table input:focus {
    border-color: var(--primary-color);
}

.mt-10 { margin-top: 10px; }
.cursor-pointer { cursor: pointer; }

/* Affichage du Total en bas de modal */
.total-display {
    background: rgba(67, 24, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--primary-color);
    flex-wrap: wrap; /* Sécurité mobile */
}

.total-display span { font-weight: 600; color: var(--text-main); }
.total-display .amount { font-size: 1.2rem; color: var(--primary-color); font-weight: 800; }

/* Status Badges Ventes specifiques */
.font-bold { font-weight: 700; }
.text-orange { color: #f39c12; }
.text-green { color: #05cd99; }

/* Ajustement boutons actions */
.action-icons i { margin: 0 5px; font-size: 1.1rem; }

/* --- STYLES CAISSE SPECIFIQUES --- */

/* Montants positifs et négatifs dans le tableau */
.amount-in {
    color: #05cd99;
    font-weight: 700;
    white-space: nowrap;
}

.amount-out {
    color: #ff0844;
    font-weight: 700;
    white-space: nowrap;
}

/* Date filter inputs */
.date-filter {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    cursor: pointer;
}

/* --- NOUVEAUX STYLES CAISSE --- */

.input-green {
    border-color: #05cd99 !important;
    color: #05cd99;
    font-weight: 700;
}

.bg-green { background-color: #05cd99 !important; }
.bg-green:hover { background-color: #04b385 !important; }

.date-filters-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-body);
    padding: 8px 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    flex-wrap: wrap; /* Responsive */
}

.flex-gap { display: flex; gap: 10px; flex-wrap: wrap; }
.print-header { display: none; } /* Caché par défaut */

/* --- STYLES D'IMPRESSION CORRIGÉS --- */
@media print {
    /* 1. On cache physiquement tout ce qui gêne */
    .main-header, 
    .desktop-nav, 
    .mobile-bottom-nav, 
    .kpi-section, 
    .action-bar, 
    .modal-overlay,
    .no-print,
    .btn-icon,        
    .flex-gap         
    {
        display: none !important;
    }

    /* 2. Reset marges et fonds */
    body, html, .app-container, .dashboard-grid {
        background: white !important;
        height: auto !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        display: block !important;
    }

    /* 3. Cible le tableau spécifique */
    .table-wrapper, #printable-journal {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        display: block !important;
    }

    /* 4. Titre visible */
    .card-head {
        border-bottom: 2px solid #000 !important;
        margin-bottom: 20px !important;
        padding-bottom: 10px !important;
        justify-content: center !important; 
    }
    
    .card-head h4 {
        font-size: 1.5rem !important;
        color: black !important;
        text-align: center;
    }

    /* 5. Affichage de l'entête d'impression (Date) */
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 30px;
    }
    .print-header h2 { font-size: 24px; margin: 0; }
    .print-header p { font-size: 12px; color: #555; }

    /* 6. Le Tableau en Noir et Blanc forcé */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 12px !important;
    }

    th {
        background-color: #f0f0f0 !important;
        color: black !important;
        font-weight: bold !important;
        border: 1px solid #000 !important;
        -webkit-print-color-adjust: exact; 
    }

    td {
        color: black !important;
        border: 1px solid #000 !important;
        padding: 8px 4px !important;
        white-space: normal !important; /* Autorise le retour à la ligne pour impression */
    }

    .amount-in { color: black !important; font-weight: bold; } 
    .amount-out { color: black !important; font-weight: bold; }
    .amount-in::before { content: "+ "; }
    
    .badge {
        border: 1px solid #000;
        background: transparent !important;
        color: #000 !important;
        padding: 2px 5px;
    }
}

/* --- NOUVEAU STYLE MODAL CLOTURE --- */
.closing-header {
    text-align: center;
    margin-bottom: 20px;
}
.closing-date {
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--bg-body);
    padding: 5px 15px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 15px;
}

/* Grille des totaux */
.closing-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .closing-stats { grid-template-columns: 1fr; }
}

.stat-item {
    background: var(--bg-body);
    padding: 10px;
    border-radius: 12px;
}
.stat-item span { display: block; font-size: 0.75rem; color: var(--text-muted); }
.stat-item strong { display: block; font-size: 1rem; margin-top: 5px; }

/* Boite Solde Théorique */
.theo-box {
    background: rgba(67, 24, 255, 0.05);
    border: 2px dashed var(--primary-color);
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    margin-bottom: 25px;
}
.theo-label { color: var(--primary-color); font-weight: 700; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }
.theo-amount { font-size: 2rem; font-weight: 800; color: var(--text-main); margin-top: 5px; display: block; }

/* Input géant pour le comptage */
.count-input-wrapper { margin-bottom: 20px; }
.count-label { display: block; font-weight: 600; margin-bottom: 10px; color: var(--text-main); }
.big-input {
    width: 100%;
    font-size: 1.8rem; 
    padding: 15px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 15px;
    background: var(--bg-body);
    color: var(--text-main);
    font-weight: 700;
    transition: 0.3s;
}
.big-input:focus { border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 4px rgba(67, 24, 255, 0.1); }

/* Zone d'écart dynamique */
.gap-alert {
    padding: 15px;
    border-radius: 12px;
    display: none; 
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease-out;
}
.gap-alert.success { background: rgba(5, 205, 153, 0.15); color: #05cd99; border: 1px solid #05cd99; }
.gap-alert.danger { background: rgba(255, 8, 68, 0.15); color: #ff0844; border: 1px solid #ff0844; }
.gap-alert.neutral { background: var(--bg-body); color: var(--text-muted); border: 1px solid var(--border); }


/* --- STYLES CRM / CLIENTS --- */

.avatar-sm {
    width: 35px; height: 35px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.avatar-lg {
    width: 60px; height: 60px; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); flex-shrink: 0;
}

.contact-info { display: flex; flex-direction: column; font-size: 0.8rem; color: var(--text-muted); }
.contact-info span { display: flex; align-items: center; gap: 5px; }

/* Modal Header Client */
.client-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.client-header-info h3 { margin: 0; display: flex; align-items: center; gap: 10px; }

/* Stats Grid dans le Modal */
.client-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}
@media (max-width: 600px) { .client-stats-grid { grid-template-columns: 1fr; } }

.stat-box {
    background: var(--bg-body);
    padding: 15px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-box i { font-size: 1.5rem; flex-shrink: 0; }
.stat-box div { display: flex; flex-direction: column; }
.stat-box span { font-size: 0.75rem; color: var(--text-muted); }
.stat-box strong { font-size: 1.1rem; }

/* Info Groups (Vue Detail) */
.info-group { margin-bottom: 10px; }
.info-group label { font-weight: 600; color: var(--text-muted); margin-right: 5px; font-size: 0.9rem; }
.info-group a { color: var(--primary-color); text-decoration: none; }
.note-box {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #5b4600;
    margin-top: 5px;
    word-break: break-word;
}

/* Mini Projet Card */
.project-mini-card {
    background: var(--bg-body);
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
}
.project-mini-card:hover { border-color: var(--primary-color); }
.pm-header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.pm-bar { height: 6px; background: #ddd; border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.pm-fill { height: 100%; background: var(--primary-color); }
.pm-footer { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 0.8rem; }

/* --- STYLE MODAL COMMUNICATION --- */

.channel-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.channel-option {
    flex: 1;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: 0.3s;
    background: var(--bg-body);
    color: var(--text-muted);
}

.channel-option i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.channel-option span { font-weight: 600; }

.channel-option.active {
    border-color: var(--primary-color);
    background: rgba(67, 24, 255, 0.05);
    color: var(--primary-color);
}

.channel-option:hover {
    border-color: var(--primary-color);
}

.attachment-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: 0.2s;
}
.attachment-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* --- STYLES SETTINGS / PARAMETRES --- */

.settings-container {
    padding: 0;
    overflow: hidden;
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-body);
    padding: 0 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.set-tab {
    padding: 18px 25px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.set-tab:hover { color: var(--primary-color); }

.set-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.settings-content {
    padding: 30px;
    flex: 1;
    overflow-y: auto; /* Scroll interne si nécessaire */
}

.set-content { display: none; animation: fadeIn 0.3s; }
.set-content.active { display: block; }
.set-content h3 { margin-bottom: 20px; color: var(--text-main); }

/* Layout Profil */
.profile-layout {
    display: flex;
    gap: 40px;
}

.profile-pic-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 200px;
}

.big-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--border);
}

.profile-form { flex: 1; max-width: 600px; }

/* Badge Rôles */
.badge.purple { background: rgba(112, 72, 232, 0.1); color: #7048e8; }
.badge.blue { background: rgba(67, 24, 255, 0.1); color: #4318ff; }
.badge.orange { background: rgba(243, 156, 18, 0.1); color: #f39c12; }

/* Upload Logo Box */
.logo-upload-box {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}
.logo-upload-box:hover { border-color: var(--primary-color); color: var(--primary-color); }
.logo-upload-box i { font-size: 2rem; margin-bottom: 10px; display: block; }

/* System Actions */
.system-actions {
    display: grid;
    gap: 15px;
}
.sys-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-body);
}
.sys-box i { font-size: 1.5rem; margin-right: 15px; }
.sys-box div { flex: 1; }
.sys-box strong { display: block; color: var(--text-main); }
.sys-box p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.sys-box.danger { border-color: rgba(255, 8, 68, 0.3); background: rgba(255, 8, 68, 0.05); }

/* Mobile */
@media (max-width: 768px) {
    .profile-layout { flex-direction: column; align-items: center; }
    .profile-pic-section { width: 100%; margin-bottom: 20px; }
    .sys-box { flex-direction: column; text-align: center; gap: 15px; }
    .sys-box i { margin: 0; }
}

/* --- BOUTON RETOUR MOBILE --- */
.mobile-back-btn {
    display: none; 
    width: 35px;
    height: 35px;
    background: var(--bg-card);
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    box-shadow: var(--shadow);
    margin-right: 15px;
    font-size: 1rem;
    transition: 0.2s;
    text-decoration: none;
}

.mobile-back-btn:active {
    transform: scale(0.95);
    background: var(--primary-color);
    color: white;
}

@media (max-width: 992px) {
    .mobile-back-btn {
        display: flex; 
    }
    
    .header-left {
        gap: 5px; 
    }
}

/* --- PAGE LOGIN / AUTH --- */

.auth-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background: var(--bg-body);
}

.auth-banner {
    width: 45%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #2b00d6 100%);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 40px;
    overflow: hidden;
}

.auth-content {
    z-index: 2;
    max-width: 400px;
    text-align: center;
}
.auth-content h2 { font-size: 2.5rem; margin-bottom: 15px; }
.auth-content p { font-size: 1rem; opacity: 0.8; line-height: 1.6; }

.big-logo {
    width: 80px; height: 80px; font-size: 2.5rem; 
    background: rgba(255,255,255,0.2); 
    border: 2px solid rgba(255,255,255,0.3);
    margin: 0 auto 20px;
    display: flex; align-items: center; justify-content: center; border-radius: 50%;
}

.auth-pattern {
    position: absolute;
    width: 100%; height: 100%;
    background-size: cover;
    opacity: 0.15;
    z-index: 1;
}

.glass-effect {
    margin-top: 50px;
    display: flex;
    gap: 20px;
    z-index: 2;
    flex-wrap: wrap; justify-content: center;
}
.stat-mini {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.auth-form-side {
    width: 55%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 450px;
    padding: 20px;
    background: var(--bg-card); /* Assure fond blanc même si body coloré */
    border-radius: 20px; /* Consistance visuelle */
}

.login-header { margin-bottom: 30px; text-align: center; }
.login-header h3 { font-size: 2rem; color: var(--text-main); margin-bottom: 10px; }

.input-icon-wrapper { position: relative; }
.input-icon-wrapper input {
    width: 100%;
    padding: 15px 15px 15px 45px; 
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 1rem;
    color: var(--text-main);
    transition: 0.3s;
}
.input-icon-wrapper input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(67, 24, 255, 0.1);
    outline: none;
}

.input-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.show-pass {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
}
.show-pass:hover { color: var(--primary-color); }

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
}

.link-hover:hover { text-decoration: underline; }

.btn-block { width: 100%; display: block; }
.btn-lg { padding: 15px; font-size: 1rem; margin-top: 10px; }

.login-footer {
    margin-top: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

@media (max-width: 900px) {
    .auth-banner { display: none; } 
    .auth-form-side { width: 100%; background: var(--bg-body); }
    .login-card { 
        box-shadow: var(--shadow); 
    }
}


/* --- STYLE TODO LIST AMÉLIORÉ --- */

.todo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border);
    transition: 0.3s;
}

.todo-left {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden; /* Pour text-overflow */
}

.todo-item.completed .t-title {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.7;
}

.t-title { font-weight: 500; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge-mini {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    text-transform: uppercase;
    font-weight: bold;
    flex-shrink: 0;
}
.badge-mini.haute { background: rgba(255, 8, 68, 0.1); color: #ff0844; }
.badge-mini.moyenne { background: rgba(246, 211, 101, 0.2); color: #e67e22; }
.badge-mini.basse { background: rgba(5, 205, 153, 0.1); color: #05cd99; }

.btn-icon-danger {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px;
    transition: 0.2s;
    opacity: 0; 
}

/* Sur mobile, on affiche toujours le bouton supprimer */
@media (max-width: 768px) {
    .btn-icon-danger { opacity: 1; }
}

.todo-item:hover .btn-icon-danger {
    opacity: 1; 
}

.btn-icon-danger:hover {
    color: #ff0844;
    transform: scale(1.1);
}

.add-todo-wrapper {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 5px;
    flex-wrap: wrap;
}
.radio-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}


/* --- FIX DROPDOWNS MOBILE (CORRECTIF HOSTING) --- */
@media (max-width: 992px) {
    .mobile-bottom-nav .dropdown-wrapper {
        position: static; /* CRUCIAL: Permet au drop de se positionner par rapport au Nav fixed */
        display: flex;
        flex-direction: column;
        align-items: center;
        /* Fix Safari click */
        cursor: pointer; 
        -webkit-tap-highlight-color: transparent;
    }

    /* Le menu mobile s'ouvre vers le HAUT */
    .mobile-drop {
        top: auto !important; 
        bottom: 70px !important; 
        
        /* CORRECTION CENTRAGE ROBUSTE */
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important; 
        
        min-width: 200px; 
        width: max-content; /* S'adapte au contenu */
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.25); /* Ombre renforcée */
        
        /* FIX MAJEUR POUR L'HEBERGEMENT MOBILE */
        z-index: 9999 !important; /* Force ultime */
        pointer-events: auto; /* Force la réactivité */
        margin-bottom: 5px;
        
        /* Animation fade */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s, visibility 0.2s;
    }

    .mobile-drop a {
        padding: 15px 20px !important; 
        display: flex !important;
        align-items: center;
        gap: 10px;
        border-bottom: 1px solid var(--border);
        font-size: 0.9rem;
        white-space: nowrap; /* Empêche le texte de casser */
    }

    .mobile-drop a:last-child {
        border-bottom: none;
    }

    .drop-content.show {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        animation: slideUpMobile 0.2s ease-out;
    }
}

@keyframes slideUpMobile {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* Correction spécifique pour Safari iOS */
.drop-trigger, .m-nav {
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent; 
    user-select: none;
    position: relative; 
    touch-action: manipulation; /* Améliore la réponse au tap */
}

.drop-trigger {
    z-index: 10;
}