/* ==========================================================================
   LOGO (Kontrola rozmiaru)
   ========================================================================== */
.site-branding {
    display: flex;
    align-items: center;
    max-width: 180px; /* Maksymalna szerokość logo */
    justify-content: center;
}

.site-branding img, 
.site-branding .custom-logo {
    display: block;
    width: 100%;
    height: auto;
    max-height: 50px; /* Maksymalna wysokość logo, by nie rozpychało nagłówka */
    object-fit: contain;
}

.site-title-text {
    font-size: 22px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-decoration: none;
    color: inherit;
}

/* Ukrywamy domyślnie mobilną wyszukiwarkę na desktopie */
.header-left-mobile {
    display: none;
}

/* ==========================================================================
   GLOBALNE USTAWIENIA NAGŁÓWKA (Sticky - Zawsze białe tło i przyklejony)
   ========================================================================== */
.site-header {
    position: sticky !important;
    top: 0;
    width: 100%;
    background-color: #ffffff !important;
    border-bottom: 1px solid #eaeaea;
    padding: 15px 0;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Blokada przewijania tła gdy menu boczny jest aktywny */
body.mobile-menu-active {
    overflow: hidden !important;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 4%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* Kolorystyka elementów */
.main-menu-list > li > a,
.header-action-item a,
.site-title-text,
.mobile-search-toggle {
    color: #1a1a1a !important;
}

.site-branding img,
.custom-logo {
    filter: none !important;
}

/* ==========================================================================
   MENU GŁÓWNE (Desktop)
   ========================================================================== */
.main-menu-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 28px;
}

.main-menu-list > li {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.main-menu-list a {
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    transition: opacity 0.2s ease;
}

.main-menu-list a:hover {
    opacity: 0.7;
}

/* Strzałka rozwijana dla wersji DESKTOP */
.main-menu-list .menu-item-has-children > a::after,
.main-menu-list .page_item_has_children > a::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    vertical-align: middle;
    border-right: 1.5px solid #1a1a1a;
    border-bottom: 1.5px solid #1a1a1a;
    /* translateY PRZED rotate = przesunięcie w pionie ekranu; chevron w dół idzie w górę */
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.2s ease;
}

/* Chevron w górę: widoczna jest górna połowa, więc przesuwamy w dół */
.main-menu-list .menu-item-has-children:hover > a::after,
.main-menu-list .page_item_has_children:hover > a::after {
    transform: translateY(2px) rotate(-135deg);
}

/* Dropdown dla kategorii w sklepie (Desktop) */
.main-menu-list li ul {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background-color: #ffffff;
    min-width: 240px;
    padding: 10px 0;
    list-style: none;
    margin: 0;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 10000;
}

.main-menu-list li:hover > ul {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.main-menu-list li ul li {
    display: block;
    width: 100%;
}

.main-menu-list li ul li a::after {
    display: none !important;
}

.main-menu-list li ul a {
    display: block;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 400;
    color: #333333 !important;
    text-transform: none;
    white-space: normal !important; /* ROZWIĄZANIE: przenoszenie długich tekstów do nowej linii */
}

.main-menu-list li ul a:hover {
    background-color: #f9f9f9;
}

/* ==========================================================================
   IKONY AKCJI (Koszyk, konto, szukaj)
   ========================================================================== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-action-item a,
.cart-contents {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a !important;
    transition: opacity 0.2s ease;
    text-decoration: none;
}

.header-action-item a:hover {
    opacity: 0.7;
}

/* Licznik przedmiotów w koszyku */
.cart-count {
    position: absolute;
    top: -6px;
    right: -8px;
    background-color: #1a1a1a;
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ffffff;
    z-index: 2;
}

/* ==========================================================================
   PRZYCISK HAMBURGERA (3 linie na pasku głównym)
   ========================================================================== */
.menu-toggle {
    display: none; /* Ukryty na desktopie */
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    z-index: 9998;
    flex-direction: column;
    justify-content: space-between;
    width: 24px;
    height: 14px;
    box-sizing: content-box;
}

.menu-toggle .hamburger-line {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #1a1a1a;
}

/* Przyciski wewnątrz wysuwanego menu nie korzystają z hamburger-toggle */
.menu-close-btn {
    display: none;
}

/* Ukrywamy dodatkowe rowy draweru na desktopie */
.drawer-extra-rows {
    display: none;
}


/* ==========================================================================
   BOCZNY PANEL WYSUWANY - SLIDE-OUT DRAWER (MOBILE)
   ========================================================================== */
@media screen and (max-width: 991px) {
    /* Pozycjonowanie elementów w nagłówku na mobile */
    .header-left-mobile {
        display: flex;
        align-items: center;
        flex: 1; /* Pcha logo do środka */
    }

    .mobile-search-toggle {
        background: none;
        border: none;
        padding: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
    }

    .site-branding {
        flex: 2; /* Centrowanie logo */
        justify-content: center;
    }

    .header-actions {
        flex: 1; /* Pcha logo do środka */
        justify-content: flex-end;
        gap: 15px; /* Kompaktowe ułożenie koszyka obok hamburgera */
    }

    /* Ukrywamy elementy czysto desktopowe */
    .desktop-search,
    .desktop-account {
        display: none !important;
    }

    .menu-toggle {
        display: flex !important; /* Pokazujemy hamburger */
    }

    /* Ukrywamy desktopowe indykatory strzałek */
    .main-menu-list .menu-item-has-children > a::after,
    .main-menu-list .page_item_has_children > a::after {
        display: none !important;
    }

    /* 1. PRZYCIEMNIONE TŁO (Backdrop Overlay) */
    .main-navigation::after {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 99990;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    /* Aktywacja przyciemnienia */
    .main-navigation.toggled::after {
        opacity: 1;
        visibility: visible;
    }

    /* 2. KONTENER BOCZNEGO PANELU (Wysuwany z prawej strony) */
    .menu-drawer-container {
        position: fixed;
        top: 0;
        right: -320px; /* Całkowicie ukryty poza ekranem */
        width: 320px; /* Szerokość bocznego panelu */
        
        /* KLUCZOWA POPRAWKA 1: 100dvh uwzględnia paski nawigacyjne przeglądarek */
        height: 100vh; /* Zabezpieczenie dla bardzo starych telefonów */
        height: 100dvh; /* Prawidłowa, dynamiczna wysokość */
        
        background-color: #ffffff;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
        z-index: 99999; /* Nad maską przyciemniającą */
        
        /* KLUCZOWA POPRAWKA 2: Elastyczny padding dolny chroniący przed paskiem "Home" na iPhone */
        padding: 80px 24px calc(25px + env(safe-area-inset-bottom, 20px)) 24px;
        
        display: flex;
        flex-direction: column;
        justify-content: space-between; /* Spycha dodatkowe rowy na sam dół */
        transition: right 0.35s cubic-bezier(0.25, 1, 0.5, 1);
        box-sizing: border-box;
    }

    .main-navigation.toggled .menu-drawer-container {
        right: 0; /* Pojawia się na ekranie */
    }

    /* 3. PRZYCISK ZAMKNIĘCIA "X" (Z ramką ze screena) */
    .menu-close-btn {
        display: flex !important;
        position: absolute;
        top: 20px;
        right: 20px;
        background: none;
        border: 1px solid #eaeaea;
        border-radius: 4px;
        padding: 6px;
        cursor: pointer;
        color: #1a1a1a;
        transition: background-color 0.2s, border-color 0.2s;
    }

    .menu-close-btn:hover {
        background-color: #f9f9f9;
        border-color: #cccccc;
    }

    /* 4. POZYCJE MENU W PANELU */
    .main-menu-list {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0 !important;
        width: 100%;
        overflow-y: auto;
        flex-grow: 1;
        margin-bottom: 20px !important; /* Zmniejszony odstęp, by menu lepiej wyglądało na małych ekranach */
    }

    .main-menu-list > li {
        width: 100%;
        border-bottom: 1px solid #f5f5f5;
        padding: 0 !important;
        display: flex !important;
        flex-wrap: wrap !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    /* Główny link po lewej stronie panelu */
    .main-menu-list > li > a {
        font-size: 15px;
        font-weight: 500;
        color: #1a1a1a !important;
        padding: 16px 0 !important;
        flex-grow: 1;
        text-transform: none;
        letter-spacing: normal;
        white-space: normal !important; /* Zapewnia zawijanie linków głównych */
    }

    /* ==========================================================================
       ROZWIJANE AKORDEONOWO PODMENU
       ========================================================================== */
    .main-menu-list li ul {
        display: none !important;
        position: static !important;
        transform: none !important;
        width: 100% !important;
        box-shadow: none !important;
        padding: 0 0 15px 15px !important; /* Wcięcie dla podkategorii */
        background: transparent !important;
        visibility: visible !important;
        pointer-events: auto !important;
        opacity: 1 !important;
    }

    .main-menu-list li.sub-menu-open > ul {
        display: block !important;
    }

    .main-menu-list li ul li {
        padding: 0;
        border: none;
    }

    /* Linki podkategorii - ZAWIJANIE TEKSTU */
    .main-menu-list li ul a {
        font-size: 14px;
        color: #555555 !important;
        padding: 10px 0 !important;
        text-transform: none;
        white-space: normal !important; /* Naprawa: Długie nazwy podkategorii lądują w nowej linii */
        word-wrap: break-word;
        display: block;
    }

    /* Przycisk strzałki (Dropdown Toggle) */
    .dropdown-toggle-btn {
        background: none !important;
        border: none !important;
        padding: 12px !important;
        cursor: pointer;
        display: flex !important;
        align-items: center;
        justify-content: center;
        color: #666666 !important;
        transition: transform 0.25s ease;
        z-index: 10;
    }

    .sub-menu-open > .dropdown-toggle-btn {
        transform: rotate(180deg);
    }

    .dropdown-toggle-btn svg {
        width: 16px;
        height: 16px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
        pointer-events: none;
    }

    /* ==========================================================================
       DODATKOWE 2 ROWY NA DOLE (Koszyk | Konto)
       ========================================================================== */
    .drawer-extra-rows {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        border-top: 1.5px solid #eaeaea; /* Linia oddzielająca od reszty menu */
        padding-top: 15px;
    }

    .drawer-row-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 0;
        text-decoration: none;
        color: #1a1a1a !important;
        font-size: 15px;
        font-weight: 500;
        border-bottom: 1px solid #f5f5f5;
        transition: opacity 0.2s ease;
    }

    .drawer-row-item:last-child {
        border-bottom: none; /* Ostatni element bez dolnej kreski */
    }

    .drawer-row-item:hover {
        opacity: 0.7;
    }

    .drawer-row-left {
        display: flex;
        align-items: center;
        gap: 12px; /* Odstęp między ikoną a tekstem */
    }

    .drawer-row-left svg {
        color: #1a1a1a;
    }

    /* Licznik w drawerze na wzór minimalistycznej odznaki */
    .drawer-cart-badge {
        background-color: #1a1a1a;
        color: #ffffff;
        font-size: 11px;
        font-weight: 600;
        padding: 2px 8px;
        border-radius: 12px;
        min-width: 14px;
        text-align: center;
    }
}

.account-menu-wrapper {
    position: relative;
}

.account-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 250px;
    background-color: #ffffff;
    border: 1px solid #eaeaea;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border-radius: 12px;
    z-index: 9999;
    margin-top: 15px;
    padding: 8px 0;
}

/* Zmienione na ostylowanie linku <a> oraz wymuszenie lewej strony */
.account-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Wymusza wyrównanie do lewej w układzie flex */
    text-align: left; /* Twarde wyrównanie tekstu do lewej */
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 8px;
    text-decoration: none !important; /* Blokuje podkreślanie linku */
    color: inherit;
    transition: background-color 0.2s ease;
}

.account-dropdown-header:hover {
    background-color: #f9f9f9; /* Delikatne podświetlenie klikalnego nagłówka */
}

.account-avatar img {
    border-radius: 50%;
    width: 42px;
    height: 42px;
    object-fit: cover;
    border: 1px solid #eaeaea;
    display: block;
}

.account-name {
    margin-left: 14px;
    font-weight: 600;
    font-size: 15px;
    color: #111;
    word-break: break-word;
    line-height: 1.2;
}

.account-dropdown-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.account-dropdown-menu li {
    margin: 0 8px;
    padding: 0;
}

.account-dropdown-menu li a {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Wymusza zawartość do lewej */
    text-align: left; /* Wymusza tekst do lewej */
    gap: 12px;
    padding: 10px 12px;
    color: #444;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
}

.account-dropdown-menu li a svg {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.account-dropdown-menu li a:hover {
    background-color: #f5f5f5;
    color: #111;
}

.account-dropdown-menu li a:hover svg {
    opacity: 1;
}

/* Wyróżnienie "Wyloguj się" na czerwono */
.account-dropdown-menu .logout-item {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.account-dropdown-menu li a.logout-link {
    color: #dc2626 !important;
}

.account-dropdown-menu li a.logout-link svg {
    stroke: #dc2626;
    opacity: 0.8;
}

.account-dropdown-menu li a.logout-link:hover {
    background-color: #fef2f2;
    color: #b91c1c !important;
}

.account-dropdown-menu li a.logout-link:hover svg {
    opacity: 1;
}

/* Ukrycie rozwijanego menu dla urządzeń mobilnych */
@media (max-width: 768px) {
    .account-dropdown {
        display: none !important;
    }
}
