/* assets/css/style.css */

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

/* FORCE LE SITE A RESTER DANS L'ECRAN */
html, body {
    max-width: 100vw;       /* Largeur max = largeur de la fenêtre */
    overflow-x: hidden;     /* Cache tout ce qui dépasse horizontalement */
    width: 100%;
    margin: 0;
    padding: 0;
}

/* S'assure que les images et inputs ne déforment jamais leurs conteneurs */
img, input, select, textarea, canvas {
    max-width: 100%;
}

/* --- ZOOM --- */
html {
    /* 13px correspond environ à votre zoom 0.8 actuel (0.8 * 16px = 12.8px) */
    font-size: 13px; 
    overflow-x: hidden; /* Évite le scroll horizontal indésirable */
}

/* Sur les très grands écrans (4K / iMac), on grossit un peu pour que ce ne soit pas illisible */
@media (min-width: 1921px) {
    html { font-size: 15px; }
}

/* Sur mobile, on remet une taille standard pour la lisibilité */
@media (max-width: 768px) {
    html { font-size: 14px; }
}

#ai-commander {
    font-size: 1.1rem; 
}

/* --- VARIABLES GLOBALES --- */
:root {
  /* Palette */
  --primary: #a855f7;
  --secondary: #06b6d4;
  --accent: #f97316;
  --danger: #ef4444;
  --success: #10b981;
  
  /* Fonds & Surfaces */
  --dark-bg: #0f172a;       
  --glass-bg: rgba(255, 255, 255, 0.95); 
  --glass-border: rgba(255, 255, 255, 0.6);
  
  /* Textes */
  --text-main: #1e293b;     
  --text-muted: #64748b;    
  
  /* Effets */
  --shadow-soft: 0 15px 35px -5px rgba(0, 0, 0, 0.2);
  --radius: 16px;
}

/* --- RESET GLOBAL --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    background-image: url('../img/background.avif');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-color: #0f172a;
    color: #1e293b;
    font-family: 'Inter', sans-serif;
    margin: 0;
    min-height: 100vh;
}

@keyframes bgBreathe {
    0% { background-size: 100%; }
    100% { background-size: 105%; }
}

.main {
    padding: 20px;
    /* On passe de 1400px à 95% ou une limite plus large (ex: 1900px) */
    width: 96%; 
    max-width: 1800px; 
    margin: 0 auto;
    padding-top: 90px;
    /* Transition fluide lors du redimensionnement de la fenêtre */
    transition: width 0.3s ease;
}

/* --- TYPOGRAPHIE --- */
h1 {
    text-align: center;
    font-size: 2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 30%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 30px 0 40px 0;
    filter: drop-shadow(0 2px 10px rgba(0,0,0,0.5));
}

h2, h3 {
    color: var(--text-main);
    font-weight: 700;
    margin-bottom: 20px;
}

/* --- BOUTONS / INTERACTIONS --- */
button, a, select, .btn, .ghost, .event-pill, .filter-chip, .tag-link, .close-btn, .ai-btn-icon, .ai-action-btn, .mini-cal-cell.has-event, .stat-card, .doc-dropzone, .ai-dropzone, tbody tr, .user-info {
    cursor: pointer !important;
    transition: all 0.2s ease;
}

/* Effet Rebond */
.btn:hover, .btn-add-action:hover, .event-pill:hover, .mini-cal-cell.has-event:hover, .ai-orb:hover {
    transform: scale(1.05);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Effet Survol */
tbody tr:hover, .stat-card:hover, .doc-dropzone:hover, .ai-dropzone:hover {
    background: #fff !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
    transform: translateY(-2px);
    position: relative;
    z-index: 5;
}

/* Style des Boutons Principaux */
.btn, .btn-save, .btn-add-action, .btn-login {
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

.btn::after, .btn-save::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent);
    transform: skewX(-25deg);
    animation: shimmer 4s infinite;
}

@keyframes shimmer {
    0% { left: -100%; } 20% { left: 200%; } 100% { left: 200%; }
}

.ghost {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 8px;
}

.ghost:hover {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
}

