/* ============================================
   MEGA MENU STYLES
   ============================================ */

/* Reset linków w mega-menu - nadpisz wszystkie kolory */
.mega-menu-dropdown a,
.mega-menu-dropdown a:link,
.mega-menu-dropdown a:visited,
.mega-menu-dropdown a:active {
    text-decoration: none !important;
}

/* Desktop Menu - Base Styles */

#menu-mega-menu {
    display: flex;
    flex-direction: row;
    gap: 24px;
    align-items: center;
    justify-content: center;
}

/* FIX: Nadpisz overflow hidden z main.css */
header .menu-item.has-mega-menu,
.menu-bar .has-mega-menu,
.mobile-menu .has-mega-menu {
    position: relative !important;
    overflow: hidden !important;
}

/* Nadpisz style z main.css dla mega menu */
.menu-bar .has-mega-menu>a {
    position: relative !important;
    padding-block: 1em !important;
}

.menu-bar .has-mega-menu>a::after {
    bottom: 13px !important;
}

.menu-bar .has-mega-menu>a {
    align-items: center;
    gap: 6px;
    position: relative;
    display: flex;
}

/* Podkreślenie dla mega menu - takie samo jak reszta */
.menu-bar .has-mega-menu>a::after {
    content: "" !important;
    position: absolute !important;
    height: 1px !important;
    background-color: #091e3f !important;
    width: 100% !important;
    bottom: 13px !important;
    left: -100% !important;
    transition: all 0.3s !important;
    overflow: hidden !important;
}

.menu-bar .has-mega-menu:hover>a::after {
    left: 0 !important;
}

.mega-menu-arrow {
    transition: transform 0.3s ease;
}

.has-mega-menu:hover .mega-menu-arrow {
    transform: rotate(180deg);
}

/* Mega Menu Dropdown Container */
.menu-bar .mega-menu-dropdown {
    display: block !important;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: 56px !important;
    width: 100% !important;
    transform: translateY(10px) !important;
    background-color: #F7F7F7 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease 0.5s, visibility 0s linear 0.8s, transform 0.3s ease 0.5s !important;
    z-index: 999999 !important;
}

body.topbar-enabled .menu-bar .mega-menu-dropdown {
    top: 100px !important;
}

.menu-bar .mega-menu-dropdown .new-container {
    max-width: 1400px !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 0 0 !important;
    padding-left: 16px !important;
}

.menu-bar .has-mega-menu:hover .mega-menu-dropdown,
.menu-bar li.has-mega-menu:hover>.mega-menu-dropdown {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
    transition: opacity 0.3s ease, visibility 0s linear, transform 0.3s ease !important;
}

.menu-bar .mega-menu-dropdown:hover {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: opacity 0.3s ease, visibility 0s linear, transform 0.3s ease !important;
}

.menu-bar .mega-menu-dropdown a {
    pointer-events: auto !important;
}

