/* ===================================
   NAVIGATION LAYOUT SYSTEM
   Gestion dynamique des positions : TOP, BOTTOM, LEFT, RIGHT
   =================================== */

/* === POSITION TOP (default) === */
.nav-position-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4000;
}

.nav-position-top .nav-container {
    flex-direction: row;
}

.nav-position-top .nav-dropdown {
    position: absolute;
    top: 100%;
    margin-top: -0.25rem;
}

/* === POSITION BOTTOM === */
.nav-position-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 4000;
}

.nav-position-bottom .nav-container {
    flex-direction: row;
}

.nav-position-bottom .nav-dropdown {
    position: absolute;
    bottom: 100%;
    margin-bottom: -0.25rem;
}

.nav-position-bottom .nav-submenu {
    bottom: 0;
    top: auto;
}

/* === POSITION LEFT (sidebar compacte) === */
.nav-position-left {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4rem; /* 64px compact par défaut */
    z-index: 4000;
    overflow: hidden; /* Masquer le débordement */
    transition: width 0.3s ease-in-out;
}

.nav-position-left:hover {
    width: 16rem; /* 256px étendu au survol */
    overflow-y: auto; /* Activer scroll au survol */
    overflow-x: hidden;
}

.nav-position-left .nav-container {
    flex-direction: column;
    height: 100%;
    padding: 1rem 0;
    width: 16rem; /* Contenu toujours à largeur complète */
}

.nav-position-left .nav-logo {
    padding: 0 1rem;
    margin-bottom: 1.5rem;
    white-space: nowrap;
}

.nav-position-left .nav-logo span {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.nav-position-left:hover .nav-logo span {
    opacity: 1;
}

.nav-position-left .nav-links {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    max-height: calc(100vh - 6rem); /* Hauteur max = viewport - logo - marges */
}

.nav-position-left .nav-links > li {
    width: 100%;
}

.nav-position-left .nav-links a,
.nav-position-left .nav-links button {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    white-space: nowrap;
    position: relative;
}

.nav-position-left .nav-links .nav-label {
    opacity: 0;
    visibility: hidden;
    width: 0;
    transition: opacity 0.2s ease-in-out, visibility 0s 0.2s, width 0s 0.2s;
    margin-left: 0;
    overflow: hidden;
    white-space: nowrap;
}

.nav-position-left:hover .nav-links .nav-label {
    opacity: 1;
    visibility: visible;
    width: auto;
    margin-left: 0.5rem;
    transition: opacity 0.2s ease-in-out 0.1s, visibility 0s 0s, width 0s 0s;
}

.nav-position-left .nav-links i.fa-chevron-down,
.nav-position-left .nav-links i.fa-chevron-up {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    margin-left: auto;
}

.nav-position-left:hover .nav-links i.fa-chevron-down,
.nav-position-left:hover .nav-links i.fa-chevron-up {
    opacity: 1;
}

.nav-position-left .nav-dropdown {
    position: relative;
    width: 100%;
    margin-top: 0;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    border-radius: 0;
    max-height: 0 !important;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    display: block;
}

.nav-position-left .nav-dropdown:not(.hidden).show {
    max-height: 2000px !important;
}

.nav-position-left .nav-dropdown a {
    padding-left: 1rem;
}

.nav-position-left .nav-submenu {
    position: relative;
    left: 0;
    margin-left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.15);
    max-height: 0 !important;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    display: block;
}

.nav-position-left .nav-submenu:not(.hidden).show {
    max-height: 2000px !important;
}

.nav-position-left .nav-submenu a {
    padding-left: 1rem;
}

/* Espacer le chevron du texte dans les sous-menus */
.nav-position-left .nav-submenu-container button i.fa-chevron-right,
.nav-position-left .nav-submenu-container button i.fa-chevron-down {
    margin-left: 0.5rem;
}

.nav-position-left .nav-separator {
    display: none;
}

/* === POSITION RIGHT (sidebar compacte) === */
.nav-position-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 4rem; /* 64px compact par défaut */
    z-index: 4000;
    overflow: hidden; /* Masquer le débordement */
    transition: width 0.3s ease-in-out;
}

.nav-position-right:hover {
    width: 16rem; /* 256px étendu au survol */
    overflow-y: auto; /* Activer scroll au survol */
    overflow-x: hidden;
}

