/* =============================================
   MOBILE SIDEBAR - Style AdminLTE
   Sidebar coulissante pour mobile uniquement
   Desktop: aucun changement
   ============================================= */

/* ---- VISIBLE UNIQUEMENT SUR MOBILE (<992px) ---- */

/* Overlay sombre derrière le sidebar */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.mobile-sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Le sidebar lui-même */
.mobile-sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    background: #1a202c;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-shadow: 4px 0 25px rgba(0,0,0,0.3);
}
.mobile-sidebar.open {
    transform: translateX(0);
}

/* ---- HEADER DU SIDEBAR ---- */
.ms-header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 2;
}
.ms-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    text-decoration: none;
}
.ms-brand-icon {
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
}
.ms-brand-text {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    color: white;
}
.ms-brand-text small {
    display: block;
    font-weight: 400;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 2px;
}
.ms-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}
.ms-close:hover, .ms-close:active {
    background: rgba(255,255,255,0.25);
}

/* ---- NAVIGATION ---- */
.ms-nav {
    padding: 0.5rem 0;
}
.ms-nav-section {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.35);
    margin-top: 0.5rem;
}

/* Lien de navigation */
.ms-nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    gap: 0.75rem;
}
.ms-nav-item:hover, .ms-nav-item:active, .ms-nav-item.active {
    background: rgba(255,255,255,0.08);
    color: white;
    border-left-color: #3b82f6;
}
.ms-nav-item i {
    width: 20px;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.7;
}
.ms-nav-item:hover i, .ms-nav-item.active i {
    opacity: 1;
}

/* Item parent (avec sous-menu) */
.ms-nav-parent {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.ms-nav-parent .ms-arrow {
    margin-left: auto;
    font-size: 0.65rem;
    transition: transform 0.25s ease;
    opacity: 0.5;
}
.ms-nav-parent.open .ms-arrow {
    transform: rotate(90deg);
    opacity: 1;
}

/* Sous-menu */
.ms-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0,0,0,0.15);
}
.ms-nav-parent.open + .ms-submenu,
.ms-submenu.open {
    max-height: 500px;
}
.ms-submenu .ms-nav-item {
    padding: 0.6rem 1rem 0.6rem 2.75rem;
    font-size: 0.82rem;
    border-left: none;
    color: rgba(255,255,255,0.65);
}
.ms-submenu .ms-nav-item:hover, .ms-submenu .ms-nav-item:active {
    color: white;
    background: rgba(255,255,255,0.06);
}
.ms-submenu .ms-nav-item i {
    font-size: 0.75rem;
    width: 18px;
}

/* Séparateur */
.ms-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0.5rem 1rem;
}

/* ---- ACTIONS EN BAS ---- */
.ms-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}
.ms-footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}
.ms-footer-btn.donate {
    background: linear-gradient(135deg, #f4d03f, #f39c12);
    color: #1a1a2e;
}
.ms-footer-btn.donate:hover {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    transform: translateY(-1px);
}
.ms-footer-btn.search {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
}
.ms-footer-btn.search:hover {
    background: rgba(255,255,255,0.15);
}
.ms-footer-btn.theme-toggle {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
}

/* ---- BOUTON HAMBURGER CUSTOM (remplace le toggler Bootstrap sur mobile) ---- */
.ms-hamburger {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    z-index: 1100;
    position: relative;
}
.ms-hamburger-lines {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 24px;
}
.ms-hamburger-lines span {
    display: block;
    height: 2.5px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}
.ms-hamburger.active .ms-hamburger-lines span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.ms-hamburger.active .ms-hamburger-lines span:nth-child(2) {
    opacity: 0;
}
.ms-hamburger.active .ms-hamburger-lines span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ---- RESPONSIVE ---- */

/* Sur mobile/tablette < 992px : sidebar visible, toggler bootstrap caché */
@media (max-width: 991.98px) {
    .mobile-sidebar,
    .mobile-sidebar-overlay {
        display: block;
    }
    .ms-hamburger {
        display: flex;
        align-items: center;
    }
    /* Cacher le toggler Bootstrap d'origine */
    .navbar-toggler {
        display: none !important;
    }
    /* Cacher le collapse Bootstrap d'origine */
    .navbar-collapse {
        display: none !important;
    }
    /* Navbar simplifiée sur mobile */
    .navbar {
        padding: 0.5rem 0 !important;
    }
    .navbar .container {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}

/* Sur desktop >= 992px : sidebar complètement caché */
@media (min-width: 992px) {
    .mobile-sidebar,
    .mobile-sidebar-overlay,
    .ms-hamburger {
        display: none !important;
    }
}

/* Dark mode */
[data-theme="dark"] .mobile-sidebar {
    background: #0f172a;
}
[data-theme="dark"] .ms-header {
    background: linear-gradient(135deg, #1e3a5f, #1e40af);
}
[data-theme="dark"] .ms-submenu {
    background: rgba(0,0,0,0.25);
}

/* Bloquer le scroll du body quand le sidebar est ouvert */
body.ms-open {
    overflow: hidden !important;
    touch-action: none;
}
