/**
 * CC Mega Menu - Frontend Styles
 * @package CC_Mega_Menu
 */

/* ===========================
   RESET & BASE
   =========================== */

.cc-mega-menu,
.cc-mega-menu * {
    box-sizing: border-box;
}

.cc-mega-menu {
    position: relative;
    width: 100%;
}

.cc-mega-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cc-mega-menu a {
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
}

/* ===========================
   MENU PRINCIPAL - DESKTOP
   =========================== */

.cc-menu-main {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0;
}

.cc-menu-main > li {
    position: relative;
}

.cc-menu-main > li > a {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.cc-menu-main > li > a:hover {
    opacity: 0.8;
}

/* Indicateur de sous-menu */
.cc-submenu-indicator {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 5px;
}

/* ===========================
   MEGA DROPDOWN
   =========================== */

/* Desktop uniquement - pas en mobile */
@media screen and (min-width: 769px) {
    .cc-mega-dropdown {
        position: fixed !important;
        top: auto;
        left: 0 !important;
        right: 0;
        width: 100vw !important;
        background: #ffffff !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transition: opacity 0.3s ease, visibility 0.3s ease !important;
        z-index: 9999 !important;
        padding: 30px 0 !important;
        display: block !important;
    }
}

/* Conteneur pour le positionnement */
.has-mega-menu {
    position: relative;
}

/* Animation fade - ACTIF via JavaScript */
.has-mega-menu.cc-active > .cc-mega-dropdown {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Animation slide */
.cc-mega-menu[data-animation="slide"] .cc-mega-dropdown {
    transform: translateY(-10px);
}

.cc-mega-menu[data-animation="slide"] .has-mega-menu:hover > .cc-mega-dropdown,
.cc-mega-menu[data-animation="slide"] .has-mega-menu.cc-active > .cc-mega-dropdown {
    transform: translateY(0);
}

/* Conteneur interne du mega menu */
.cc-mega-inner {
    display: flex;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;           /* Centre le conteneur */
    padding: 0 30px;          /* Espacement latéral */
}

/* Alignements horizontaux */
.cc-mega-inner.cc-align-left {
    justify-content: flex-start;
}

.cc-mega-inner.cc-align-center {
    justify-content: center;
}

.cc-mega-inner.cc-align-right {
    justify-content: flex-end;
}

.cc-mega-inner.cc-align-space-between {
    justify-content: space-between;
}

/* ===========================
   COLONNES
   =========================== */

.cc-mega-column {
    flex: 1;
    min-width: 0;
}

/* Titre de colonne */
.cc-column-title {
    margin: 0 0 15px 0;
    padding: 0 0 10px 0;
    border-bottom: 2px solid #f0f0f0;
    font-size: 16px;
    font-weight: 600;
    color: #333333;
}

.cc-column-title a {
    color: inherit;
}

.cc-column-title a:hover {
    color: #0073aa;
}

/* Image de colonne */
.cc-column-image-wrapper {
    margin-bottom: 15px;
    overflow: hidden;
    border-radius: 4px;
}

.cc-column-image {
    width: 100%;
    height: auto;
    max-height: 150px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Tailles d'images */
.cc-image-size-small .cc-column-image {
    max-height: 100px;
}

.cc-image-size-medium .cc-column-image {
    max-height: 150px;
}

.cc-image-size-large .cc-column-image {
    max-height: 200px;
}

.cc-image-size-full .cc-column-image {
    max-height: none;
    height: auto;
}

/* Effet zoom sur hover */
.cc-mega-menu[data-hover-effect="zoom"] .cc-column-image:hover {
    transform: scale(1.05);
}

/* Effet opacité sur hover */
.cc-mega-menu[data-hover-effect="opacity"] .cc-column-image:hover {
    opacity: 0.8;
}

/* Modes de largeur des colonnes */
.cc-mega-dropdown.cols-mode-equal .cc-mega-column {
    flex: 1;
}

.cc-mega-dropdown.cols-mode-auto .cc-mega-column {
    flex: 0 1 auto;
}

.cc-mega-dropdown.cols-mode-custom .cc-mega-column {
    flex: 0 0 auto;
}

/* Items de colonne */
.cc-column-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cc-column-items li a {
    padding: 8px 12px;
    color: #666666;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.cc-column-items li a:hover {
    background-color: #f5f5f5;
    color: #0073aa;
    padding-left: 16px;
}

/* ===========================
   SOUS-MENU STANDARD
   =========================== */

.cc-standard-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 9999;
    padding: 10px 0;
    border-radius: 4px;
}

.has-children:hover > .cc-standard-dropdown,
.has-children.cc-active > .cc-standard-dropdown {
    opacity: 1;
    visibility: visible;
}

.cc-standard-dropdown li a {
    padding: 10px 20px;
    color: #666666;
    font-size: 14px;
}

.cc-standard-dropdown li a:hover {
    background-color: #f5f5f5;
    color: #0073aa;
}

/* ===========================
   ÉTATS ACTIFS
   =========================== */

.cc-menu-main > li.current-menu-item > a,
.cc-menu-main > li.current-menu-ancestor > a {
    background-color: #f0f0f0;
    color: #0073aa;
}

/* ===========================
   BOUTON HAMBURGER (caché en desktop)
   =========================== */

.cc-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 10000;
}

.cc-hamburger-line {
    width: 100%;
    height: 3px;
    background-color: #333333;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* Animation hamburger actif */
.cc-menu-toggle.active .cc-hamburger-line:nth-child(1) {
    transform: rotate(45deg) translateY(10px);
}

.cc-menu-toggle.active .cc-hamburger-line:nth-child(2) {
    opacity: 0;
}

.cc-menu-toggle.active .cc-hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translateY(-10px);
}

/* ===========================
   NOTICE (mode édition)
   =========================== */

.cc-mega-menu-notice {
    padding: 20px;
    background: #f0f0f0;
    border: 2px dashed #cccccc;
    border-radius: 4px;
    text-align: center;
    color: #666666;
}

/* ===========================
   RESPONSIVE - MOBILE
   =========================== */

@media screen and (max-width: 768px) {
    
    /* Afficher le bouton hamburger */
    .cc-menu-toggle {
        display: flex !important;
    }
    
    /* Menu principal en accordéon */
    .cc-menu-main {
        display: flex;
        flex-direction: column;
        width: 100%;
        background: #ffffff;
        position: absolute;
        top: 100%;
        left: 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        z-index: 9998;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .cc-menu-main.active {
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .cc-menu-main > li {
        width: 100%;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .cc-menu-main > li > a {
        padding: 15px 20px;
        justify-content: space-between;
    }
    
    /* Indicateur de sous-menu mobile */
    .cc-submenu-indicator {
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 4px solid currentColor;
        border-bottom: none;
        transition: transform 0.3s ease;
    }
    
    .has-children.cc-active > a .cc-submenu-indicator,
    .has-mega-menu.cc-active > a .cc-submenu-indicator {
        transform: rotate(180deg);
    }
    
    /* Mega dropdown en accordéon - Forcer le positionnement statique */
    .cc-menu-main .cc-mega-dropdown,
    .cc-mega-menu .cc-mega-dropdown,
    div.cc-mega-dropdown {
        position: static !important;
        width: 100% !important;
        transform: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: #f9f9f9 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.3s ease, padding 0.3s ease !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        display: block !important;
        height: auto !important;
        margin: 0 !important;
    }
    
    /* Ouverture avec classe cc-active - Sélecteurs multiples pour plus de spécificité */
    .cc-menu-main > li.has-mega-menu.cc-active > .cc-mega-dropdown,
    .cc-menu-main > li.cc-active > .cc-mega-dropdown,
    .cc-menu-main .has-mega-menu.cc-active > .cc-mega-dropdown,
    .cc-menu-main .cc-active > .cc-mega-dropdown {
        max-height: 2000px !important;
        padding: 15px !important;
        height: auto !important;
    }
    
    /* Colonnes empilées */
    .cc-mega-inner {
        flex-direction: column !important;
        gap: 20px !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
    
    .cc-mega-column {
        width: 100% !important;
        flex: 1 1 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
    }
    
    /* Forcer les couleurs du texte en mobile */
    .cc-mega-dropdown .cc-column-title,
    .cc-mega-dropdown .cc-column-title a {
        color: #333333 !important;
    }
    
    .cc-mega-dropdown .cc-column-items li a {
        color: #666666 !important;
    }
    
    /* Images adaptatives */
    .cc-column-image {
        max-height: 120px;
    }
    
    /* Sous-menu standard en accordéon */
    .cc-standard-dropdown {
        position: static;
        width: 100%;
        box-shadow: none;
        background: #f9f9f9;
        max-height: 0;
        overflow: hidden;
        padding: 0;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }
    
    .has-children.cc-active > .cc-standard-dropdown {
        max-height: 1000px;
        padding: 10px 0;
        opacity: 1;
        visibility: visible;
    }
    
    .cc-standard-dropdown li a {
        padding: 10px 30px;
    }
    
    /* Zones tactiles minimum 44px */
    .cc-menu-main a,
    .cc-column-items a,
    .cc-standard-dropdown a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ===========================
   RESPONSIVE - TABLETTE
   =========================== */

@media screen and (min-width: 769px) and (max-width: 1024px) {
    
    .cc-mega-inner {
        gap: 20px;
        padding: 0 20px;
    }
    
    .cc-menu-main > li > a {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    /* Ajuster les colonnes pour tablette */
    .cc-mega-dropdown.cols-5 .cc-mega-column,
    .cc-mega-dropdown.cols-6 .cc-mega-column,
    .cc-mega-dropdown.cols-7 .cc-mega-column,
    .cc-mega-dropdown.cols-8 .cc-mega-column {
        flex: 0 0 calc(33.333% - 20px);
    }
}

/* ===========================
   ACCESSIBILITÉ
   =========================== */

/* Focus visible pour navigation clavier */
.cc-mega-menu a:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Améliorer le contraste */
@media (prefers-contrast: high) {
    .cc-mega-menu a {
        font-weight: 600;
    }
    
    .cc-column-title {
        border-bottom-width: 3px;
    }
}

/* Réduire les animations si préférence utilisateur */
@media (prefers-reduced-motion: reduce) {
    .cc-mega-menu *,
    .cc-mega-menu *::before,
    .cc-mega-menu *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================
   PRINT
   =========================== */

@media print {
    .cc-menu-toggle {
        display: none;
    }
    
    .cc-mega-dropdown,
    .cc-standard-dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
    }
}