.mega-menu-sub-items a {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Mega Menu Content Layout */
.mega-menu-content {
    display: flex !important;
    gap: 48px !important;
    align-items: stretch !important;
    /* Rozciągnij na pełną wysokość */
}

/* Kolumny z kategoriami - 70% szerokości */
.mega-menu-columns {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: wrap !important;
    align-content: flex-start !important;
    gap: 16px 32px !important;
    max-height: 500px !important;
    padding: 32px 0 !important;
}

/* Główny nagłówek "Kategorie" */
.mega-menu-main-title {
    width: 100% !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    color: #6a6f76 !important;
    margin: 0 0 16px 0 !important;
    padding: 0 !important;
    letter-spacing: 0.5px !important;
    line-height: 1 !important;
}

/* Pojedyncza kolumna */
.mega-menu-column {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    width: 250px !important;
    flex-shrink: 0 !important;
}

.mega-menu-column-title {
    font-size: 14px;
    font-weight: 500;
    color: #03142e;
    margin: 0 0 4px 0;
    padding: 0;
    letter-spacing: -0.01em;
    line-height: 140%;
}

/* Link w tytule kolumny */
.mega-menu-column-title a {
    color: #03142e !important;
    text-decoration: none !important;
    pointer-events: auto !important;
    transition: color 0.2s ease !important;
}

.mega-menu-column-title a:hover {
    color: #2662b8 !important;
}

.mega-menu-column-title a::after {
    display: none !important;
}

/* Lista elementów w kolumnie */
.mega-menu-sub-items {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
}

.mega-menu-sub-items li {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
}

.mega-menu-sub-items a {
    display: block !important;
    padding: 4px 0 !important;
    font-size: 14px !important;
    line-height: 140% !important;
    letter-spacing: -0.0125em !important;
    color: #6a6f76 !important;
    font-weight: 400 !important;
    text-transform: none !important;
    transition: color 0.2s ease, padding-left 0.2s ease !important;
    position: relative !important;
}

.mega-menu-sub-items a::after {
    display: none !important;
}

.mega-menu-sub-items a:hover {
    color: #03142e !important;
    padding-left: 8px !important;
}

/* Kolumna Promocyjna - 30% szerokości */
.mega-menu-promo {
    background-color: #03142e;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
}

.mega-menu-promo-image {
    width: 100%;
    aspect-ratio: 1/1;
    overflow: hidden;
    background-color: #fff;
    order: -1;
}

.mega-menu-promo-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.mega-menu-promo:hover .mega-menu-promo-image img {
    transform: scale(1.05);
}

.mega-menu-promo-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.mega-menu-promo-title {
    font-size: 18px;
    line-height: 120%;
    letter-spacing: 0.02em;
    font-weight: 500;
    text-transform: uppercase;
    color: #fff;
    margin: 0;
}

.mega-menu-promo-text {
    font-size: 14px;
    line-height: 160%;
    letter-spacing: 0;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.mega-menu-promo-button {
    background-color: #fff;
    color: #03142e !important;
    padding: 14px 28px;
    text-align: center;
    text-transform: uppercase;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-top: auto;
}

.mega-menu-promo-button:hover {
    background-color: #2662b8;
    color: #fff !important;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */

@media (max-width: 1200px) {
    .mega-menu-content {
        gap: 32px;
    }

    .mega-menu-columns {
        gap: 24px;
    }

    .mega-menu-promo {
        width: 280px;
        min-width: 280px;
        padding: 24px 20px;
    }
}

/* ============================================
   MOBILE - ACCORDION STYLE
   ============================================ */

@media (max-width: 992px) {

    /* UKRYJ desktop menu z mega menu */
    #menu-mega-menu {
        display: none !important;
    }

    /* UKRYJ mega menu dropdown wszędzie */
    .mega-menu-dropdown {
        display: none !important;
        visibility: hidden !important;
    }

    /* Ukryj strzałkę mega menu */
    .mega-menu-arrow {
        display: none !important;
    }

    /* ============================================
       MOBILE MENU - ACCORDION SUBMENU
       ============================================ */

    /* Ukryj submenu domyślnie */
    .mobile-menu .sub-menu {
        display: none !important;
        padding-left: 20px !important;
        margin-top: 8px !important;
    }

    /* Pokaż gdy parent ma klasę submenu-open */
    .mobile-menu .menu-item-has-children.submenu-open>.sub-menu {
        display: block !important;
    }

    /* Strzałka dla elementów z submenu */
    .mobile-menu .menu-item-has-children>a {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .mobile-menu .menu-item-has-children>a::after {
        position: relative !important;
        bottom: 0 !important;
        left: 0 !important;
        content: "" !important;
        width: 12px !important;
        height: 12px !important;
        flex-shrink: 0 !important;
        margin-left: 12px !important;
        background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4L6 8L10 4' stroke='%2303142e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: center !important;
        transition: transform 0.3s ease !important;
    }

    .mobile-menu .menu-item-has-children.submenu-open>a::after {
        transform: rotate(180deg) !important;
    }

    /* Style dla submenu items */
    .mobile-menu .sub-menu .menu-item {
        padding: 8px 0 !important;
        margin: 0 !important;
    }

    .mobile-menu .sub-menu a {
        font-size: 14px !important;
        color: #6a6f76 !important;
    }

    .mobile-menu .sub-menu a:hover {
        color: #03142e !important;
    }

    /* 3 poziom zagnieżdżenia */
    .mobile-menu .sub-menu .sub-menu {
        padding-left: 16px !important;
        margin-top: 8px !important;
    }

    .mobile-menu .sub-menu .sub-menu a {
        font-size: 13px !important;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus states */
.has-mega-menu>a:focus {
    outline: 2px solid #2662b8;
    outline-offset: 2px;
}

.mega-menu-sub-items a:focus {
    outline: 2px solid #2662b8;
    outline-offset: 2px;
    color: #03142e;
}

.mega-menu-promo-button:focus {
    outline: 2px solid #2662b8;
    outline-offset: 2px;
}

/* Keyboard navigation */
.has-mega-menu>a:focus-visible+.mega-menu-dropdown,
.has-mega-menu:focus-within .mega-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes megaMenuFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.has-mega-menu:hover .mega-menu-dropdown {
    animation: megaMenuFadeIn 0.3s ease forwards;
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .mega-menu-dropdown {
        display: none !important;
    }
}

.mega-menu-promo-content .nolbaz-button-primary.primary-start-button {
    padding-block: 0 !important;
    background-color: #f7f7f7;
    color: #03142e !important;

    &:hover {
        background-color: #03142e;
        color: #f7f7f7 !important;
    }
}


a.nolbaz-button-primary.primary-start-button::after {
    bottom: -100% !important;
}