/* =========================================
   1. VARIABLES (LES COULEURS)
   ========================================= */
:root {
    /* --- MODE JOUR (Light) --- */
    --bg-body: #F9FAFB;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff; /* Blanc pur pour éviter les effets bizarres */

    --text-main: #111827;  /* Noir profond */
    --text-muted: #6B7280; /* Gris moyen */

    --border-color: #E5E7EB;
    --primary: #ED1B2F; /* LE ROUGE EUS OFFICIEL */

    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    /* --- MODE NUIT (Dark) --- */
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a; /* Sombre opaque */

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --border-color: #334155;
    --primary: #ff4d4d; /* Rouge légèrement plus clair pour le noir */

    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

/* =========================================
   2. BASE & TYPOGRAPHIE
   ========================================= */
body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* =========================================
   3. SIDEBAR
   ========================================= */
.sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 280px;
    background-color: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex; flex-direction: column;
    padding: 24px;
    transition: transform 0.3s ease;
}

/* Logo dans la sidebar */
.brand-logo {
    font-size: 1.4rem;
    font-weight: 800;
    text-decoration: none;
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 40px; /* Espace sous le logo */
    padding-left: 0;
    color: var(--text-main);
}

/* LE FIX DU TEXTE (Noir + Rouge) */
.text-eus, .brand-text-eus {
    color: var(--text-main) !important;
}
.text-wiki, .brand-text-wiki {
    color: var(--primary) !important; /* ROUGE EUS FORCÉ */
    font-weight: 900;
    background: none !important; /* Enlève les vieux dégradés */
    -webkit-text-fill-color: initial !important;
}

/* Liens du menu */
.nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 4px;
    display: flex; align-items: center; gap: 12px;
    text-decoration: none;
    transition: all 0.2s;
}
.nav-link:hover {
    background-color: var(--border-color);
    color: var(--text-main);
}
.nav-link.active {
    background-color: rgba(237, 27, 47, 0.1); /* Fond rouge très pâle */
    color: var(--primary);
    font-weight: 700;
}

/* =========================================
   4. COMPOSANTS (Cartes & Header Mobile)
   ========================================= */

/* Mobile Header */
.mobile-header {
    background: var(--bg-sidebar) !important;
    border-bottom: 1px solid var(--border-color);
}

/* Cartes */
.card, .cute-card, .folder-card, .result-card, .info-card {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
    box-shadow: var(--shadow);
    border-radius: 16px;
    transition: transform 0.2s;
}
.card:hover, .cute-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary) !important;
}

/* Inputs */
input.search-input, input.form-control {
    background-color: var(--bg-body) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
}
input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(237, 27, 47, 0.2) !important;
}

/* Liens génériques */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Tableaux */
table {
    width: 100%; margin: 20px 0;
    border: 1px solid var(--border-color);
    border-radius: 12px; overflow: hidden;
}
th {
    background-color: var(--bg-body) !important;
    color: var(--text-muted) !important;
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
}
td {
    background-color: var(--bg-card) !important;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding: 12px;
}
/* =========================================
   5. SIDEBAR NAV — moved from base.html inline styles
   ========================================= */

.logo-img { height: 38px; width: auto; }

.nav-item-main {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: 14px;
    color: var(--text-muted); font-weight: 600; text-decoration: none;
    transition: all 0.2s ease; margin-bottom: 5px;
}
.nav-item-main:hover {
    background-color: var(--bg-body); color: var(--text-main);
    transform: translateX(3px);
}
.nav-item-main.active { background-color: #FFF1F2; color: #ED1B2F; }
.nav-item-main i { font-size: 1.1rem; }

.nav-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); font-weight: 800;
    margin: 25px 0 10px 10px; opacity: 0.6;
}

.nav-item-color {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 14px;
    color: var(--text-main); text-decoration: none;
    font-weight: 600; font-size: 0.95rem;
    transition: all 0.2s; margin-bottom: 8px;
}
.nav-item-color:hover { background-color: var(--bg-body); transform: translateX(3px); }

.nav-icon-box {
    width: 32px; height: 32px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; flex-shrink: 0;
}

.icon-gov   { background: #FFF7ED; color: #F59E0B; }
.icon-clubs { background: #F5F3FF; color: #8B5CF6; }
.icon-dept  { background: #EFF6FF; color: #3B82F6; }
.icon-rand  { background: #FDF2F8; color: #DB2777; }

.user-card {
    background: var(--bg-body); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 12px; margin-top: auto;
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; transition: all 0.2s;
}
.user-card:hover {
    border-color: #ED1B2F;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.user-avatar {
    width: 36px; height: 36px; background: #ED1B2F; color: white;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
}
.user-info { overflow: hidden; }
.user-name {
    font-size: 0.9rem; font-weight: 700; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.btn-login-sidebar {
    width: 100%; padding: 12px; border-radius: 14px;
    background: #111827; color: white; font-weight: 700;
    text-align: center; text-decoration: none;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); transition: all 0.2s;
}
.btn-login-sidebar:hover {
    background: #ED1B2F; transform: translateY(-2px); color: white;
}

/* =========================================
   6. LAYOUT — main content area & mobile
   ========================================= */

.main-content {
    margin-left: 280px;
    min-height: 100vh;
    display: flex; flex-direction: column;
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 85%; max-width: 300px;
        box-shadow: 10px 0 30px rgba(0,0,0,0.1);
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }

    .mobile-header {
        display: flex !important;
        align-items: center; justify-content: space-between;
        padding: 15px 20px;
        background: var(--bg-sidebar);
        border-bottom: 1px solid var(--border-color);
        position: sticky; top: 0; z-index: 900;
    }

    .overlay {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
        z-index: 999; display: none;
    }
    .overlay.show { display: block; }
}

/* =========================================
   MOBILE NAV DEFAULTS
   Sidebar and overlay are hidden by default;
   JS (.show class) reveals them on mobile.
   ========================================= */
.mobile-header { display: none; }
.overlay { display: none; }