.nav-position-right .nav-container {
    flex-direction: column;
    height: 100%;
    padding: 1rem 0;
    width: 16rem; /* Contenu toujours à largeur complète */
}

.nav-position-right .nav-logo {
    padding: 0 1rem;
    margin-bottom: 1.5rem;
    white-space: nowrap;
}

.nav-position-right .nav-logo span {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.nav-position-right:hover .nav-logo span {
    opacity: 1;
}

.nav-position-right .nav-links {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    max-height: calc(100vh - 6rem); /* Hauteur max = viewport - logo - marges */
}

.nav-position-right .nav-links > li {
    width: 100%;
}

.nav-position-right .nav-links a,
.nav-position-right .nav-links button {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    white-space: nowrap;
    position: relative;
}

.nav-position-right .nav-links .nav-label {
    opacity: 0;
    visibility: hidden;
    width: 0;
    transition: opacity 0.2s ease-in-out, visibility 0s 0.2s, width 0s 0.2s;
    margin-left: 0;
    overflow: hidden;
    white-space: nowrap;
}

.nav-position-right:hover .nav-links .nav-label {
    opacity: 1;
    visibility: visible;
    width: auto;
    margin-left: 0.5rem;
    transition: opacity 0.2s ease-in-out 0.1s, visibility 0s 0s, width 0s 0s;
}

.nav-position-right .nav-links i.fa-chevron-down,
.nav-position-right .nav-links i.fa-chevron-up {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    margin-left: auto;
}

.nav-position-right:hover .nav-links i.fa-chevron-down,
.nav-position-right:hover .nav-links i.fa-chevron-up {
    opacity: 1;
}

.nav-position-right .nav-dropdown {
    position: relative;
    width: 100%;
    margin-top: 0;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    border-radius: 0;
    max-height: 0 !important;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    display: block;
}

.nav-position-right .nav-dropdown:not(.hidden).show {
    max-height: 2000px !important;
}

.nav-position-right .nav-dropdown a {
    padding-left: 1rem;
}

.nav-position-right .nav-submenu {
    position: relative;
    right: 0;
    margin-right: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.15);
    max-height: 0 !important;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    display: block;
}

.nav-position-right .nav-submenu:not(.hidden).show {
    max-height: 2000px !important;
}

.nav-position-right .nav-submenu a {
    padding-left: 1rem;
}

/* Espacer le chevron du texte dans les sous-menus */
.nav-position-right .nav-submenu-container button i.fa-chevron-right,
.nav-position-right .nav-submenu-container button i.fa-chevron-down {
    margin-left: 0.5rem;
}

.nav-position-right .nav-separator {
    display: none;
}

/* === MAIN CONTENT PADDING ADJUSTMENTS === */
body.nav-top {
    padding-top: 4rem; /* 64px / h-16 */
}

body.nav-bottom {
    padding-bottom: 4rem;
}

body.nav-left {
    padding-left: 4rem; /* 64px compact */
    padding-top: 0;
    transition: padding-left 0.3s ease-in-out;
}

body.nav-right {
    padding-right: 4rem; /* 64px compact */
    padding-top: 0;
    transition: padding-right 0.3s ease-in-out;
}

