/* ==========================================================
   VARIABLES & RESET
   ========================================================== */
:root {
    /* Couleurs primaires */
    --primary: #009fe3;
    --primary-light: #33b5e5;
    --secondary: #6c757d;
    --success: #27c98b;
    --warning: #f5a623;
    --danger: #e74c3c;
    
    /* COULEURS PAR DÉFAUT (MODE SOMBRE) */
    --bg: #0f172a;       
    --card: #1e293b;     
    --text: #e2e8f0;     
    --text-muted: #94a3b8;
    --border: #334155;
    
    --sidebar-width: 260px;
}

/* Mode CLAIR (uniquement si la classe .light est présente sur body) */
body.light {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #2c3e50;
    --text-muted: #8892b0;
    --border: #e1e5eb;
}

/* Reset de base */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

/* CORRECTION FOND BLANC : Force la couleur sombre dès le chargement */
html, body {
    background-color: var(--bg); /* Utilise la variable --bg définie dans :root (#0f172a) */
}

/* Sécurité pour les images (logo, etc.) */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

html { scroll-behavior: smooth; } 

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================
   1. BARRE DE DÉFILEMENT PERSONNALISÉE
   ========================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================================
   LAYOUT PRINCIPAL
   ========================================================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: margin-left 0.3s ease;
}

/* ==========================================================
   SIDEBAR STYLES
   ========================================================== */
.sidebar .logo {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.sidebar .logo img { height: 40px; width: auto; }
.logo-title { font-weight: 700; font-size: 1.1rem; color: var(--primary); }

.nav-title {
    padding: 20px 20px 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 700;
}

.nav { display: flex; flex-direction: column; padding: 0 10px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px 12px 12px; 
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
}

.nav-item:hover { 
    background: rgba(0, 159, 227, 0.1); 
    color: var(--primary); 
    border-left-color: var(--primary);
}
.nav-item.active { 
    background: rgba(0, 159, 227, 0.15); 
    color: var(--primary); 
    border-left-color: var(--primary);
    font-weight: 600;
}
.nav-icon { font-size: 1.2rem; width: 24px; text-align: center; }

.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid var(--border);
}
.security-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.security-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

/* ==========================================================
   TOPBAR & MOBILE HEADER
   ========================================================== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--card);
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.breadcrumb { font-size: 0.9rem; color: var(--text-muted); }
.breadcrumb strong { color: var(--text); }

.mobile-header { display: none; }
.icon-button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}
.icon-button:hover { background: rgba(0,0,0,0.05); }

/* ==========================================================
   COMPOSANTS UI
   ========================================================== */
.panel, .card, .info-card, .prop-card, .maj-card { 
    background: var(--card); 
    padding: 20px; 
    border-radius: 12px; 
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel:hover, .card:hover, .info-card:hover, .prop-card:hover, .maj-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.form-row { display: flex; gap: 15px; margin-bottom: 15px; }
.form-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus { 
    outline: none; 
    border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.25); 
}

.btn-submit, .btn-clear {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.btn-submit { background: var(--primary); color: white; }
.btn-submit:hover { background: var(--primary-light); }
.btn-clear { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-clear:hover { background: var(--danger); color: white; }

/* ==========================================================
   STYLES DU TABLEAU DE BORD
   ========================================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 30px 0 15px 0;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
}
.section-title { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.section-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 12px;
}

.accordion-header {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 10px;
}
.accordion-header:hover { background: var(--bg); }
.acc-title { font-weight: 600; color: var(--text); }
.acc-arrow { transition: transform 0.3s ease; color: var(--text-muted); }
.accordion-header.open .acc-arrow { transform: rotate(180deg); }

.accordion-content { display: none; animation: fadeIn 0.3s ease; }
.accordion-header.open + .accordion-content { display: block; }

.info-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.info-title { font-weight: 700; font-size: 1rem; color: var(--text); flex: 1; padding-right: 30px; }
.info-meta { text-align: right; font-size: 0.8rem; color: var(--text-muted); }
.info-author { font-weight: 600; color: var(--primary); }
.info-text { font-size: 0.95rem; color: var(--text); line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin-top: 20px; }
.card { text-decoration: none; color: var(--text); position: relative; overflow: hidden; display: flex; flex-direction: column; }
.card-icon { font-size: 2.5rem; margin-bottom: 15px; }
.card h3 { font-size: 1.1rem; font-weight: 700; margin: 0 0 8px 0; color: var(--text); }
.card p { font-size: 0.9rem; color: var(--text-muted); margin: 0; line-height: 1.4; }
.card-arrow {
    position: absolute; top: 20px; right: 20px; font-size: 1.2rem; color: var(--primary);
    opacity: 0; transform: translateX(-10px); transition: all 0.3s ease;
}
.card:hover .card-arrow { opacity: 1; transform: translateX(0); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

footer {
    margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted);
}

/* ==========================================================
   CORRECTION MOBILE
   ========================================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        height: 100vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar.open { transform: translateX(0); }
    
    .main { margin-left: 0; padding: 15px; }
    
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: var(--card);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 900;
    }
    .topbar { display: none; }
    .form-row { flex-direction: column; gap: 10px; }
}