/* ============================================
   SIDEBAR MOBILE - Passe sous le header
   ============================================ */

/* Overlay - couvre uniquement le main */
.sidebar-mobile-overlay {
    display: none;
    position: fixed;
    top: 10rem; /* Commence sous le header */
    left: 0;
    width: 100%;
    height: calc(100% - 10rem);
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.sidebar-mobile-overlay.active {
    display: block;
}

/* Sidebar mobile */
.sidebar-mobile {
    position: fixed;
    top: -100%; /* Cachée au-dessus */
    left: 0;
    width: 100%;
    height: auto;
    max-height: 80vh;
    background: linear-gradient(224deg, rgba(92, 225, 230, 1) 0%, rgba(0, 121, 167, 1) 100%);
    z-index: 1000; /* Sous le header (1030) */
    border-radius: 0 0 20px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    transition: top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* État actif - visible sous le header */
.sidebar-mobile.active {
    top: 10rem;
}

/* Header de la sidebar */
.sidebar-mobile-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

/* Formulaire de recherche */
.sidebar-mobile-search {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-mobile-search input {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 4px;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.9);
}

.sidebar-mobile-search button {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.sidebar-mobile-search button svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* Liste des menus */
.sidebar-mobile-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-mobile-menu > li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-mobile-menu > li > a {
    display: block;
    padding: 1.2rem 1.5rem;
    color: white;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 500;
    transition: background 0.2s ease;
}

.sidebar-mobile-menu > li > a:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Header de l'item de menu avec sous-menu */
.menu-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 1.5rem;
}

.menu-item-header > a {
    flex: 1;
    color: white;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 500;
}

/* Bouton de toggle pour les sous-menus */
.submenu-toggle {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    margin-left: 1rem;
    transition: transform 0.3s ease;
    font-size: 1rem;
}

.submenu-toggle[aria-expanded="true"] {
    transform: rotate(180deg);
}

.toggle-icon {
    display: block;
    transition: transform 0.3s ease;
}

/* Sous-menus */
.sidebar-mobile-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.15);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.sidebar-mobile-submenu:not(.hidden) {
    max-height: 500px;
    opacity: 1;
}

/* Classe pour cacher le sous-menu */
.sidebar-mobile-submenu.hidden {
    display: none;
}

.sidebar-mobile-submenu > li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-mobile-submenu > li:last-child {
    border-bottom: none;
}

.sidebar-mobile-submenu > li > a {
    display: block;
    padding: 1rem 1.5rem 1rem 2.5rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 1.1rem;
    transition: background 0.2s ease, padding-left 0.2s ease;
}

.sidebar-mobile-submenu > li > a:hover {
    background: rgba(255, 255, 255, 0.1);
    padding-left: 3rem;
    color: white;
}

/* Style pour les items avec sous-menu */
.has-submenu {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.has-submenu.open > .menu-item-header {
    background: rgba(255, 255, 255, 0.05);
}

/* Menu secondaire */
.sidebar-mobile-secondary {
    list-style: none;
    margin: 0;
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-mobile-secondary > li > a {
    display: block;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.2s ease;
}

.sidebar-mobile-secondary > li > a:hover {
    color: white;
}

/* Section utilisateur */
.sidebar-mobile-user {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-mobile-user a {
    display: block;
    padding: 0.8rem;
    color: white;
    text-decoration: none;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.sidebar-mobile-user a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-mobile-user .logout {
    background: rgba(220, 53, 69, 0.8);
    text-align: center;
}

.sidebar-mobile-user .logout:hover {
    background: rgba(220, 53, 69, 1);
}

/* Animation d'entrée des items */
.sidebar-mobile.active .sidebar-mobile-menu > li {
    opacity: 0;
    transform: translateY(-20px);
    animation: slideDown 0.4s ease forwards;
}

.sidebar-mobile.active .sidebar-mobile-menu > li:nth-child(1) { animation-delay: 0.05s; }
.sidebar-mobile.active .sidebar-mobile-menu > li:nth-child(2) { animation-delay: 0.1s; }
.sidebar-mobile.active .sidebar-mobile-menu > li:nth-child(3) { animation-delay: 0.15s; }
.sidebar-mobile.active .sidebar-mobile-menu > li:nth-child(4) { animation-delay: 0.2s; }
.sidebar-mobile.active .sidebar-mobile-menu > li:nth-child(5) { animation-delay: 0.25s; }
.sidebar-mobile.active .sidebar-mobile-menu > li:nth-child(6) { animation-delay: 0.3s; }
.sidebar-mobile.active .sidebar-mobile-menu > li:nth-child(7) { animation-delay: 0.35s; }

/* Animation des sous-menus */
.sidebar-mobile-submenu > li {
    opacity: 0;
    transform: translateX(-10px);
}

.sidebar-mobile.active .sidebar-mobile-submenu > li {
    animation: slideInRight 0.3s ease forwards;
}

.sidebar-mobile.active .sidebar-mobile-submenu > li:nth-child(1) { animation-delay: 0.2s; }
.sidebar-mobile.active .sidebar-mobile-submenu > li:nth-child(2) { animation-delay: 0.25s; }
.sidebar-mobile.active .sidebar-mobile-submenu > li:nth-child(3) { animation-delay: 0.3s; }
.sidebar-mobile.active .sidebar-mobile-submenu > li:nth-child(4) { animation-delay: 0.35s; }
.sidebar-mobile.active .sidebar-mobile-submenu > li:nth-child(5) { animation-delay: 0.4s; }

@keyframes slideInRight {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive - uniquement sur mobile */
@media (min-width: 992px) {
    .sidebar-mobile,
    .sidebar-mobile-overlay {
        display: none !important;
    }
}