/*
 * ATFPRO Header — v3
 * Hardkodowana nawigacja z ikonami SVG w dropdownach + dynamiczne account actions.
 * Header zawsze ciemny (brand identity, patrz theme.css).
 */

/* =====================================================
   HEADER — kontener
   ===================================================== */
.atfpro-header {
    background-color: var(--color-header-bg);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.atfpro-header__container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    gap: 1.5rem;
}

/* ----- Logo ----- */
.atfpro-header__logo-wrapper { flex-shrink: 0; }
.atfpro-header__logo-link { display: inline-flex; align-items: center; }
.atfpro-header__logo-img { height: 2rem; display: block; }

/* =====================================================
   DESKTOP NAV
   ===================================================== */
.atfpro-header__nav { display: none; }

@media (min-width: 980px) {
    .atfpro-header__nav { display: block; flex: 1; }
}

.atfpro-header__nav-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0 1rem;
    gap: 2rem;
    align-items: center;
}

.atfpro-header__nav-menu > li { position: relative; }

.atfpro-header__nav-link {
    font-family: var(--font-base);
    color: var(--color-header-text);
    text-decoration: none;
    transition: color 0.3s;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    background: none;
    border: none;
    padding: 0.5rem 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

/* Override reset.css `button:hover/focus { background:#c36 }` z hello-elementor —
   nav-linki w headerze nie maja tla na hover, zmienia sie tylko kolor tekstu. */
.atfpro-header__nav-link:hover,
.atfpro-header__nav-link:focus,
.atfpro-header__nav-link[aria-expanded="true"] {
    background: transparent;
    color: var(--color-header-text-hover);
}

.atfpro-header__nav-link:focus:not(:focus-visible) {
    outline: none;
}

.atfpro-header__nav-link .chevron {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
    opacity: 0.7;
}

.atfpro-header__nav-link[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

.atfpro-header__badge-lock {
    display: inline-flex;
    align-items: center;
    margin-left: 0.15rem;
    width: 14px;
    height: 14px;
    opacity: 0.55;
}

/* =====================================================
   DROPDOWN (desktop)
   ===================================================== */
.atfpro-header__dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 320px;
    background-color: var(--gray-500);
    border: 1px solid var(--gray-400);
    border-radius: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
    z-index: 1001;
}

/* Hover bridge — niewidoczny obszar nad dropdownem, żeby kursor mógł przejść bez zniknięcia */
.atfpro-header__nav-menu > li.has-dropdown::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
    z-index: 1000;
}

.atfpro-header__nav-menu > li.has-dropdown:hover > .atfpro-header__dropdown,
.atfpro-header__nav-menu > li.has-dropdown:focus-within > .atfpro-header__dropdown,
.atfpro-header__dropdown[data-open="true"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition-delay: 0s;
}

/* Wariant szerszy dla dropdownów z dłuższymi opisami */
.atfpro-header__dropdown--wide {
    min-width: 360px;
}

.atfpro-header__dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.75rem 0.85rem;
    color: var(--color-header-text);
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    white-space: normal;
}

.atfpro-header__dropdown-item:hover {
    background-color: var(--gray-400);
    color: var(--color-header-text-hover);
}

.atfpro-header__dropdown-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: rgba(251, 191, 36, 0.12);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-accent-yellow);
}

.atfpro-header__dropdown-content { flex: 1; min-width: 0; }

.atfpro-header__dropdown-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-white);
    margin-bottom: 2px;
    line-height: 1.3;
}

.atfpro-header__dropdown-desc {
    display: block;
    font-size: 0.8rem;
    color: rgba(233, 236, 239, 0.65);
    line-height: 1.4;
    font-weight: 400;
}

.atfpro-header__dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.4rem 0.5rem;
}

.atfpro-header__dropdown-footer {
    margin: 0.4rem -0.5rem -0.5rem;
    padding: 0.85rem 1.2rem;
    background: rgba(251, 191, 36, 0.07);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0 0 0.45rem 0.45rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.8rem;
}

.atfpro-header__dropdown-footer-text { color: rgba(233, 236, 239, 0.7); }

