:root {
    --primary-color: #f97316; /* Orange */
    --secondary-color: #22c55e; /* Green */
    --light-color: #f8f9fa; /* Light Gray */
    --dark-color: #2d3748; /* Dark Gray */
    --accent-color: #ffffff; /* White */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--light-color);
    margin: 0;
    padding: 0;
    color: var(--dark-color);
    overflow-x: hidden;
}

/* ===== SIDEBAR STYLES ===== */
.sidebar {
    background: var(--dark-color);
    color: var(--accent-color);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    padding-top: 20px;
    transition: all 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

/* Sidebar collapsed state */
.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .sidebar-header h3,
.sidebar.collapsed .sidebar-header p,
.sidebar.collapsed .user-badge,
.sidebar.collapsed .sidebar-menu span,
.sidebar.collapsed .dropdown-toggle::after {
    display: none !important;
}

.sidebar.collapsed .sidebar-menu a {
    justify-content: center;
    padding: 15px 10px;
    border-left: 2px solid transparent;
}

.sidebar.collapsed .sidebar-menu i {
    margin-right: 0;
    font-size: 1.3rem;
}

.sidebar.collapsed .sidebar-menu a:hover,
.sidebar.collapsed .sidebar-menu a.active {
    border-left: 2px solid var(--primary-color);
}

/* Sidebar header */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 120px;
}

.sidebar-header h3 {
    font-weight: 700;
    font-size: 1.4rem;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.3s ease;
}

.sidebar-header p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
    transition: opacity 0.3s ease;
}

.user-badge {
    margin-top: 10px;
    text-align: center;
    transition: opacity 0.3s ease;
}

/* ===== SIDEBAR TOGGLE BUTTON ===== */
.sidebar-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1001;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Rotation de l'icône quand le sidebar est réduit */
.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* ===== MOBILE TOGGLE BUTTON ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    background: var(--primary-color);
    border: none;
    color: white;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.mobile-toggle:hover {
    background: #ea580c;
    transform: scale(1.05);
}

/* ===== SIDEBAR CLOSE BUTTON (MOBILE) ===== */
.sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== OVERLAY FOR MOBILE ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Sidebar menu */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

.sidebar-menu li {
    padding: 0;
}

.sidebar-menu a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    display: flex;
    align-items: center;
    padding: 14px 20px;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-size: 0.95rem;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
    border-left: 4px solid var(--primary-color);
}

.sidebar-menu i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: margin 0.3s ease;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 280px;
    padding: 24px;
    min-height: 100vh;
    transition: all 0.3s ease;
    position: relative;
}

.main-content.expanded {
    margin-left: 70px;
}

/* Réinitialisation pour la page de connexion */
body:not(.authenticated) .main-content {
    margin-left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        margin-left: 240px;
    }

    .sidebar.collapsed {
        width: 70px;
    }

    .main-content.expanded {
        margin-left: 70px;
    }
}

@media (max-width: 768px) {
    /* Mobile toggle button */
    .mobile-toggle {
        display: flex;
    }

    /* Sidebar en mode mobile */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        box-shadow: 2px 0 15px rgba(0,0,0,0.3);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: 280px; /* En mobile, on montre toujours le sidebar complet */
        transform: translateX(-100%);
    }

    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    /* Cacher le toggle du sidebar en mobile */
    .sidebar-toggle {
        display: none;
    }

    /* Afficher le bouton fermer pour mobile */
    .sidebar-close {
        display: flex;
    }

    /* Overlay pour mobile */
    .sidebar-overlay.active {
        display: block;
    }

    /* Main content en mode mobile */
    .main-content {
        margin-left: 0;
        padding: 80px 20px 20px 20px; /* Plus d'espace en haut pour le bouton mobile */
    }

    .main-content.expanded {
        margin-left: 0;
    }

    /* Ajustements pour le header du sidebar en mobile */
    .sidebar-header {
        padding-top: 60px; /* Espace pour le bouton de fermeture */
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 80px 16px 16px 16px;
    }

    .sidebar {
        width: 100%; /* Prend toute la largeur sur très petits écrans */
        max-width: 320px;
    }

    .mobile-toggle {
        top: 15px;
        left: 15px;
        width: 40px;
        height: 40px;
    }
}

/* ===== SCROLLBAR STYLING ===== */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar-menu li {
    animation: slideIn 0.3s ease forwards;
}

.sidebar-menu li:nth-child(1) { animation-delay: 0.1s; }
.sidebar-menu li:nth-child(2) { animation-delay: 0.15s; }
.sidebar-menu li:nth-child(3) { animation-delay: 0.2s; }
.sidebar-menu li:nth-child(4) { animation-delay: 0.25s; }
.sidebar-menu li:nth-child(5) { animation-delay: 0.3s; }
.sidebar-menu li:nth-child(6) { animation-delay: 0.35s; }

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .main-content,
    .sidebar-toggle,
    .sidebar-menu a {
        transition: none;
    }

    .sidebar-menu li {
        animation: none;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: none;
    }
}