/* === RESPONSIVE - Mobile === */
@media (max-width: 1023px) {
    /* LEFT reste à gauche en mobile - COMPLET caché par défaut */
    .nav-position-left {
        width: 0;
        overflow: hidden;
        transition: width 0.3s ease-in-out;
    }

    .nav-position-left.mobile-expanded {
        width: 16rem; /* 256px - largeur complète au clic */
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* RIGHT reste à droite en mobile - COMPLET caché par défaut */
    .nav-position-right {
        width: 0;
        overflow: hidden;
        transition: width 0.3s ease-in-out;
    }

    .nav-position-right.mobile-expanded {
        width: 16rem; /* 256px - largeur complète au clic */
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* BOTTOM reste en BOTTOM en mobile */
    .nav-position-bottom {
        bottom: 0;
        top: auto;
    }

    .nav-position-bottom .nav-dropdown {
        bottom: 100%;
        top: auto;
        margin-bottom: -0.25rem;
    }

    /* Ajustement du padding body en mobile - PAS de padding pour sidebars */
    body.nav-left {
        padding-left: 0;
        padding-top: 0;
    }

    body.nav-right {
        padding-right: 0;
        padding-top: 0;
    }

    body.nav-bottom {
        padding-bottom: 4rem;
        padding-top: 0;
    }

    body.nav-top {
        padding-top: 4rem;
    }

    /* Overlay sombre quand sidebar ouverte en mobile */
    .nav-mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 3999;
        opacity: 0;
        transition: opacity 0.3s ease-in-out;
    }

    .nav-mobile-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Burger button FLOTTANT en mobile pour sidebars - sélecteur simplifié */
    .mobile-burger {
        display: none; /* Caché par défaut */
    }

    /* Afficher uniquement pour LEFT en mobile */
    body.nav-left .mobile-burger {
        display: flex !important;
        position: fixed !important;
        top: 1rem;
        left: 1rem;
        justify-content: center;
        align-items: center;
        width: 3rem;
        height: 3rem;
        background: var(--color-primary, #BE2026) !important;
        border-radius: 0.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        cursor: pointer;
        font-size: 1.5rem;
        color: white !important;
        z-index: 5001;
        transition: left 0.3s ease-in-out, all 0.3s ease-in-out;
    }

    /* Quand menu LEFT ouvert, déplacer le X à droite avec marge */
    body.nav-left .mobile-burger.expanded {
        left: 12rem; /* 192px = 256px - 64px pour laisser de l'espace */
    }

    /* Afficher uniquement pour RIGHT en mobile */
    body.nav-right .mobile-burger {
        display: flex !important;
        position: fixed !important;
        top: 1rem;
        right: 1rem;
        justify-content: center;
        align-items: center;
        width: 3rem;
        height: 3rem;
        background: var(--color-primary, #BE2026) !important;
        border-radius: 0.5rem;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
        cursor: pointer;
        font-size: 1.5rem;
        color: white !important;
        z-index: 5001;
        transition: right 0.3s ease-in-out, all 0.3s ease-in-out;
    }

    /* Quand menu RIGHT ouvert, déplacer le X à gauche avec marge */
    body.nav-right .mobile-burger.expanded {
        right: 12rem; /* 192px = 256px - 64px pour laisser de l'espace */
    }

    /* Burger reste visible même quand menu ouvert (devient X et se déplace) */
    /* Suppression de la règle qui cachait le burger */

    /* Masquer le div MOBILE LAYOUT pour sidebars (celui avec le hamburger intégré) */
    .nav-position-left > .nav-container > div.flex.lg\\:hidden,
    .nav-position-right > .nav-container > div.flex.lg\\:hidden {
        display: none !important;
    }

    /* Masquer aussi le div #mobileMenu */
    .nav-position-left > .nav-container > #mobileMenu,
    .nav-position-right > .nav-container > #mobileMenu {
        display: none !important;
    }

    /* FORCER l'affichage du menu DESKTOP pour sidebars en mobile */
    .nav-position-left > .nav-container > div.hidden.lg\\:flex,
    .nav-position-right > .nav-container > div.hidden.lg\\:flex {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        align-items: flex-start !important;
    }

    /* S'assurer que logo et links sont visibles */
    .nav-position-left > .nav-container > div.hidden.lg\\:flex .nav-logo,
    .nav-position-left > .nav-container > div.hidden.lg\\:flex .nav-links,
    .nav-position-right > .nav-container > div.hidden.lg\\:flex .nav-logo,
    .nav-position-right > .nav-container > div.hidden.lg\\:flex .nav-links {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
}

/* Masquer burger en desktop (en dehors du media query mobile) */
@media (min-width: 1024px) {
    .mobile-burger {
        display: none !important;
    }
}

/* === ANIMATIONS === */
.nav-dropdown {
    transition: all 0.2s ease-in-out;
}

.nav-links a,
.nav-links button {
    transition: all 0.15s ease-in-out;
}

/* === SCROLLBAR pour sidebars === */
.nav-position-left::-webkit-scrollbar,
.nav-position-right::-webkit-scrollbar {
    width: 6px;
}

.nav-position-left::-webkit-scrollbar-track,
.nav-position-right::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

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

.nav-position-left::-webkit-scrollbar-thumb:hover,
.nav-position-right::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