.atfpro-header__dropdown-footer-cta {
    color: var(--color-accent-yellow);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.atfpro-header__dropdown-footer-cta:hover {
    color: var(--color-accent-yellow-hover);
    text-decoration: underline;
}

/* =====================================================
   ACTIONS (prawa strona)
   ===================================================== */
.atfpro-header__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* =====================================================
   LANGUAGE SWITCHER (override domyślnych stylów z atfpro_language_switcher)
   ===================================================== */
.atfpro-language-switcher { position: relative; }

.atfpro-language-switcher__button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: var(--color-header-text);
    cursor: pointer;
    font-family: var(--font-base);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.atfpro-language-switcher__button:hover,
.atfpro-language-switcher__button:focus {
    color: var(--color-header-text-hover);
    background-color: var(--gray-400);
}
.atfpro-language-switcher__button:focus:not(:focus-visible) {
    outline: none;
}

.atfpro-language-switcher__flag {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
    object-fit: cover;
    margin-right: 0;
}

.atfpro-language-switcher__code {
    font-weight: 500;
    letter-spacing: 0.02em;
}

.atfpro-language-switcher__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background-color: var(--gray-500);
    border: 1px solid var(--gray-400);
    border-radius: 0.375rem;
    padding: 0.4rem 0;
    min-width: 11rem;
    z-index: 1001;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    /* Stan ukryty. NIE display:none — display nie da się animować, przez co okno
       znikało natychmiast po zejściu kursora (zanim user zdążył przejechać przez
       4px przerwę na listę). opacity/visibility pozwalają opóźnić zanikanie. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    /* Zanikanie z opóźnieniem (hold) 200ms — kursor ma czas przejść z przycisku
       na listę. Pojawianie jest natychmiastowe (delay 0s w stanie pokazanym niżej).
       visibility flipuje na hidden dopiero PO holdzie + fade (0.2s + 0.18s = 0.38s),
       żeby okno pozostało klikalne i mogło odzyskać :hover przez cały ten czas. */
    transition: opacity 0.18s ease 0.2s, transform 0.18s ease 0.2s, visibility 0s linear 0.38s;
}

/* Hover bridge — niewidoczny pasek przykrywający 4px przerwę między przyciskiem
   a listą, żeby kursor nie tracił :hover po drodze (jak w nav-dropdownach). */
.atfpro-language-switcher::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 0;
    width: 100%;
    height: 6px;
    background: transparent;
}

.atfpro-language-switcher:hover .atfpro-language-switcher__dropdown,
.atfpro-language-switcher:focus-within .atfpro-language-switcher__dropdown,
.atfpro-language-switcher__dropdown[data-open="true"] {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 0.18s ease 0s, transform 0.18s ease 0s, visibility 0s linear 0s;
}

.atfpro-language-switcher__item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.85rem;
    color: var(--color-header-text);
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font-base);
    font-size: 0.9rem;
}

.atfpro-language-switcher__item:hover {
    background-color: var(--gray-400);
    color: var(--color-header-text-hover);
}

.atfpro-language-switcher__item--current {
    background-color: rgba(251, 191, 36, 0.1);
    color: var(--color-accent-yellow);
}

/* =====================================================
   ACCOUNT ACTIONS (Logowanie / Rejestracja / User menu)
   ===================================================== */
.atfpro-header__account-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.12);
    margin: 0 0.25rem;
}

.atfpro-header__account {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.atfpro-header__btn-login {
    color: var(--color-header-text);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    font-weight: 500;
}

.atfpro-header__btn-login:hover {
    background-color: var(--gray-400);
    color: var(--color-header-text-hover);
}

.atfpro-header__btn-register {
    background: var(--color-accent-yellow);
    color: var(--color-black);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.55rem 1.1rem;
    border-radius: 6px;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.atfpro-header__btn-register:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    color: var(--color-black);
}

.atfpro-header__user-wrapper {
    position: relative;
}

.atfpro-header__user-menu {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.85rem 0.3rem 0.3rem;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    color: var(--color-header-text);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    font-family: var(--font-base);
    font-size: 0.85rem;
}

.atfpro-header__user-menu:hover,
.atfpro-header__user-menu:focus,
.atfpro-header__user-menu[aria-expanded="true"] {
    background-color: var(--gray-400);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--color-header-text-hover);
}
.atfpro-header__user-menu:focus:not(:focus-visible) {
    outline: none;
}

.atfpro-header__user-menu .chevron {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
    opacity: 0.7;
    margin-left: 0.15rem;
}
.atfpro-header__user-menu[aria-expanded="true"] .chevron {
    transform: rotate(180deg);
}

/* User dropdown — prawa strona headera, kompaktowa lista bez ikon */
.atfpro-header__user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 240px;
    background-color: var(--gray-500);
    border: 1px solid var(--gray-400);
    border-radius: 0.5rem;
    padding: 0.4rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s 0.2s;
    z-index: 1001;
}

/* Hover bridge — niewidoczny obszar nad dropdownem, kursor moze przejsc z buttona */
.atfpro-header__user-wrapper.has-dropdown::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
    z-index: 1000;
}

.atfpro-header__user-wrapper.has-dropdown:hover > .atfpro-header__user-dropdown,
.atfpro-header__user-wrapper.has-dropdown:focus-within > .atfpro-header__user-dropdown,
.atfpro-header__user-dropdown[data-open="true"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
    transition-delay: 0s;
}

