/* ============================================
   MEGAMENU STYLES - Click-baseret 3. niveau
   ============================================ */

.megamenu-container {
    font-family: 'Chivo', sans-serif;
    position: relative;
    background: transparent;
    border-radius: 6px;
    overflow: visible;
    z-index: 999;
}

.megamenu-nav {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: 6px 6px 0 0;
}




/* ============================================
   TOP-LEVEL MENU ITEMS - STAGGER ANIMATION
   ============================================ */
.megamenu-item {
    position: relative;
    flex: 1;
    opacity: 0;
    transform: translateY(-20px);
    animation: slideInStagger 0.6s ease forwards;
}

/* Stagger delays */
.megamenu-item:nth-child(1) { animation-delay: 0.1s; }
.megamenu-item:nth-child(2) { animation-delay: 0.2s; }
.megamenu-item:nth-child(3) { animation-delay: 0.3s; }
.megamenu-item:nth-child(4) { animation-delay: 0.4s; }
.megamenu-item:nth-child(5) { animation-delay: 0.5s; }
.megamenu-item:nth-child(6) { animation-delay: 0.6s; }
.megamenu-item:nth-child(7) { animation-delay: 0.7s; }
.megamenu-item:nth-child(8) { animation-delay: 0.8s; }

@keyframes slideInStagger {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   TOP-LEVEL MENU LINKS
   ============================================ */
.megamenu-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0px;
    padding: 15px 0px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
}

.megamenu-item:first-child .megamenu-link {
    border-radius: 6px 0 0 0;
}

.megamenu-item:last-child .megamenu-link {
    border-right: none;
    border-radius: 0 6px 0 0;
}

.megamenu-link:hover {
    color: white;
}

.megamenu-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #D1002F;
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.megamenu-link:hover::after {
    width: 80%;
}

/* ============================================
   CHEVRON STYLING
   ============================================ */
