/* =========================================
   VARIABLES DE COULEURS (Mode Clair)
   ========================================= */
:root {
    --bg-color: #f4f5f7;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --primary-color: #FF8300;
    --primary-hover: #e67600;
    --error-bg: #fee2e2;
    --error-text: #dc2626;
}

/* =========================================
   VARIABLES DE COULEURS (Mode Sombre)
   ========================================= */
[data-theme="dark"] {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #f5f5f5;
    --text-muted: #a0aab5;
    --border-color: #333333;
    --input-bg: #2d2d2d;
    --primary-color: #FF8300;
    --primary-hover: #e67600;
    --error-bg: #442323;
    --error-text: #ff6b6b;
}

/* =========================================
   STYLES GLOBAUX
   ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* =========================================
   PAGE DE CONNEXION / INSCRIPTION
   ========================================= */
.login-card {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    text-align: center;
    position: relative;
    transition: background-color 0.3s ease;
}

.login-card h1 { font-size: 24px; font-weight: 600; color: var(--text-main); margin-bottom: 8px; }
.login-card p { font-size: 14px; color: var(--text-muted); margin-bottom: 30px; }

.error-message {
    background-color: var(--error-bg);
    color: var(--error-text);
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: left;
    border-left: 4px solid var(--error-text);
}

.form-group { text-align: left; margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background-color: var(--input-bg);
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 131, 0, 0.15);
}

.btn-submit {
    width: 100%;
    background-color: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    font-size: 16px;
    padding: 14px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    margin-top: 10px;
}

.btn-submit:hover { background-color: var(--primary-hover); }
.btn-submit:active { transform: translateY(1px); }

.forgot-password {
    display: inline-block;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.forgot-password:hover { color: var(--primary-color); }

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    transition: color 0.2s;
}

.theme-toggle:hover { color: var(--primary-color); }

/* =========================================
   GESTION DES LOGOS (Clair / Sombre)
   ========================================= */
.sidebar-logo {
    max-width: 100%;
    height: auto;
    max-height: 130px;
    display: block;
    margin: 0 auto;
}

.login-logo {
    max-width: 100%;
    height: auto;
    max-height: 130px;
    display: block;
    margin: 0 auto 15px auto;
}

.logo-dark { display: none !important; }
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }

/* =========================================
   STYLES DU DASHBOARD (Menu latéral "Îlots")
   ========================================= */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background-color: var(--bg-color);
}

/* Conteneur invisible de la sidebar */
.sidebar {
    width: 290px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background-color: transparent;
    border-right: none;
    height: 100vh;
    position: sticky;
    top: 0;
}

/* Encart 1 : Le Logo */
.sidebar-header {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}

/* Encart 2 : Le Menu */
.nav-menu {
    background-color: var(--card-bg);
    padding: 20px 15px; /* Le fameux padding autour des liens */
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    list-style: none;
    margin: 0;
    /* On a retiré flex-grow: 1 pour qu'il colle à son contenu */
    height: fit-content; 
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background-color 0.3s ease;
}

/* Encart 1.5 : Profil Utilisateur */
.sidebar-user {
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.3s ease;
}

/* Bulle avec les initiales */
.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background-color: rgba(255, 131, 0, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 15px;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-grow: 1; /* Prend tout l'espace libre pour pousser le bouton à droite */
}

/* Nouveau style pour le bouton thème dans la sidebar */
.theme-toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    transition: color 0.2s ease, transform 0.2s ease;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.theme-toggle-sidebar:hover {
    color: var(--primary-color);
    background-color: rgba(255, 131, 0, 0.1);
    transform: scale(1.1); /* Petit effet de zoom au survol */
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Si le nom est trop long, ça mettra des "..." */
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
    font-weight: 500;
}

/* Boutons du menu */
.nav-link {
    display: block;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(255, 131, 0, 0.1);
    color: var(--primary-color);
}

/* Bouton Déconnexion */
.nav-link.logout {
    color: var(--error-text);
    /* On remplace 'auto' par une marge fixe pour le séparer un peu des autres liens */
    margin-top: 15px; 
    background-color: rgba(220, 38, 38, 0.04);
}

.nav-link.logout:hover {
    background-color: var(--error-bg);
    color: var(--error-text);
}

/* =========================================
   CONTENU PRINCIPAL DU DASHBOARD
   ========================================= */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: transparent;
}

/* Barre de navigation du haut (Ajustée style "Îlot") */
.topbar {
    height: 70px;
    background-color: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    margin: 20px 20px 0 0; /* Aligné avec la marge de la sidebar */
    border-radius: 20px; /* Arrondi cohérent */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.user-info {
    font-weight: 600;
    color: var(--text-main);
}

/* Espace central de travail */
.content-area {
    padding: 30px 20px 30px 0;
    overflow-y: auto;
}

/* Cartes de statistiques */
.dashboard-cards {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 20px; /* Arrondi cohérent */
    flex: 1;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.stat-card h3 { color: var(--text-muted); font-size: 14px; margin-bottom: 10px; }
.stat-card .number { font-size: 28px; font-weight: bold; color: var(--primary-color); }

/* Style du lien vers le profil dans la sidebar */
.user-name-link {
    text-decoration: none;
    color: inherit;
    display: inline-block;
    transition: color 0.2s ease;
}

.user-name-link:hover .user-name {
    color: var(--primary-color);
}

/* Style de la carte de profil */
.profile-card {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    max-width: 600px;
    margin-top: 20px;
}
    /* Assure que le logo se comporte bien comme un lien cliquable */
    .sidebar-header a {
        display: block;
        cursor: pointer;
        text-decoration: none;
    }