.atfpro-header__user-dropdown-item {
    display: block;
    padding: 0.6rem 0.85rem;
    color: var(--color-header-text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.3;
    transition: background-color 0.2s ease;
}

.atfpro-header__user-dropdown-item:hover,
.atfpro-header__user-dropdown-item:focus {
    background-color: var(--gray-400);
    color: var(--color-header-text-hover);
}

.atfpro-header__user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent-yellow);
    color: var(--color-black);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.atfpro-header__user-name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* =====================================================
   MOBILE BURGER
   ===================================================== */
.atfpro-header__mobile-toggle {
    display: block;
    background: none;
    border: 1px solid var(--color-header-text);
    color: var(--color-header-text);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 4px;
    line-height: 0;
}

.atfpro-header__mobile-toggle:hover,
.atfpro-header__mobile-toggle:focus {
    color: var(--color-header-text-hover);
    border-color: var(--color-header-text-hover);
    background-color: var(--gray-400);
}
.atfpro-header__mobile-toggle:focus:not(:focus-visible) {
    outline: none;
}

/* Mobile menu close button — bez tla z reset.css */
.atfpro-mobile-menu__close:hover,
.atfpro-mobile-menu__close:focus {
    background: transparent;
    color: var(--color-header-text-hover);
}
.atfpro-mobile-menu__close:focus:not(:focus-visible) {
    outline: none;
}

@media (min-width: 980px) {
    .atfpro-header__mobile-toggle { display: none; }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 979px) {
    .atfpro-header__container { padding: 0.75rem 1rem; }
    .atfpro-header__btn-login,
    .atfpro-header__btn-register,
    .atfpro-header__user-menu,
    .atfpro-header__account-divider,
    .atfpro-header__account {
        display: none;
    }
    .atfpro-language-switcher__code { display: none; }
    #themeToggle { display: none; }
}

/* =====================================================
   MOBILE MENU PANEL
   ===================================================== */
.atfpro-mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background-color: var(--color-header-bg);
    z-index: 1002;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.atfpro-mobile-menu.active {
    transform: translateX(0);
}

.atfpro-mobile-menu__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.atfpro-mobile-menu__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.atfpro-mobile-menu__logo { height: 2rem; }

.atfpro-mobile-menu__close {
    background: none;
    border: none;
    color: var(--color-header-text);
    cursor: pointer;
    line-height: 0;
    padding: 0.25rem;
}

.atfpro-mobile-menu__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
}

.atfpro-mobile-menu__nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.atfpro-mobile-menu__nav-menu > li > a {
    font-family: var(--font-base);
    color: var(--color-white) !important;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    display: block;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background-color 0.2s;
}

.atfpro-mobile-menu__nav-menu > li > a:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.atfpro-mobile-menu__nav-menu .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(255, 255, 255, 0.03);
}

.atfpro-mobile-menu__nav-menu li.submenu-open > .sub-menu {
    max-height: 1000px;
}

.atfpro-mobile-menu__nav-menu .sub-menu li a {
    font-family: var(--font-base);
    color: var(--gray-200) !important;
    font-weight: 400;
    font-size: 0.9rem;
    text-decoration: none;
    display: block;
    padding: 0.625rem 1.5rem 0.625rem 2.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background-color 0.2s, color 0.2s;
}

.atfpro-mobile-menu__nav-menu .sub-menu li a:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--color-white) !important;
}

.atfpro-mobile-menu__nav-menu > li.menu-item-has-children > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.atfpro-mobile-menu__nav-menu > li.menu-item-has-children > a::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--gray-230);
    border-bottom: 2px solid var(--gray-230);
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.atfpro-mobile-menu__nav-menu > li.menu-item-has-children.submenu-open > a::after {
    transform: rotate(-135deg);
}

/* Separator między menu nawigacyjnym a sekcją konta */
.atfpro-mobile-menu__account-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.75rem 1.5rem;
    list-style: none;
}

/* CTA Rejestracja w mobile menu */
.atfpro-mobile-menu__nav-menu .atfpro-mobile-menu__cta {
    color: var(--color-accent-yellow) !important;
    font-weight: 600;
}

.atfpro-mobile-menu__footer {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile theme toggle — full-width button z ikona + etykieta tekstowa.
   Podwojenie klasy (.atfpro-theme-toggle.atfpro-theme-toggle--mobile)
   da specyficznosc 0,2,0 i wygrywa nad bazowym .atfpro-theme-toggle
   z theme-toggle.css (width:36px, border-radius:50%, padding:0). */
.atfpro-theme-toggle.atfpro-theme-toggle--mobile {
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-header-text);
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s;
}

.atfpro-theme-toggle.atfpro-theme-toggle--mobile:hover,
.atfpro-theme-toggle.atfpro-theme-toggle--mobile:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--color-header-text-hover);
}

.atfpro-theme-toggle.atfpro-theme-toggle--mobile svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.atfpro-theme-toggle__label {
    font-size: 0.9rem;
    font-weight: 500;
}

.atfpro-mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.atfpro-mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}