/* --- CARTES / CONTENEURS --- */
.card, .modal-card, .stat-card, .chart-card, .ai-dropzone {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    padding: 25px;
    margin-bottom: 30px;
    position: relative;
    overflow: visible;
    color: var(--text-main);
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0; 
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative; 
    margin: 20px;
}

body.loaded .card, 
body.loaded .modal-card, 
body.loaded .stat-card, 
body.loaded .chart-card, 
body.loaded .ai-dropzone {
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

body.loaded .stats-grid > *:nth-child(1) { animation-delay: 0.1s; }
body.loaded .stats-grid > *:nth-child(2) { animation-delay: 0.2s; }
body.loaded .stats-grid > *:nth-child(3) { animation-delay: 0.3s; }
body.loaded .stats-grid > *:nth-child(4) { animation-delay: 0.4s; }
body.loaded .charts-grid { animation-delay: 0.5s; }

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

.stats-grid > *:nth-child(1) { animation-delay: 0.1s; }
.stats-grid > *:nth-child(2) { animation-delay: 0.2s; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: relative;
}

.card-header::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0;
    width: 60px; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 3px;
}

.card-header h2 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #1e293b 50%, #64748b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex; align-items: center; gap: 10px;
}

/* --- STATS DASHBOARD --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    width: 100%;
}

.stat-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    padding: 25px;
    border-left: 4px solid transparent;
}

.stat-icon-wrapper {
    width: 55px; height: 55px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid rgba(255,255,255,0.5);
}

/* Couleurs Stats */
#card-flotte { border-left-color: #6366f1; }
#card-flotte .stat-icon-wrapper { background: #e0e7ff; color: #6366f1; }

#card-ent { border-left-color: #f97316; }
#card-ent .stat-icon-wrapper { background: #ffedd5; color: #f97316; }

#card-cert { border-left-color: #06b6d4; }
#card-cert .stat-icon-wrapper { background: #cffafe; color: #06b6d4; }

#card-abs { border-left-color: #ec4899; }
#card-abs .stat-icon-wrapper { background: #fce7f3; color: #ec4899; }

.stat-value { font-size: 2rem; font-weight: 800; color: var(--text-main); margin: 0; line-height: 1.1; }
.stat-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-top: 5px; }

/* --- FORMULAIRES --- */
.input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: 0.3s;
}

.input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
}

label.small, .form-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
}

.form-row, .ent-form-grid, .modal-grid, .cert-form-grid {
    display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end;
}
.form-row > div, .ent-form-grid > div, .modal-grid > div, .cert-form-grid > div {
    flex: 1; min-width: 160px;
}
.btn-container { flex: 0 0 auto; min-width: auto; }

/* --- TABLEAUX --- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    margin-top: 10px;
}

th {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0 20px 10px 20px;
}

td {
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

td:first-child { border-left: 1px solid #f1f5f9; border-radius: 12px 0 0 12px; }
td:last-child { border-right: 1px solid #f1f5f9; border-radius: 0 12px 12px 0; text-align: right; }

tbody tr { background: rgba(255, 255, 255, 0.7); border-radius: 12px; position: relative; }

.tag-link {
    display: inline-flex; padding: 4px 10px; border-radius: 12px;
    font-size: 0.75rem; font-weight: 700; color: white; background: var(--accent);
    white-space: nowrap; vertical-align: middle;
}
.tag-link.secondary { background: #475569; }

.actions-cell { display: flex; justify-content: flex-end; gap: 8px; }
.btn-icon-action {
    width: 34px; height: 34px; border-radius: 8px; background: #fff;
    border: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: #64748b; transition: 0.2s;
}
.btn-icon-action:hover { background: #f1f5f9; border-color: var(--primary); color: var(--primary); }

/* --- SIDEBAR / MENU --- */
.sidebar {
    background: rgba(5, 5, 5, 0.95) !important;
    backdrop-filter: blur(15px);
    border-right: 1px solid rgba(255,255,255,0.1);
    width: 280px;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 1500;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    box-shadow: 10px 0 50px rgba(0,0,0,0.5);
}

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

