/* ==========================================================================
   1. STRUCTURE ET COMPORTEMENT DU MEGAMENU (DESKTOP)
   ========================================================================== */

/* Alignement horizontal du menu principal */
#sp-menu .sp-megamenu-parent {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Positionnement relatif obligatoire sur les li pour ancrer les dropdowns */
#sp-menu .sp-megamenu-parent > li.sp-has-child,
#sp-menu .sp-dropdown-items > li {
    position: relative !important;
}

/* Suppression des contraintes de débordement sur les conteneurs */
#sp-menu, 
#sp-menu .sp-column, 
#sp-menu .menu-wrap, 
#sp-menu .sp-megamenu-wrapper,
#sp-menu .sp-megamenu-parent {
    overflow: visible !important;
}

/* Style des liens du niveau 1 */
#sp-menu .sp-megamenu-parent > li > a,
#sp-menu .sp-megamenu-parent > li > .sp-menu-heading {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #2b2b2b;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

/* --- Icônes / Flèches des menus déroulants --- */
#sp-menu .sp-megamenu-parent > li.sp-has-child > a::after,
#sp-menu .sp-megamenu-parent > li.sp-has-child > .sp-menu-heading::after {
    content: "\f107"; /* fa-angle-down */
    font-family: "Font Awesome 5 Free", "FontAwesome";
    font-weight: 900;
    margin-left: 8px;
    font-size: 12px;
}

#sp-menu .sp-dropdown-items li.sp-has-child > a::after {
    content: "\f105"; /* fa-angle-right */
    font-family: "Font Awesome 5 Free", "FontAwesome";
    font-weight: 900;
    float: right;
    margin-left: 10px;
}

/* --- Gestion des Dropdowns (Niveau 1 & Sous-niveaux) --- */
#sp-menu .sp-dropdown {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    z-index: 99999 !important;
    background: #ffffff !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15) !important;
    border-radius: 4px !important;
    padding: 10px 0 !important;
    min-width: 240px !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

/* Pont invisible pour éviter de perdre le survol de la souris */
#sp-menu .sp-dropdown::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    width: 100%;
    height: 10px;
}

/* Positionnement du sous-sous-menu (Niveau 2 -> Niveau 3) */
#sp-menu .sp-dropdown-sub {
    display: none !important;
    position: absolute !important;
    top: 0 !important;
    left: 100% !important;
    margin-top: -10px !important;
    z-index: 100000 !important;
}

/* Affichage au survol (:hover) */
#sp-menu .sp-megamenu-parent > li.sp-has-child:hover > .sp-dropdown,
#sp-menu .sp-dropdown-items > li.sp-has-child:hover > .sp-dropdown-sub {
    display: block !important;
}

/* --- Styles des listes et liens internes aux dropdowns --- */
#sp-menu .sp-dropdown-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

#sp-menu .sp-dropdown-items li a,
#sp-menu .sp-dropdown-items li .sp-menu-heading {
    display: block;
    padding: 8px 20px;
    color: #333333;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}


/* ==========================================================================
   2. CHARTE GRAPHIQUE ET SURCHARGES HELIX ULTIMATE (ROUGE)
   ========================================================================== */

#sp-menu .sp-megamenu-parent > li.active > a,
#sp-menu .sp-megamenu-parent > li.current > a,
#sp-menu .sp-megamenu-parent > li:first-child > a,
#sp-menu .sp-megamenu-parent > li:hover > a,
#sp-menu .sp-megamenu-parent > li > a:hover {
    color: #e63946 !important; /* Rouge Helix */
}

#sp-menu .sp-dropdown-items li a:hover,
#sp-menu .sp-dropdown-items li.active > a,
#sp-menu .sp-dropdown-items li.current > a {
    background-color: #f8f9fa !important;
    color: #e63946 !important;
}


/* ==========================================================================
   3. MENU OFF-CANVAS (MOBILE & BURGER)
   ========================================================================== */

.open-offcanvas {
    cursor: pointer !important;
    line-height: 1 !important;
    z-index: 100 !important;
    margin-left: auto !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

.open-offcanvas i {
    color: #333333 !important;
    font-size: 24px !important;
    transition: color 0.2s ease;
}

.open-offcanvas:hover i {
    color: #e63946 !important;
}

.offcanvas-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 99998 !important;
    display: none;
}

.offcanvas-overlay.active {
    display: block !important;
}

.offcanvas-menu {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 300px !important;
    height: 100vh !important;
    background: #ffffff !important;
    z-index: 99999 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s ease-in-out !important;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2) !important;
    overflow-y: auto !important;
}

.offcanvas-menu.active {
    transform: translateX(0) !important;
}

.offcanvas-menu ul li a {
    color: #333333;
    text-decoration: none;
    display: block;
    padding: 6px 0;
}

.offcanvas-menu ul li a:hover,
.offcanvas-menu ul li.active > a {
    color: #e63946 !important;
}


/* ==========================================================================
   4. ELEMENTS GLOBAUX (BOTTOM & SCROLL TO TOP)
   ========================================================================== */

#sp-bottom {
    font-size: 14px;
}

#sp-bottom a {
    color: #333333;
    text-decoration: none;
    font-weight: 500;
}

#sp-bottom a:hover,
#sp-bottom li.active > a {
    color: #e63946 !important;
}

.sp-scroll-up {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    background: #e63946;
    color: #ffffff !important;
    border-radius: 4px;
    z-index: 999;
    transition: background-color 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    text-decoration: none;
}

.sp-scroll-up:hover {
    background: #c92a37;
    color: #ffffff !important;
}


/* ==========================================================================
   5. CARTES D'ARTICLES ET VISUALISEUR PDF.JS
   ========================================================================== */

.list-group-item.article-card {
    min-height: 55px !important;
    height: auto !important;
    padding: 40px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
}

.article-title {
    color: #0d6efd;
    cursor: pointer; 
    text-decoration: underline;
    font-size: 14px !important;
    line-height: 1.2 !important;
    margin-top: 0 !important;
    margin-bottom: 5px !important;
    padding: 0 !important;
}

.article-title:hover {
    color: #e63946 !important;
}

.list-group-item.article-card .text-muted {
    font-size: 12px !important;
    line-height: 1.1 !important;
    margin-bottom: 0 !important;
}

.pdf-viewer-container {
    display: none;
    background-color: #525659;
    padding: 20px;
    border-radius: 6px;
    max-height: 750px;
    overflow-y: auto;
    text-align: center;
    width: 100% !important;
    clear: both !important;
}

.pdf-viewer-container canvas,
.pdf-page-canvas {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 10px auto 15px auto !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border: 1px solid #dee2e6;
    background-color: #ffffff;
}

/* --- Correctif pour la stabilité du Header et du Menu (F12 / Resize) --- */
#sp-header {
    position: relative !important;
    z-index: 1050 !important; /* S'assure qu'il reste au-dessus du contenu et du footer */
}

#sp-header .container-inner,
#sp-header .row {
    position: relative !important;
}

/* Empêche le menu de descendre sous le footer lors d'un redimensionnement de la fenêtre */
#sp-menu {
    position: relative !important;
    z-index: 1060 !important;
}

/* S'assure que les dropdowns restent bien rattachés à leur parent sans déborder hors de l'écran */
#sp-menu .sp-dropdown {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
}