.megamenu-chevron {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.megamenu-chevron svg {
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
}

/* Rotate chevron up on hover */
.megamenu-item:hover .megamenu-chevron {
    transform: rotate(180deg);
    opacity: 0.9;
}

.megamenu-item.active .megamenu-chevron {
    transform: rotate(180deg);
    opacity: 0.9;
}

/* Submenu chevron */
.submenu-chevron {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.submenu-chevron svg {
    width: 10px;
    height: 10px;
    transition: transform 0.3s ease;
    transform: rotate(90deg);
}

/* Active state når dropdown er åben */
.submenu-item.active > .submenu-link .submenu-chevron svg {
    transform: rotate(-90deg);
}

.submenu-item.active > .submenu-link .submenu-chevron {
    opacity: 0.9;
}

/* ============================================
   MAIN DROPDOWN STYLING
   ============================================ */
.megamenu-dropdown {
    position: absolute;
    top: 100%;
    left: -150%;
    right: -150%;
    background: white;
    background-image: url('https://scantrapper.udvikling360.dk/wp-content/uploads/2025/04/run1-4-scaled.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: scroll;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    min-height: auto;
    border: 1px solid #e5e7eb;
    border-top: none;
    width: 400%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    pointer-events: none;
    padding-top: 20px;
    margin-top: 0px;
}

/* Overlay for text readability */
.megamenu-dropdown::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    z-index: 1;
    pointer-events: none;
}

.megamenu-content {
    position: relative;
    z-index: 2;
}

/* Show dropdown on hover */
.megamenu-item:hover > .megamenu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.megamenu-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.megamenu-item.active .megamenu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* ============================================
   DROPDOWN CONTENT
   ============================================ */
.megamenu-content {
    display: flex;
    padding: .8rem;
    padding-bottom: 0.2rem !important;
    padding-top: 20px;
    gap: 0;
    align-items: stretch;
    max-width: 1500px !important;
    margin: 0 auto;
    height: auto;
    min-height: auto;
}

.megamenu-links {
    flex: 1;
    max-width: 50%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 1rem;
    padding-right: 2rem !important;
    padding-bottom: 1rem !important;
    align-content: start;
    min-height: 200px;
}

/* ============================================
   IMAGE CONTAINER
   ============================================ */
.megamenu-image {
    flex: 0 0 50% !important;
    height: auto !important;
    min-height: 400px !important;
    max-height: 400px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    position: relative !important;
    background: #f8f9fa !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    border: none !important;
    border-left: 1px solid #e5e7eb !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 7px;
    margin-bottom: 17px !important;
}

.megamenu-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.megamenu-placeholder {
    width: 100% !important;
    height: 100% !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border-radius: 0 0 12px 0 !important;
    display: block !important;
    filter: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 1 !important;
    background-color: transparent !important;
    transition: none !important;
}

/* ============================================
   SUBMENU ITEMS - STAGGER ANIMATION
   ============================================ */
.submenu-item {
    margin-bottom: 4px;
    opacity: 0;
    transform: translateX(-20px) translateY(10px);
    transition: all 0.4s ease;
    transition-delay: 0s;
    position: relative;
}

.megamenu-item:hover .submenu-item {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

.megamenu-item.active .submenu-item {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

/* Stagger delays */
.submenu-item:nth-child(1) { transition-delay: 0.05s; }
.submenu-item:nth-child(2) { transition-delay: 0.1s; }
.submenu-item:nth-child(3) { transition-delay: 0.15s; }
.submenu-item:nth-child(4) { transition-delay: 0.2s; }
.submenu-item:nth-child(5) { transition-delay: 0.25s; }
.submenu-item:nth-child(6) { transition-delay: 0.3s; }
.submenu-item:nth-child(7) { transition-delay: 0.35s; }
.submenu-item:nth-child(8) { transition-delay: 0.4s; }
.submenu-item:nth-child(9) { transition-delay: 0.45s; }
.submenu-item:nth-child(10) { transition-delay: 0.5s; }

/* ============================================
   SUBMENU LINKS (LEVEL 2)
   ============================================ */
.submenu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 14px;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-weight: 400;
    font-size: 15px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.submenu-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: #D1002F;
    transition: left 0.3s ease;
    z-index: -1;
}

.submenu-link:hover::before {
    left: 0;
}

.submenu-link:hover {
    color: white;
    transform: translateX(8px);
    text-decoration: none;
}

/* ============================================
   3RD LEVEL SUBMENU - CLICK-BASERET
   ============================================ */
.submenu-dropdown {
    position: static;
    top: auto;
    left: auto;
    min-width: auto;
    max-width: none;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, max-height 0.4s ease;
    z-index: auto;
    border: none;
    margin-left: 16px;
    margin-top: 0px;
    pointer-events: auto;
    max-height: 0;
    overflow: hidden;
    padding: 0px !important;
    margin-bottom: 0px !important;
}

/* KRITISK: Vis dropdown KUN når .show-dropdown klassen er tilføjet via JavaScript */
.submenu-dropdown.show-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    max-height: 500px;
}

.submenu-content {
    padding: 0;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 4px;
}

/* ============================================
   ITEMS WITH CHILDREN (CLICKABLE)
   ============================================ */
.submenu-item.has-children {
    position: relative;
    min-height: auto;
}

.submenu-item.has-children > .submenu-link {
    font-weight: 500;
    cursor: pointer;
}

/* Active state når dropdown er åben */
.submenu-item.has-children.active > .submenu-link {
    background: linear-gradient(135deg,rgba(209, 0, 47, 1) 0%, rgba(209, 0, 47, 1) 100%);
    color: white;
}

.submenu-item.has-children.active > .submenu-link::before {
    left: 0;
}

/* Hover state for items with children */
.submenu-item.has-children > .submenu-link:hover {
    color: white;
}

/* ============================================
   LEVEL 3 STYLING
   ============================================ */
.level-3 {
    opacity: 0;
    transform: translateY(-5px);
    transition: all 0.3s ease;
}

.submenu-dropdown.show-dropdown .level-3 {
    opacity: 1;
    transform: translateY(0);
}

.level-3-link {
    padding: 8px 16px !important;
    font-size: 13px !important;
    color: #6b7280 !important;
    font-weight: 400 !important;
    border-radius: 4px !important;
    margin: 2px 8px !important;
    display: block !important;
    background: transparent !important;
    border: none !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

.level-3-link:hover {
    background: #e5e7eb !important;
    color: #374151 !important;
    transform: translateX(4px) !important;
}

.level-3-link::before {
    display: none !important;
}

/* Stagger for 3rd level */
.level-3:nth-child(1) { transition-delay: 0.05s; }
.level-3:nth-child(2) { transition-delay: 0.1s; }
.level-3:nth-child(3) { transition-delay: 0.15s; }
.level-3:nth-child(4) { transition-delay: 0.2s; }
.level-3:nth-child(5) { transition-delay: 0.25s; }

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .megamenu-nav {
        flex-direction: column;
    }
    
    .megamenu-link {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .megamenu-content {
        flex-direction: column;
        padding: 0 !important;
        gap: 0 !important;
        max-width: 100% !important;
        min-height: auto !important;
    }
    
    .megamenu-links {
        max-width: 100% !important;
        grid-template-columns: 1fr !important;
        padding: 20px !important;
        min-height: auto !important;
    }
    
    .megamenu-image {
        flex: none !important;
        height: 200px !important;
        width: 100% !important;
        min-height: 200px !important;
        max-height: 300px !important;
        border-left: none !important;
        border-top: 1px solid #e5e7eb !important;
        border-radius: 0 0 12px 12px !important;
    }
    
    .megamenu-placeholder {
        border-radius: 0 0 12px 12px !important;
    }