/* ==========================================================================
   Header & Navigation — Unified design system (prototype match)
   ========================================================================== */

/* ----- Top bar (brand color strip) ----- */
.uheader__top {
    background: var(--brand);
    color: var(--brand-contrast);
    font-size: var(--fs-sm);
    font-weight: 600;
}
.uheader__top .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    gap: var(--s4);
    max-width: var(--container-max-width);
}
.uheader__top span {
    font-family: var(--font-display);
    font-weight: var(--fw-bold);
    letter-spacing: 0.02em;
}
.uheader__top-links {
    display: flex;
    align-items: center;
    gap: var(--s4);
    margin-left: auto;
}
#header .uheader__top a,
.uheader__top a {
    color: var(--brand-contrast) !important;
    opacity: .92;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.uheader__top a .material-icons { font-size: 16px; }
#header .uheader__top a:hover,
.uheader__top a:hover { opacity: 1; }

/* Pill button for login/account in top bar */
.uheader__top .uheader__btn {
    font-size: 10px !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0 14px !important;
    height: 22px;
    background: rgba(0,0,0,0.15);
    border-radius: 11px;
    transition: background 0.2s;
    line-height: 1 !important;
    opacity: 1;
}
.uheader__top .uheader__btn .material-icons {
    font-size: 12px !important;
    margin-right: 2px;
}
.uheader__top .uheader__btn:hover {
    background: rgba(0,0,0,0.25);
}

/* ----- Banner (displayBanner hook) ----- */
#header .header-banner { display: none; }
#header .header-banner:has(*) {
    display: block;
    background: var(--brand);
    color: var(--brand-contrast);
    text-align: center;
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    font-size: var(--fs-sm);
    padding: var(--s2) var(--s4);
}
#header .header-banner a { color: #fff; text-decoration: underline; }

/* ----- Mobile nav bar ----- */
body:not(#checkout) #header .header-nav { display: none; }
@media (max-width: 991px) {
    #header .header-nav:has(.mobile #menu-icon) {
        display: block;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        min-height: 56px;
    }
}
#header .header-nav .container {
    min-height: 56px;
    display: flex;
    align-items: center;
}

/* ----- Main header (single flex row) ----- */
#header .header-top {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.uheader__main {
    display: flex;
    align-items: center;
    gap: var(--s6);
    padding: 0;
    max-width: var(--container-max-width);
}

/* ----- Logo ----- */
.uheader__logo { flex: none; }
.uheader__logo h1 { margin: 0; padding: 0; line-height: 0; }
.ulogo {
    display: flex;
    align-items: center;
    gap: var(--s3);
    text-decoration: none;
}
.ulogo__img {
    max-height: 64px;
    width: auto;
    transition: transform var(--t-base);
}
.ulogo:hover .ulogo__img { transform: rotate(-2deg); }

/* ----- Nav + Search area (displayTop renders menu + search here) ----- */
.uheader__nav {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--s4);
}
/* Hide anything from displayTop that isn't menu or search */
.uheader__nav > *:not(#_desktop_top_menu):not(#search_widget) { display: none !important; }

#header .menu.js-top-menu {
    display: flex !important;
    align-items: center;
}
#header .menu.js-top-menu .clearfix { display: none; }

#header .top-menu {
    display: flex;
    align-items: center;
    gap: var(--s5);
    list-style: none;
    margin: 0;
    padding: 0;
}
#header .top-menu li { list-style: none; }

#header .top-menu a[data-depth="0"] {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: var(--fw-bold);
    text-transform: none;
    letter-spacing: 0;
    color: var(--ink);
    display: inline-block;
    padding: 8px 2px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    transition: color var(--t-base), border-color var(--t-base);
    text-decoration: none;
}
#header .top-menu a[data-depth="0"]:hover,
#header .top-menu a[data-depth="0"]:focus-visible,
#header .top-menu a[data-depth="0"].current {
    color: var(--brand-ink);
    border-color: var(--brand);
    background: none;
}

/* Submenus */
#header .top-menu[data-depth="1"] {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    padding: var(--s2);
    margin-top: var(--s2);
}
#header .top-menu[data-depth="1"] a {
    color: var(--ink);
    padding: var(--s2) var(--s4);
    border-radius: var(--r-sm);
    font-family: var(--font-body);
    font-weight: var(--fw-bold);
    font-size: var(--fs-base);
    display: block;
    transition: background var(--t-base), color var(--t-base);
}
#header .top-menu[data-depth="1"] a:hover {
    background: var(--page);
    color: var(--brand);
}

