/**
 * MEGA MENU STYLES - v1.1.0
 * Plik: assets/css/mega-menu.css
 * Max-width: 1400px | Breakpoint: 1024px
 * NOWOŚĆ: Panel floating dla 4 poziomu hierarchii
 */
/* ========================================
   BASE STYLES
======================================== */
.mega-menu {
    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    font-family: inherit;
}

.mega-menu__list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
}

.mega-menu__item {
    position: relative;
}

.mega-menu__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
    color: inherit;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.mega-menu__link:hover {
    color: #000;
}

.mega-menu__icon {
    display: inline-flex;
    align-items: center;
    transition: transform 0.2s ease;
}

/* ========================================
   MOBILE HEADER (logo + hamburger)
======================================== */
.mega-menu__mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: #fff;
    transition: box-shadow 0.3s ease;
    width: 100%;
}

.mega-menu__logo-link {
    display: flex;
    align-items: center;
}

.mega-menu__logo {
    width: auto;
    display: block;
    width: 120px;
}

/* ========================================
   MEGA DROPDOWN (kategorie WooCommerce)
======================================== */
.mega-menu__mega {
    position: absolute;
    top: 100%;
    left: 0;
    width: 1400px;
    max-width: calc(100vw - 40px);
    background: #fff;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

.mega-menu__item--has-mega {
    position: static;
}

.mega-menu__item--has-mega .mega-menu__mega {
    left: 50%;
    transform: translateX(-50%);
}

.mega-menu__item--has-mega:hover .mega-menu__mega {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.mega-menu__mega-inner {
    padding: 2rem;
}

.mega-menu__loader {
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

.mega-menu__columns {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.mega-menu__column {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.mega-menu__subcat-thumb-wrapper {
    flex-shrink: 0;
}

.mega-menu__subcat-content {
    flex: 1;
    min-width: 0;
}

.mega-menu__subcat {
    display: block;
    padding: 0.5rem 0;
    color: #333;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

.mega-menu__subcat:hover {
    color: #000;
}

.mega-menu__empty {
    text-align: center;
    color: #999;
    padding: 1rem;
}

/* ========================================
   POD-PODKATEGORIE (poziom 2)
======================================== */
.mega-menu__subcat--has-children {
    position: relative;
}

.mega-menu__subcat-arrow {
    display: none; /* Ukryte na desktop */
    margin-left: auto;
    transition: transform 0.2s ease;
}

.mega-menu__subcat-list {
    list-style: none;
    margin: 4px 0 0 0;
    padding: 0 0 0 0;
}

.mega-menu__subcat-child {
    display: block;
    padding: 0.25rem 0;
    color: #666;
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s ease;
    position: relative;
}

.mega-menu__subcat-child:hover {
    color: #000;
}

.mega-menu__subcat-child--see-all {
    color: #FDA635;
    font-weight: 700;
}

.mega-menu__subcat-child--see-all:hover {
    color: #e69530;
}

/* ========================================
   STRZAŁKA → dla pod-podkategorii z 4 poziomem
======================================== */
.mega-menu__arrow-right {
    color: #FDA635;
    margin-left: 4px;
    font-weight: bold;
}

.mega-menu__subcat-child--has-children {
    padding-right: 20px;
}

/* ========================================
   PANEL FLOATING (4 poziom) - DESKTOP ONLY
======================================== */
/* ========================================
   PANEL FLOATING (4 poziom) - DESKTOP ONLY
======================================== */
.mega-menu__subcat-list > li {
    position: relative; /* ✅ KLUCZOWE - panel pozycjonuje się względem <li> */
}

.mega-menu__floating-panel {
    display: none; /* Domyślnie ukryty */
    position: absolute;
    left: 100%; /* Po prawej stronie <li> */
    top: 0; /* Wartość domyślna, JS to nadpisze */
    margin-left: 10px;
    min-width: 220px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    padding: 0.75rem 0;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mega-menu__floating-panel.active {
    display: block;
    opacity: 1;
}

.mega-menu__floating-item {
    display: block;
    padding: 0.5rem 1rem;
    color: #333;
    text-decoration: none;
    font-size: 0.75rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.mega-menu__floating-item:hover {
    background: #f5f5f5;
    color: #000;
}

.mega-menu__floating-item--all {
    color: #FDA635;
    font-weight: 700;
    border-top: 1px solid #e5e5e5;
    margin-top: 0.25rem;
    padding-top: 0.75rem;
}

.mega-menu__floating-item--all:hover {
    color: #e69530;
}

/* ========================================
   ACCORDION dla pod-pod-podkategorii (mobile)
======================================== */
.mega-menu__sub-subcat-list {
    display: none; /* Desktop: ukryte (tylko panel floating) */
    list-style: none;
    margin: 4px 0 0 0;
    padding: 0 0 0 1rem;
}

.mega-menu__sub-subcat-child {
    display: block;
    padding: 0.25rem 0;
    color: #999;
    text-decoration: none;
    font-size: 0.7rem;
    transition: color 0.2s ease;
}

.mega-menu__sub-subcat-child:hover {
    color: #666;
}

.mega-menu__sub-subcat-child--all {
    color: #FDA635;
    font-weight: 700;
}

.mega-menu__sub-subcat-child--all:hover {
    color: #e69530;
}

/* ========================================
   ZWYKŁE DROPDOWN (strony/linki)
======================================== */
.mega-menu__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 999;
}

.mega-menu__item--has-dropdown:hover > .mega-menu__dropdown {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.mega-menu__item--child .mega-menu__link {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
}

/* ========================================
   HAMBURGER (mobile only)
======================================== */
.mega-menu__hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.mega-menu__hamburger-line {
    width: 24px;
    height: 2px;
    background: #000;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.mega-menu__hamburger[aria-expanded="true"] .mega-menu__hamburger-line:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.mega-menu__hamburger[aria-expanded="true"] .mega-menu__hamburger-line:nth-child(2) {
    opacity: 0;
}

.mega-menu__hamburger[aria-expanded="true"] .mega-menu__hamburger-line:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ========================================
   IKONY PODKATEGORII
======================================== */
.mega-menu__subcat-thumb {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 6px;
    display: block;
}

/* ========================================
   RESPONSIVE - MOBILE (max-width: 1024px)
======================================== */
@media (max-width: 1024px) {
    /* Ukryj panel floating na mobile */
    .mega-menu__floating-panel {
        display: none !important;
    }
    
    /* Pokaż accordion dla 4 poziomu */
    .mega-menu__sub-subcat-list {
        display: none; /* Domyślnie ukryte, rozwijane JS */
    }
    
    .mega-menu__column--has-sub-children.is-open .mega-menu__sub-subcat-list {
        display: block;
    }
    
    /* Usuń ograniczenie szerokości na mobile */
    .mega-menu {
        max-width: none;
    }
    
    /* Pokaż mobile header - rozciągnięty na cały ekran */
    .mega-menu__mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100vw;
        margin-left: calc(-50vw + 50%);
        z-index: 10001;
    }
    
    .mega-menu__hamburger {
        display: flex;
        position: relative;
        z-index: 10002;
    }
    
    .mega-menu__list {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: #fff;
        flex-direction: column;
        gap: 0;
        padding: 80px 1.5rem 1.5rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        z-index: 9998;
    }
    
    .mega-menu__list.is-open {
        transform: translateX(0);
    }
    
    .mega-menu__item {
        width: 100%;
        border-bottom: 1px solid #eee;
    }
    
    .mega-menu__link {
        padding: 1rem 0;
        justify-content: space-between;
    }
    
    /* Mega dropdown → accordion */
    .mega-menu__mega {
        position: static;
        width: 100%;
        left: auto;
        right: auto;
        transform: none !important;
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .mega-menu__item--has-mega {
        position: relative;
    }
    
    .mega-menu__item--has-mega .mega-menu__mega {
        left: 0;
        transform: none !important;
    }
    
    .mega-menu__item--has-mega.is-open .mega-menu__mega {
        max-height: 5000px;
    }
    
    .mega-menu__mega-inner {
        padding: 1rem 0;
    }
    
    .mega-menu__columns {
        grid-template-columns: 1fr;
    }
    
    /* Pod-podkategorie - accordion na mobile */
    .mega-menu__column {
    }
    
    .mega-menu__subcat-arrow {
        display: inline-flex;
    }
    
    .mega-menu__subcat-list {
        max-height: 0;
        overflow: hidden;
        padding-left: 1rem;
        transition: max-height 0.3s ease;
    }
    
    .mega-menu__column--has-children.is-open .mega-menu__subcat-list {
        max-height: 500px;
    }
    
    .mega-menu__column--has-children.is-open .mega-menu__subcat-arrow {
        transform: rotate(180deg);
    }
    
    /* Pod-pod-podkategorie (4 poziom) - accordion w accordion */
    .mega-menu__subcat-child--has-children {
        position: relative;
    }
    
    .mega-menu__arrow-right {
        position: absolute;
        right: 0;
        transition: transform 0.2s ease;
    }
    
    .mega-menu__subcat-child.is-open .mega-menu__arrow-right {
        transform: rotate(90deg);
    }
    
    .mega-menu__subcat-child.is-open + .mega-menu__sub-subcat-list {
        display: block;
        max-height: 500px;
    }
    
    /* Zwykłe dropdown → accordion */
    .mega-menu__dropdown {
        position: static;
        box-shadow: none;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .mega-menu__item--has-dropdown.is-open > .mega-menu__dropdown {
        max-height: 500px;
    }
    
    .mega-menu__item--child .mega-menu__link {
        padding: 0.75rem 0 0.75rem 1rem;
    }
    
    /* Rotacja ikony na mobile */
    .mega-menu__item.is-open > .mega-menu__link .mega-menu__icon {
        transform: rotate(180deg);
    }
}

/* MEGA MENU NA WIERZCHU NAD WSZYSTKIM NA MOBILE */
@media (max-width: 1024px) {
    .mega-menu {
        position: relative;
        z-index: 30000 !important;
    }
    
    .mega-menu__list {
        z-index: 30001 !important;
    }
    
    .mega-menu__mobile-header {
        position: fixed;
        z-index: 30002 !important;
    }
}
