/* Sidebar Menu CSS */
:root {
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #2c3e50;
    --sidebar-hover: #34495e;
    --sidebar-text: #ecf0f1;
    --sidebar-active: #3498db;
    --sidebar-submenu-bg: #1a252f;
    --mobile-header-height: 60px;
}

/* Wrapper pour le layout avec sidebar */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

/* Sidebar collapsed */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar header */
.sidebar-header {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.sidebar-brand i {
    margin-right: 10px;
    font-size: 1.8rem;
}

.sidebar.collapsed .sidebar-brand span {
    display: none;
}

.sidebar.collapsed .sidebar-brand-icon {
    display: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.sidebar-toggle:hover {
    background-color: var(--sidebar-hover);
}

/* Sidebar menu */
.sidebar-menu {
    padding: 20px 0;
}

.sidebar-item {
    position: relative;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background-color: var(--sidebar-active);
    color: #fff;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #fff;
}

.sidebar-link i {
    width: 24px;
    margin-right: 15px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 15px 10px;
    position: relative;
    cursor: pointer;
}

.sidebar.collapsed .sidebar-link span {
    display: none;
}

.sidebar.collapsed .sidebar-link i {
    margin-right: 0;
    font-size: 1.2rem;
}

/* Assurer que les liens restent cliquables en mode collapsed */
.sidebar.collapsed .sidebar-link:not(.sidebar-dropdown-toggle) {
    pointer-events: all;
}

.sidebar.collapsed .sidebar-dropdown-toggle {
    pointer-events: all;
}

/* Indicateur pour les éléments avec sous-menu en mode collapsed */
.sidebar.collapsed .sidebar-dropdown-toggle::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 6px;
    height: 6px;
    background: var(--sidebar-active);
    border-radius: 50%;
    opacity: 0.6;
}

/* Dropdown pour sidebar */
.sidebar-dropdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: var(--sidebar-submenu-bg);
}

.sidebar-dropdown.show {
    max-height: 500px;
}

.sidebar-dropdown .sidebar-link {
    padding-left: 50px;
    font-size: 0.9rem;
}

.sidebar.collapsed .sidebar-dropdown {
    display: none;
}

.sidebar-link .dropdown-toggle::after {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
}

.sidebar-link.collapsed .dropdown-toggle::after {
    transform: translateY(-50%) rotate(-90deg);
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    background-color: #f8f9fa;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top bar */
.top-bar {
    background-color: #fff;
    padding: 15px 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.user-menu {
    display: flex;
    align-items: center;
}

.user-dropdown {
    margin-left: 20px;
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--sidebar-bg);
    cursor: pointer;
    padding: 5px 10px;
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Popup menu pour sidebar collapsed */
.sidebar-collapsed-popup {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    min-width: 200px;
    max-width: 300px;
    z-index: 9999;
    animation: fadeInScale 0.2s ease-out;
}

.sidebar-collapsed-popup .sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 0;
}

.sidebar-collapsed-popup .sidebar-link:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

.sidebar-collapsed-popup .sidebar-link i {
    width: 20px;
    margin-right: 12px;
    text-align: center;
    font-size: 0.9rem;
}

.sidebar-collapsed-popup .sidebar-link span {
    font-size: 0.9rem;
    font-weight: 500;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Tooltip amélioré */
.sidebar-tooltip {
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 9998;
    position: fixed;
}

.sidebar-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #333;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .main-content.expanded {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .sidebar-toggle {
        display: none;
    }
}

@media (max-width: 576px) {
    .sidebar {
        width: 100%;
    }
    
    .top-bar {
        padding: 15px;
    }
}

/* Animation pour les éléments du menu */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar-link {
    animation: slideIn 0.3s ease;
}

/* Scrollbar personnalisée pour la sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Badge de notification dans le menu */
.sidebar-badge {
    background-color: #e74c3c;
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: auto;
    margin-right: 10px;
}

.sidebar.collapsed .sidebar-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
}

/* Section divider */
.sidebar-section {
    margin: 20px 0;
    padding: 0 20px;
}

.sidebar-section-title {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.sidebar.collapsed .sidebar-section-title {
    display: none;
}

/* Footer dans la sidebar */
.sidebar-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar.collapsed .sidebar-footer {
    padding: 10px;
    text-align: center;
}

.sidebar.collapsed .sidebar-footer span {
    display: none;
}