/* ----- Search widget (inside .uheader__nav, pushed right) ----- */
.uheader__nav #search_widget {
    display: block !important;
    margin-left: auto;
    flex: 1;
    max-width: 340px;
}
.uheader__nav #search_widget form {
    position: relative;
    display: flex;
    align-items: center;
}
.uheader__nav #search_widget input[type="text"] {
    width: 100%;
    height: 44px;
    border-radius: var(--r-pill);
    border: 1.5px solid var(--line);
    background: var(--page);
    padding: 0 16px 0 42px;
    font-family: var(--font-body);
    font-size: var(--fs-sm);
    color: var(--ink);
    outline: none;
    transition: border-color var(--t-base), background var(--t-base);
}
.uheader__nav #search_widget input[type="text"]:focus {
    border-color: var(--brand);
    background: #fff;
}
.uheader__nav #search_widget form i.search {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 42px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 18px;
    color: var(--muted);
    pointer-events: none;
}

/* ----- Cart + User actions ----- */
.uheader__actions {
    display: flex;
    align-items: center;
    gap: var(--s2);
    flex: none;
}

/* Kill old absolute positioning from previous layout */
#header .header-top-cluster,
#header .header-top-right { display: none !important; }

/* User dropdown */
#header .user-info { display: flex; align-items: center; }
#header .user-dropdown { position: relative; }
#header .user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ink);
    border-radius: var(--r-pill);
    transition: background var(--t-base), color var(--t-base);
}
#header .user-avatar .material-icons { font-size: 28px; }
#header .user-avatar:hover,
#header .user-dropdown:hover .user-avatar,
#header .user-dropdown:focus-within .user-avatar {
    color: var(--brand);
    background: var(--brand-tint);
}

#header .user-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    padding: var(--s2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-pop);
    text-align: left;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--t-base), transform var(--t-base), visibility var(--t-base);
}
#header .user-dropdown:hover .user-dropdown-menu,
#header .user-dropdown:focus-within .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
#header .user-dropdown-name {
    display: block;
    padding: 6px var(--s2) var(--s2);
    margin-bottom: 4px;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-display);
    font-weight: var(--fw-bold);
    font-size: var(--fs-base);
    color: var(--ink);
    white-space: nowrap;
}
#header .user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: var(--s1);
    padding: 8px var(--s2);
    border-radius: var(--r-sm);
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: var(--fw-bold);
    font-size: var(--fs-sm);
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--t-base), color var(--t-base);
}
#header .user-dropdown-menu a:hover {
    background: var(--page);
    color: var(--brand);
}
#header .user-dropdown-menu a .material-icons { font-size: 18px; }
#header .user-dropdown-menu a.logout { color: var(--danger); }
#header .user-dropdown-menu a.logout:hover {
    color: var(--danger);
    background: rgba(224, 49, 49, 0.08);
}

/* Cart */
#header .blockcart,
#header .blockcart .header { display: flex; align-items: center; }
#header .blockcart a {
    display: inline-flex;
    align-items: center;
    gap: var(--s1);
    color: var(--ink);
    font-family: var(--font-body);
    font-weight: var(--fw-bold);
    font-size: var(--fs-sm);
    text-decoration: none;
    padding: 4px var(--s2);
    border-radius: var(--r-pill);
    transition: background var(--t-base), color var(--t-base);
}
#header .blockcart.active a:hover {
    color: var(--brand);
    background: var(--brand-tint);
}
#header .blockcart .material-icons.shopping-cart {
    font-size: 24px;
    color: var(--ink);
    transition: color var(--t-base);
}
#header .blockcart.active a:hover .material-icons.shopping-cart { color: var(--brand); }
#header .blockcart .cart-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
}
#header .blockcart .cart-products-count {
    position: absolute;
    top: -7px;
    right: -9px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: var(--r-pill);
    background: var(--brand);
    color: var(--brand-contrast);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: var(--fw-bold);
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
}
#header .blockcart.inactive .cart-products-count { display: none; }
#header .blockcart .cart-label { display: none; }

/* ----- Mobile ----- */
@media (max-width: 991px) {
    .uheader__top { display: none; }
    .uheader__nav,
    .uheader__search,
    .uheader__actions { display: none !important; }
    .uheader__main { padding: var(--s2) 0; }
    .uheader__logo { min-height: 56px; display: flex; align-items: center; }
    .ulogo__img { max-height: 48px; }
    .top-logo #_mobile_logo img,
    .top-logo img { max-height: 48px; width: auto; }

    #menu-icon i {
        font-size: 28px;
        color: var(--ink);
        padding: var(--s2);
        border-radius: var(--r-md);
        background: var(--page);
    }
    #mobile_top_menu_wrapper {
        background: var(--surface);
        padding: var(--s4);
        border-radius: var(--r-lg);
        box-shadow: var(--shadow-md);
        margin-top: var(--s2);
    }
    #mobile_top_menu_wrapper a {
        font-family: var(--font-display);
        font-weight: var(--fw-bold);
        color: var(--ink);
        padding: var(--s2) var(--s4);
        display: block;
        border-radius: var(--r-sm);
    }
    #mobile_top_menu_wrapper a:hover {
        background: var(--page);
        color: var(--brand);
    }
}