/* --- SIDEBAR / MENU --- */

.menu-toggle {
    position: fixed; top: 20px; left: 20px; z-index: 2000;
    background: rgba(255,255,255,0.1); backdrop-filter: blur(5px);
    color: white; border: 1px solid rgba(255,255,255,0.2);
    padding: 10px 14px; border-radius: 10px; cursor: pointer;
    transition: all 0.3s ease;
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.menu-toggle.menu-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.8) translateX(-20px);
}

.brand {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text; 
    color: transparent;
    text-align: center; 
    margin: 30px 0 20px 0;
    text-transform: uppercase; 
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
}

.menu-list { list-style: none; padding: 0 15px; flex: 1; overflow-y: auto; }
.menu-list a {
    display: flex; align-items: center; gap: 15px;
    padding: 12px 20px; color: #94a3b8; font-weight: 600;
    text-decoration: none; border-left: 3px solid transparent;
    transition: 0.2s; margin-bottom: 5px; border-radius: 0 10px 10px 0;
}
.menu-list a:hover, .menu-list li.active a {
    background: rgba(255,255,255,0.08); color: #fff;
    border-left-color: var(--secondary);
}

.user-dropdown { margin: 20px; position: relative; flex-shrink: 0; }
.user-info {
    background: rgba(255,255,255,0.1); padding: 12px;
    border-radius: 12px; color: white; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    gap: 10px; cursor: pointer; border: 1px solid rgba(255,255,255,0.1);
    transition: 0.3s;
}
.user-info:hover { background: rgba(255,255,255,0.15); border-color: var(--primary); }

.user-menu {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    margin-top: 10px; background: #1e293b; border: 1px solid #475569;
    border-radius: 12px; overflow: hidden; z-index: 1600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: slideDown 0.2s ease-out;
}
.user-menu.show { display: flex; flex-direction: column; }
.user-menu a {
    padding: 12px 15px; color: #cbd5e1; font-size: 0.9rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; margin: 0; border-radius: 0; border-left: none;
}
.user-menu a:hover { background: var(--primary); color: white; }
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 1400; display: none; backdrop-filter: blur(4px);
}
.sidebar-overlay.show { display: block; }

