/* ============================================
   NAVIGATION SYSTEM - Sidebar & User Menu
   ============================================ */

/* Compatibilité avec le header existant */
.main-header {
    position: relative;
    z-index: 1000;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: relative;
}

.header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    min-width: 44px;
}

.header-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============================================
   MENU TOGGLE BUTTON (Hamburger)
   ============================================ */

.nav-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
    z-index: 1001;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    flex-shrink: 0;
}

.nav-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.nav-menu-toggle:active {
    transform: scale(0.95);
}

.nav-menu-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ============================================
   SIDEBAR
   ============================================ */

.main-sidebar {
    position: fixed;
    top: 0;
    left: -360px;
    width: 360px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.98);
    border-right: 1.5px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    z-index: 2000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
}

.main-sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.sidebar-logo span {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
}

.sidebar-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(90deg);
}

.sidebar-nav {
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 17px;
    font-weight: 600;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    position: relative;
}

/* Style gris foncé uniquement pour les liens dans le sidebar */
.main-sidebar .nav-link {
    background: #2b2b2b;
    color: #e0e0e0;
    border: 1px solid #3f3f3f;
    border-radius: 16px;
    margin: 4px 20px;
    border-left: 1px solid #3a3a3a;
}

.nav-link i {
    width: 24px;
    font-size: 18px;
    text-align: center;
}

/* Icônes dans le sidebar */
.main-sidebar .nav-link i {
    color: #e0e0e0;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-left-color: rgba(255, 255, 255, 0.3);
    padding-left: 24px;
}

/* Hover pour les liens du sidebar */
.main-sidebar .nav-link:hover {
    background: #333333;
    color: #ffffff;
    border-color: #444444;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.main-sidebar .nav-link:hover i {
    color: #ffffff;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-left-color: #ffffff;
}

/* Active pour les liens du sidebar */
.main-sidebar .nav-link.active {
    background: #333333;
    color: #ffffff;
    border-color: #444444;
}

.main-sidebar .nav-link.active i {
    color: #ffffff;
}

.nav-link-primary {
    background: #2b2b2b;
    color: #e0e0e0;
    margin: 8px 20px;
    border-radius: 16px;
    border-left: none;
    border: 1px solid #3a3a3a;
}

.nav-link-primary:hover {
    background: #333333;
    color: #ffffff;
    border-color: #444444;
    padding-left: 20px;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.nav-link-primary i {
    color: #e0e0e0;
}

.nav-link-primary:hover i {
    color: #ffffff;
}

.nav-link-admin {
    color: #FFD700;
}

.nav-link-admin:hover {
    color: #FFD700;
    border-left-color: #FFD700;
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 12px 20px;
}

/* ============================================
   SIDEBAR OVERLAY
   ============================================ */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   USER MENU (Desktop)
   ============================================ */

.user-menu {
    position: relative;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.user-menu-button:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-email {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-button i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.user-menu-button:hover i {
    transform: translateY(2px);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: rgba(0, 0, 0, 0.98);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
}

.user-menu-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.1);
}

.user-menu-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.8) 100%);
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    flex-shrink: 0;
}

.user-menu-info {
    flex: 1;
    min-width: 0;
}

.user-menu-name {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.user-menu-item i {
    width: 20px;
    font-size: 16px;
    text-align: center;
}

.user-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    padding-left: 24px;
}

.user-menu-item-admin {
    color: #FFD700;
}

.user-menu-item-admin:hover {
    color: #FFD700;
}

.user-menu-item-danger {
    color: #ff4444;
}

.user-menu-item-danger:hover {
    background: rgba(255, 68, 68, 0.1);
    color: #ff4444;
}

/* ============================================
   AUTH BUTTONS (Non connecté)
   ============================================ */

.auth-buttons {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Masquer les boutons d'authentification sur desktop (PC) - mais garder le menu hamburger */
@media (min-width: 769px) {
    .auth-buttons {
        display: none !important;
    }
    
    /* Masquer aussi le bouton de notifications sur desktop */
    #notificationButtonHeader,
    .notification-toggle-btn {
        display: none !important;
    }
    
    /* Le menu hamburger reste visible sur desktop */
    .nav-menu-toggle {
        display: flex !important;
    }
}

.btn-auth {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 1.5px solid transparent;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    touch-action: manipulation;
    min-height: 44px;
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 10;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.btn-auth-primary {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #3a3a3a;
}

.btn-auth-primary:hover {
    background: #333333;
    color: #ffffff;
    border-color: #444444;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-auth-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-auth-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-auth i {
    font-size: 16px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .main-sidebar {
        width: 100%;
        max-width: 100%;
        left: -100%;
    }

    .main-sidebar.active {
        left: 0;
    }

    /* Ajuster les marges des liens du sidebar sur mobile */
    .main-sidebar .nav-link {
        margin: 4px 16px;
        padding: 14px 16px;
        background: transparent;
        border: none;
        box-shadow: none;
        color: #ffffff;
    }

    .main-sidebar .nav-link-primary {
        margin: 8px 16px;
        background: transparent;
        border: none;
        box-shadow: none;
        color: #ffffff;
    }

    .main-sidebar .nav-link:hover,
    .main-sidebar .nav-link-primary:hover {
        background: rgba(255, 255, 255, 0.08);
        border: none;
        box-shadow: none;
        transform: none;
        padding-left: 16px;
    }

    .user-menu-button .user-email {
        display: none;
    }

    .user-menu-button {
        padding: 8px 12px;
        min-width: 44px;
    }

    .user-menu-dropdown {
        right: 0;
        left: auto;
        width: calc(100vw - 32px);
        max-width: 320px;
    }

    .auth-buttons {
        gap: 8px;
        flex-direction: column;
    }

    .btn-auth {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        min-width: auto;
    }

    .btn-auth-text {
        display: inline !important;
    }

    .btn-auth i {
        margin-right: 8px;
    }

    /* S'assurer que le menu hamburger est toujours visible */
    .nav-menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

@media (max-width: 480px) {
    .main-sidebar {
        width: 100%;
        max-width: 100%;
        left: -100%;
    }

    .main-sidebar.active {
        left: 0;
    }

    /* Ajuster encore plus les marges sur très petit écran */
    .main-sidebar .nav-link {
        margin: 4px 12px;
        padding: 12px 14px;
        font-size: 15px;
        background: transparent;
        border: none;
        box-shadow: none;
        color: #ffffff;
    }

    .main-sidebar .nav-link-primary {
        margin: 8px 12px;
        background: transparent;
        border: none;
        box-shadow: none;
        color: #ffffff;
    }

    .user-menu-dropdown {
        width: calc(100vw - 16px);
        max-width: 100%;
        right: 8px;
    }

    .auth-buttons {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .btn-auth {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
        font-size: 15px;
    }

    .btn-auth-text {
        display: inline !important;
    }

    /* Menu hamburger plus visible sur très petit écran */
    .nav-menu-toggle {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
        font-size: 20px;
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.3);
    }

    .header-container {
        padding: 12px 16px !important;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.main-sidebar.active {
    animation: slideInLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

.main-sidebar::-webkit-scrollbar {
    width: 6px;
}

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

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

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