/* ==========================================================================
   Variables & Reset (Palette modernisée et plus douce, styles premium)
   ========================================================================= */
:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: rgba(2, 132, 199, 0.08); /* Pour les effets de hover et focus */
    --dark-bg: #0f172a;
    --sidebar-bg: #1e293b;
    --light-bg: #f1f5f9; /* Légèrement plus chaud que f8fafc, pour moins de fatigue oculaire */
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #334155;
    --text-muted: #64748b;
    --success: #10b981;
    --radius-lg: 12px;
    --radius-md: 8px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.03);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.05), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
    --transition: all 0.2s ease-in-out;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
}

body { 
    background: var(--light-bg); 
    color: var(--text-main); 
    display: flex; 
    min-height: 100vh; 
    overflow-x: hidden; /* Empêche tout défilement horizontal */
}

/* ==========================================================================
   Iconographie (Styles pour tes icônes si tu en utilises)
   ========================================================================= */
.icon {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.75rem;
    vertical-align: middle;
}

/* ==========================================================================
   Menu Latéral (Sidebar) - Version Desktop
   ========================================================================= */
.sidebar { 
    width: 280px; 
    background: var(--sidebar-bg); 
    color: white; 
    padding: 24px; 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0;
    transition: var(--transition);
}

.logo-container { 
    text-align: center; 
    margin-bottom: 30px; 
    padding-bottom: 20px; 
    border-bottom: 1px solid #334155; 
}
.logo-container img { 
    max-width: 80%; 
    height: auto; 
    object-fit: contain; 
}
.logo-container p { 
    font-size: 11px; 
    color: #94a3b8; 
    margin-top: 6px; 
    text-transform: uppercase; 
    letter-spacing: 1.5px; 
    font-weight: 600;
}

.sidebar a { 
    display: flex; 
    align-items: center; 
    color: #cbd5e1; 
    padding: 12px 16px; 
    text-decoration: none; 
    border-radius: var(--radius-md); 
    margin-bottom: 4px; /* Un peu moins pour un espacement plus serré */
    font-weight: 500; 
    font-size: 14px;
    transition: var(--transition); 
}
.sidebar a:hover, .sidebar a.active { 
    background: var(--primary); 
    color: white; 
}

/* ==========================================================================
   Contenu Principal (Dashboard, Cartes, Formulaires)
   ========================================================================= */
.main-content { 
    flex: 1; 
    padding: 40px; 
    overflow-y: auto; 
    width: 100%;
}

.header-title { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 32px; 
    gap: 20px;
}
.header-title h1 { 
    color: var(--dark-bg); 
    font-size: 26px; 
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Look des Cartes */
.card { 
    background: var(--card-bg); 
    padding: 28px; 
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-md); 
    margin-bottom: 28px; 
    border: 1px solid var(--border-color); 
}
.card h2 { 
    font-size: 18px; 
    color: var(--dark-bg); 
    margin-bottom: 22px; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    font-weight: 600;
}

/* Grille des Formulaires */
.form-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); 
    gap: 24px; 
}
.form-group { 
    display: flex; 
    flex-direction: column; 
}
.form-group label { 
    font-weight: 600; 
    margin-bottom: 8px; 
    font-size: 13px; 
    color: #475569; 
}

/* Inputs & Sélection */
input, select, textarea { 
    padding: 11px 16px; 
    border: 1px solid #cbd5e1; 
    border-radius: var(--radius-md); 
    font-size: 14px; 
    transition: var(--transition); 
    background: #fff; 
    width: 100%;
    color: var(--text-main);
}
input:focus, select:focus, textarea:focus { 
    outline: none; 
    border-color: var(--primary); 
    box-shadow: 0 0 0 4px var(--primary-light); 
}
input[readonly] { 
    background: #f1f5f9; 
    color: var(--text-muted); 
    cursor: not-allowed; 
}

/* Boutons */
button { 
    background: var(--primary); 
    color: white; 
    border: none; 
    padding: 12px 26px; 
    border-radius: var(--radius-md); 
    cursor: pointer; 
    font-weight: 600; 
    font-size: 14px;
    transition: var(--transition); 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
button:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
button:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Tableaux Responsives */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Défilement fluide sur iOS */
    margin-top: 15px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    text-align: left; 
    background: #fff;
}
th { 
    background: #f8fafc; 
    color: #64748b; 
    padding: 16px; 
    font-size: 12px; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color); 
    white-space: nowrap;
}
td { 
    padding: 16px; 
    border-bottom: 1px solid var(--border-color); 
    font-size: 14px; 
    vertical-align: middle; 
    white-space: nowrap;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td { 
    background: #f8fafc; 
}

/* Badges */
.badge { 
    padding: 6px 12px; 
    border-radius: 9999px; 
    font-size: 12px; 
    font-weight: 600; 
    display: inline-block; 
}
.badge-active { background: #dcfce7; color: #16a34a; }
.badge-inactive { background: #fee2e2; color: #dc2626; }
.badge-info { background: #e0f2fe; color: #0284c7; }


/* ==========================================================================
   ADAPTATION MOBILE & TABLETTE (Media Queries Ultra-Optimisées)
   ========================================================================= */

@media (max-width: 992px) {
    body {
        flex-direction: column; /* On empile la sidebar au-dessus du contenu */
    }

    /* La sidebar devient une barre supérieure fixe et moderne */
    .sidebar {
        width: 100%;
        padding: 12px 20px;
        position: sticky; /* Reste en haut au défilement */
        top: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
        gap: 12px;
    }

    /* Le logo passe à gauche et prend moins de place */
    .logo-container {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
        text-align: left;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    
    .logo-container img {
        max-width: 120px;
        height: 30px;
    }

    .logo-container p {
        display: none; /* Cache le sous-texte sur mobile pour gagner de la place */
    }

    /* Navigation horizontale fluide et scrollable avec le doigt */
    .sidebar-menu {
        flex-direction: row;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 4px; /* Un peu d'espace pour le défilement */
        gap: 8px;
        
        /* On masque la barre de défilement pour un effet application premium */
        -ms-overflow-style: none;  /* IE et Edge */
        scrollbar-width: none;  /* Firefox */
    }
    
    .sidebar-menu::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }

    .sidebar a {
        padding: 8px 14px;
        font-size: 13px;
        margin-bottom: 0;
        flex: 0 0 auto; /* Empêche les boutons de rétrécir */
    }
    
    .main-content {
        padding: 24px 16px; /* Plus compact pour les mobiles */
    }
}

@media (max-width: 576px) {
    .header-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .header-title h1 {
        font-size: 22px;
    }

    /* Les boutons prennent toute la largeur sur petit écran pour faciliter le clic */
    .header-title button, button {
        width: 100%; 
    }

    .card {
        padding: 20px 16px;
        border-radius: var(--radius-md);
    }

    .form-grid {
        grid-template-columns: 1fr; /* Force 1 seule colonne parfaite pour les inputs */
        gap: 16px;
    }
}