/* --- CALENDRIER & FILTRES --- */
.calendar-container { border: 1px solid #cbd5e1; border-radius: 12px; overflow: visible !important; background: #fff; }
.calendar-container table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.calendar-container th { background: #f1f5f9; color: #475569; padding: 12px 0; border-bottom: 1px solid #cbd5e1; font-size: 0.75rem; text-align: center; }
.calendar-container td { height: 110px; vertical-align: top; padding: 6px !important; border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0; background: #fff; overflow: visible !important; position: relative; }
.calendar-container td.today { background: #f0f9ff !important; box-shadow: inset 0 0 0 2px #3b82f6 !important; }
.date-num { text-align: right; font-weight: 700; color: #94a3b8; margin-bottom: 5px; }
.calendar-toolbar select {
    appearance: none;            
    -webkit-appearance: none;
    -moz-appearance: none;
    
    background-color: #fff;      
    border: 1px solid #cbd5e1;   
    border-radius: 12px;         
    padding: 10px 40px 10px 16px;
    
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;            
    color: var(--text-main);
    text-transform: capitalize;
    
    cursor: pointer;
    outline: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    transition: all 0.2s ease;

    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

/* Effet au survol */
.calendar-toolbar select:hover {
    border-color: var(--primary); 
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(168, 85, 247, 0.15);
}

/* Effet clique */
.calendar-toolbar select:focus {
    border-color: var(--secondary); 
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
}

.event-pill {
    display: flex; align-items: center; gap: 6px; width: calc(100% - 4px);
    margin: 0 auto 3px auto; padding: 4px 8px; border-radius: 6px;
    font-size: 0.7rem; font-weight: 700; color: white; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; border-left: 3px solid rgba(255,255,255,0.4);
}
.pill-orange { background: linear-gradient(135deg, #fb923c, #ea580c); }
.pill-red { background: linear-gradient(135deg, #f87171, #dc2626); }
.pill-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }

.calendar-toolbar { display: flex; justify-content: center; gap: 12px; margin-bottom: 25px; align-items: center; flex-wrap: wrap; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 0 15px; }
.filter-chip { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; background: #fff; border: 1px solid #e2e8f0; color: #64748b; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.filter-chip.active { background: #0f172a; color: white; border-color: #0f172a; }

/* Mini Calendar */
.mini-cal-wrap { display: grid !important; grid-template-columns: repeat(7, 1fr) !important; gap: 4px !important; width: 100% !important; margin-top: 10px; }
.mini-cal-header { text-align: center; font-weight: 800; color: var(--primary); font-size: 0.7rem; }
.mini-cal-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; border-radius: 50%; background: #f8fafc; cursor: default; position: relative; overflow: visible !important; }
.cal-hover-modal { display: none; position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%); width: 200px; background: #1e293b; color: white; border-radius: 8px; padding: 10px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); z-index: 9999; text-align: left; pointer-events: none; animation: popUp 0.2s ease-out; border: 1px solid rgba(255,255,255,0.1); }
.mini-cal-cell:hover .cal-hover-modal { display: block; }

/* --- 8. AI COMMANDER --- */

#ai-commander {
    position: fixed;
    z-index: 2000;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

/* ÉTAT FERMÉ (CAPSULE) */
#ai-commander:not(.expanded) {
    bottom: 30px; left: 50%; transform: translateX(-50%);
    width: auto; min-width: 270px; height: 56px;
    padding: 0 25px 0 6px; border-radius: 40px;
    display: flex; align-items: center; justify-content: flex-start; cursor: pointer;
}
#ai-commander:not(.expanded):hover { transform: translateX(-50%) translateY(-5px); border-color: var(--secondary); box-shadow: 0 0 30px rgba(6, 182, 212, 0.4); }

/* ORBE FERMÉ */
#ai-commander:not(.expanded) #ai-orb-wrapper {
    width: 42px !important; height: 42px !important; border-radius: 50% !important;
    position: relative !important; flex-shrink: 0 !important; margin-right: 15px !important;
    border: 2px solid var(--secondary); background: #000; box-shadow: 0 0 15px var(--secondary);
    z-index: 10; overflow: hidden !important;
}

/* TEXTE FERMÉ */
.ai-idle-text {
    color: #fff; font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1px; white-space: nowrap; opacity: 1; display: block;
}

/* MASQUAGE */
#ai-commander.expanded .ai-idle-text { display: none !important; }
#ai-commander:not(.expanded) .ai-interface, 
#ai-commander:not(.expanded) .ai-close,
#ai-commander:not(.expanded) .ai-instruction { display: none !important; }


/* ÉTAT OUVERT (CINÉMA) */
#ai-commander.expanded {
    top: 50%; left: 50%; bottom: auto; transform: translate(-50%, -50%);
    width: 85vw; height: 75vh; max-width: 1100px;
    border-radius: 24px; padding: 0;
    flex-direction: column; justify-content: center;
    background: rgba(5, 8, 16, 0.98); 
    border: 1px solid var(--secondary);
    box-shadow: 0 0 100px rgba(0,0,0,0.8);
    z-index: 9500; overflow: hidden;
}

/* ORBE OUVERT */
#ai-commander.expanded #ai-orb-wrapper {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 100% !important; height: 100% !important; max-width: 800px; max-height: 800px;
    background: transparent; border-radius: 0; margin: 0;
    z-index: 1; pointer-events: none; opacity: 1;
}

/* TRANSPARENCE DU NOIR */
#ai-orb-3d canvas {
    mix-blend-mode: screen; 
    width: 100% !important; height: 100% !important; object-fit: contain;
}

/* INTERFACE INTERNE */
#ai-commander.expanded .ai-interface {
    position: relative; z-index: 10; width: 100%; height: 100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    padding: 40px; background: transparent !important;
    
    isolation: isolate; 
}

/* TEXTE "SYSTÈME EN LIGNE" */
#ai-instruction {
    position: absolute; top: 40px; left: 0; width: 100%; text-align: center; pointer-events: none;
}
#ai-instruction span {
    font-size: 0.8rem; font-weight: 600; color: var(--secondary);
    text-transform: uppercase; letter-spacing: 4px; padding: 8px 20px;
    background: rgba(6, 182, 212, 0.1); border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 50px; backdrop-filter: blur(5px);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.1);
}

/* --- LA CARTE DE RÉSULTAT --- */
.ai-result-card {
    background: rgba(16, 23, 41, 0.85) !important; 
    
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 20px; padding: 30px; color: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    
    width: 100%; max-width: 800px;
    margin-bottom: 20px;

    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.ai-card-header {
    display: flex; align-items: center; gap: 15px; margin-bottom: 20px;
    padding-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.ai-card-icon { font-size: 1.5rem; text-shadow: 0 0 15px var(--secondary); }
.ai-card-title { font-weight: 800; font-size: 1rem; text-transform: uppercase; letter-spacing: 2px; color: var(--secondary); }

/* CONTENU TEXTE */
.ai-card-body { font-size: 1rem; line-height: 1.6; color: #e2e8f0; }
.ai-card-body p { margin-bottom: 10px; }
.ai-card-body ul { margin-left: 20px; }
.ai-card-body a { color: #a5f3fc; text-decoration: none; border-bottom: 1px dashed rgba(6, 182, 212, 0.5); }
.ai-card-body img { display: none !important; }

/* BOUTONS ACTIONS */
.ai-actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 15px; margin-top: 20px; }
.ai-action-btn {
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px; padding: 15px; text-align: left; cursor: pointer; transition: 0.3s;
}
.ai-action-btn:hover {
    background: rgba(6, 182, 212, 0.15); border-color: var(--secondary); transform: translateY(-3px);
}
.ai-btn-title { display: block; color: #fff; font-weight: 700; margin-bottom: 4px; }
.ai-btn-desc { display: block; color: #94a3b8; font-size: 0.8rem; }

/* Zone de saisie */
.ai-input-wrapper {
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(15px);
    border: 1px solid rgba(6, 182, 212, 0.3); border-radius: 50px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    height: 70px; width: 100%; max-width: 800px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 10px 0 30px; margin-top: 20px;
}
#ai-input { flex: 1; background: transparent; border: none; color: #fff; font-size: 1.1rem; height: 100%; outline: none; }
.ai-actions { display: flex; gap: 8px; background: rgba(0,0,0,0.2); padding: 5px; border-radius: 40px; }
.ai-btn-icon { width: 48px; height: 48px; border-radius: 50%; background: transparent; border: none; color: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.ai-btn-icon:hover { background: var(--secondary); color: #0f172a; box-shadow: 0 0 15px var(--secondary); }
.ai-close { position: absolute; top: 20px; right: 20px; color: rgba(255,255,255,0.5); background: transparent; border: none; font-size: 2rem; cursor: pointer; display: none; z-index: 100; }
#ai-commander.expanded .ai-close { display: block; }
.ai-close:hover { color: #fff; transform: rotate(90deg); }

/* --- 9. MODALES --- */
.modal {
    position: fixed; 
    inset: 0; 
    display: flex;
    align-items: flex-start; 
    justify-content: center;
    z-index: 9999; 
    opacity: 0; 
    pointer-events: none;
    transition: opacity 0.2s;
    overflow-y: auto; 
    padding: 40px 10px; 
}

.modal:not(.hidden) { opacity: 1; pointer-events: all; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85); 
    backdrop-filter: blur(8px);
    z-index: 9998;
}

.modal-card {
    margin: 0 auto; 
    width: 100%; 
    max-width: 950px;
    background: #fff !important;
    border-radius: 16px; 
    padding: 30px;
    position: relative; 
    z-index: 9999;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    max-height: none; 
    height: auto;
}

/* Mini modale */
.mini-modal {
    z-index: 10000;
    align-items: center;
}

/* MODALES CENTRAGE */
#repo-modal, #summary-modal {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding-top: 0 !important;
}
#repo-modal .modal-card, #summary-modal .modal-card {
    max-width: 600px !important;
    margin: auto !important;
    top: auto !important; transform: none !important;
}

/* SCROLLBARS */
.info-list, .doc-list, #summary-list, #ent-listing, #spot-list, #provider-contracts-list, #perm-list, #ch-cert-list {
    max-height: none !important;
    overflow-y: visible !important;
    height: auto !important;
}

.close-btn { position: absolute; top: 20px; right: 20px; font-size: 1.5rem; background: none; border: none; color: #64748b; }
.modal-footer {
    margin-top: 30px; padding-top: 20px;
    border-top: 1px solid #f1f5f9;
    display: flex; justify-content: space-between; gap: 15px;
}

/* LOADER */
#global-loader {
    position: fixed; inset: 0; 
    background-image: url('../img/loader-bg.png'); background-size: cover;
    z-index: 9999; 
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity 0.8s cubic-bezier(0.65, 0, 0.35, 1), 
                transform 0.8s cubic-bezier(0.65, 0, 0.35, 1),
                filter 0.8s ease,
                visibility 0.8s;
    will-change: transform, opacity, filter;
}
#global-loader::before { 
    content: ''; position: absolute; inset: 0; 
    background: rgba(15, 23, 42, 0.9); 
    backdrop-filter: blur(8px); 
    z-index: 0;
}
.loader-hidden { 
    opacity: 0; 
    visibility: hidden; 
    pointer-events: none;
    transform: scale(1.5); 
    filter: blur(20px);
}

.loader-wrapper {
    position: relative;
    width: 220px;
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.loader-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    
    background: conic-gradient(
        from 0deg, 
        transparent 0%, 
        transparent 40%, 
        var(--secondary) 100%
    );
    
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #fff calc(100% - 4px + 1px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #fff calc(100% - 4px + 1px));
    
    animation: spinRing 1s linear infinite;
    z-index: 2;
}

.loader-logo {
    width: 190px;
    height: 190px;
    object-fit: contain;
    border-radius: 50%;
    z-index: 1;
    background-color: #0f172a; 
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* 4. Définition de la rotation */
@keyframes spinRing {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.loader-text { margin-top: 15px; color: #fff; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; font-size: 0.9rem; position:relative; z-index:1; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
@keyframes pulseGlow { 0%,100%{transform:scale(1); filter:drop-shadow(0 0 5px rgba(168,85,247,0.5));} 50%{transform:scale(1.1); filter:drop-shadow(0 0 20px var(--secondary));} }

.hidden { display: none !important; }

@media print {
    .sidebar, .menu-toggle, #ai-commander, .btn, .ghost { display: none !important; }
}
@media(max-width: 1100px) {
    .layout-split { grid-template-columns: 1fr; }
}

.sidebar .brand-icon {
    width: 460px;
    max-width: 70%;
    display: block;
    margin: 30px auto 20px auto;
    background: #fff;
    padding: 12px;
    border-radius: 16px;
    box-shadow: 
        inset 0 0 20px rgba(255, 255, 255, 0.5),
        0 0 0 2px var(--secondary),
        0 0 25px rgba(168, 85, 247, 0.5);  
    transition: all 0.3s ease;
}
.sidebar .brand-icon:hover {
    box-shadow: 
        inset 0 0 10px rgba(255, 255, 255, 1),
        0 0 0 2px var(--primary),
        0 0 40px var(--secondary);
}

body.loading-locked {
    overflow: hidden !important;
    height: 100vh;
}
.notification, #notification-area, .toast-container {
    position: fixed !important;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 350px;
}

/* --- ORGANIGRAMME AGENCES --- */
.org-tree {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.org-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: 0.2s;
}

.org-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(168, 85, 247, 0.5);
}

.org-children {
    margin-left: 30px; 
    padding-left: 15px;
    border-left: 2px dashed rgba(255, 255, 255, 0.2); 
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.org-badge-parent {
    font-size: 0.7rem;
    background: #3b82f6;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 10px;
    text-transform: uppercase;
}

/* ==========================================================================
   1. MOBILE : VERSION DÉFINITIVE (CORRECTIF LOUPE + FOOTER)
   ========================================================================== */
@media (max-width: 900px) {

    /* --- 1. STRUCTURE GLOBALE --- */
    .main {
        width: 100% !important; padding: 10px !important;
        padding-bottom: 120px !important; overflow-x: hidden;
    }

    .modal {
        align-items: flex-start !important; padding: 0 !important; overflow-y: auto !important;
    }

    .modal-card {
        width: 100% !important; max-width: 100% !important; margin: 0 !important;
        min-height: 100vh !important; border-radius: 0 !important;
        box-shadow: none !important; padding-bottom: 150px !important;
        position: relative !important;
    }

    /* --- 2. BARRE DE RECHERCHE (LE CORRECTIF LOUPE) --- */
    .toolbar, .sidebar-header, .list-header, .filters-container-wrapper {
        display: flex !important; flex-direction: column !important;
        align-items: stretch !important; gap: 10px !important;
        margin-bottom: 10px !important; height: auto !important;
    }

    /* CONTENEUR (Boîte blanche) */
    .search-box, .search-container, .input-group {
        display: flex !important;
        flex-direction: row !important; /* LIGNE OBLIGATOIRE */
        align-items: center !important; /* CENTRE VERTICALEMENT */
        width: 100% !important;
        height: 50px !important;
        max-height: 50px !important;
        gap: 0 !important;
        background: #fff; border-radius: 12px; border: 1px solid #e2e8f0;
        margin-bottom: 5px !important; overflow: hidden;
        position: relative !important;
    }

    /* LOUPE / ICÔNE (STOP AU FLOTTEMENT) */
    .search-box i, .search-box .icon, .search-icon, .input-group i, .search-box button {
        /* On remet tout à zéro pour qu'il ne flotte plus */
        position: relative !important; 
        top: auto !important; left: auto !important; right: auto !important; bottom: auto !important;
        transform: none !important;
        
        /* Taille et alignement Flex */
        width: 44px !important; flex: 0 0 44px !important;
        height: 100% !important;
        margin: 0 !important; padding: 0 !important;
        
        display: flex !important; align-items: center !important; justify-content: center !important;
        background: transparent !important; border: none !important;
        color: #64748b !important; /* Couleur gris propre */
        z-index: 10;
    }

    /* CHAMP TEXTE (Prend le reste) */
    .search-box input, #search-input, input[type="search"] {
        flex: 1 !important; width: auto !important; 
        height: 100% !important;
        border: none !important; margin: 0 !important; padding-left: 5px !important;
        background: transparent !important;
        position: relative !important; z-index: 5;
    }

    /* --- 3. PIED DE PAGE MODALE (BOUTONS RECTANGULAIRES) --- */
    .modal-footer {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        padding-top: 20px !important; margin-top: 20px !important;
        width: 100% !important;
        position: relative !important;
        height: auto !important;
    }

    .modal-footer button, 
    .modal-footer .btn, 
    .modal-footer .modal-close, /* Cible le bouton Annuler s'il a cette classe */
    .modal-footer a {
        width: 100% !important;
        height: 48px !important; min-height: 48px !important;
        border-radius: 12px !important;
        margin: 0 !important; padding: 0 !important;
        display: flex !important; align-items: center !important; justify-content: center !important;
        position: relative !important; top: auto !important; right: auto !important;
        z-index: 1 !important;
    }

    /* Couleurs spécifiques Footer */
    .modal-footer .btn-cancel, .modal-footer .btn-secondary, 
    .modal-footer .ghost, .modal-footer .modal-close {
        background: #f1f5f9 !important; border: 1px solid #cbd5e1 !important; color: #64748b !important;
    }
    .modal-footer .btn-save, .modal-footer button[type="submit"] {
        background: linear-gradient(135deg, var(--primary), var(--secondary)) !important; 
        color: white !important; border: none !important;
    }

    /* --- 4. FORMULAIRES (STACK) --- */
    .form-row, .modal-grid, div[style*="display:flex"]:not(.search-box):not(.input-group):not(.menu-toggle):not(.close-btn) {
        display: flex !important; flex-direction: column !important;
        align-items: stretch !important; gap: 10px !important; width: 100% !important;
    }
    select, textarea, .input, input:not([type="checkbox"]):not([type="radio"]) {
        width: 100% !important; height: 50px !important; font-size: 16px !important;
        margin: 0 !important; box-sizing: border-box !important; margin-bottom: 5px !important;
    }
    
    /* Boutons généraux */
    .btn, button:not(.btn-icon-action):not(.menu-toggle):not(.close-btn):not(.modal-close):not(.small):not(.ai-close):not(.modal-close-abs) {
        width: 100% !important; height: 48px !important; margin-top: 5px !important;
    }

    /* --- 5. DIVERS --- */
    .header-card { padding: 20px !important; flex-direction: column !important; }
    table td, table th, .tag-link {
        white-space: nowrap !important; font-size: 0.85rem !important; padding: 12px 10px !important;
    }
    .table-container, div[style*="overflow-x:auto"] {
        display: block !important; width: 100% !important; overflow-x: auto !important;
    }
    .filter-group, .filters-bar {
        flex-direction: row !important; overflow-x: auto !important; 
        justify-content: flex-start !important; padding-bottom: 5px; gap: 8px !important;
    }
    .cockpit-grid, .map-layout { display: flex !important; flex-direction: column !important; gap: 20px; }
    .map-layout { flex-direction: column-reverse !important; }
    .map-container { height: 350px !important; width: 100%; }

    .actions-grid, .mini-kpi-grid {
        display: flex !important; flex-wrap: wrap !important; gap: 10px; padding: 0 15px;
    }
    .quick-btn, .mini-kpi { flex: 0 0 45% !important; margin: 0 !important; }

    /* --- 6. PAGE DE CONNEXION (LOGIN FIX) --- */
    .login-card {
        width: 90% !important; /* Prend presque toute la largeur */
        max-width: 400px !important; /* Mais ne devient pas géant sur tablette */
        margin: 50px auto !important; /* Centrage horizontal avec marge haut */
        padding: 30px 20px !important;
        position: relative !important;
        box-shadow: 0 10px 25px rgba(0,0,0,0.1) !important;
        border: none !important;
    }
    
    /* Si la page Login a un conteneur global, on l'aide à centrer */
    body:has(.login-card), .login-container {
        display: flex !important; flex-direction: column !important;
        justify-content: center !important; align-items: center !important;
        min-height: 100vh !important;
    }
}


/* ==========================================================================
   2. ÉCRANS MOYENS & GRANDS (RESTE INCHANGÉ)
   ========================================================================== */
@media (min-width: 901px) and (max-width: 1399px) {
    html, body { height: auto !important; overflow-y: auto !important; overflow-x: hidden; }
    .main { width: 92% !important; max-width: 1200px; margin: 0 auto !important; padding-bottom: 100px !important; display: block !important; }
    .cockpit-grid { display: grid !important; grid-template-columns: 1fr 320px; gap: 25px; align-items: stretch !important; }
    .right-col { display: flex !important; flex-direction: column !important; min-height: 100%; }
    .right-sidebar { width: 100%; flex: 1 !important; display: flex; flex-direction: column; }
    .map-container { height: 500px !important; }
}

@media (min-width: 1400px) {
    html, body { height: auto !important; overflow-y: auto !important; overflow-x: hidden; }
    .main { width: 96% !important; max-width: 1800px; margin: 0 auto !important; padding-bottom: 140px !important; display: block !important; }
    .cockpit-grid { display: grid !important; grid-template-columns: 1fr 380px; gap: 30px; align-items: stretch !important; }
    .left-col, .right-col, .right-sidebar, .sidebar-panel { height: auto !important; overflow: visible !important; }
    .right-col { display: flex !important; flex-direction: column !important; min-height: 100%; }
    .right-sidebar { flex: 1 !important; display: flex; flex-direction: column; }
    .map-container { height: 650px !important; }
}