/* ===========================
   BB Header CSS
   =========================== */

/* ===========================
   PREHEADER / TOPBAR
   =========================== */
.bb-preheader {
    background: var(--bb-black);
    color: #fff;
    font-size: var(--bb-tiny);
    letter-spacing: var(--bb-ls-wide);
    text-transform: uppercase;
    position: relative;
    z-index: var(--bb-z-sticky);
}

.bb-preheader__inner {
    max-width: var(--bb-max);
    margin: 0 auto;
    padding: 8px var(--bb-gutter);
    text-align: center;
}

/* ===========================
   MAIN HEADER
   =========================== */
header#masthead.site-header {
    border-bottom: 1px solid var(--bb-line);
    background: var(--bb-bg);
    position: sticky;
    top: 0;
    z-index: var(--bb-z-sticky);
}

header#masthead .main-header {
    display: grid !important;
    grid-template-columns: 1fr auto 1fr !important;
    align-items: center;
    padding: 16px var(--bb-gutter);
    /*gap: 20px;*/
    max-width: 100%;
    overflow: visible;
}

/* Ensure each grid child stays in its lane */
header#masthead .main-header > * {
    min-width: 0;
}

/* ===========================
   LEFT SECTION (Hamburger + Navigation)
   =========================== */
.bb-header__left {
    display: flex;
    align-items: center;
    gap: 24px;
    justify-self: start;
    grid-column: 1;
    grid-row: 1;
}

/* Navigation wrapper - hidden on mobile */
.bb-header-nav-wrapper {
    display: none;
}

@media (min-width: 992px) {
    .bb-header-nav-wrapper {
        display: block;
    }
}

.bb-header-nav {
    display: flex;
    align-items: center;
    gap: 24px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.bb-header-nav__item {
    margin: 0;
    padding: 0;
}

.bb-header-nav__link {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: var(--bb-ls-wide);
    text-transform: uppercase;
    text-decoration: none;
    color: var(--bb-fg);
    transition: opacity var(--bb-transition-fast);
    white-space: nowrap;
}

.bb-header-nav__link:hover {
    opacity: 0.6;
    color: var(--bb-fg);
}

/* ===========================
   CENTER LOGO
   =========================== */
header#masthead .site-branding {
    justify-self: center;
    text-align: center;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    grid-column: 2;
    grid-row: 1;
}

/* Ensure Shoptimizer branding doesn't have conflicting styles */
header#masthead .main-header .site-branding {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    float: none;
}

/* ===========================
   RIGHT SIDE ICONS
   =========================== */
.bb-header__right {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-self: end;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    max-width: 100%;
    grid-column: 3;
    grid-row: 1;
}

.bb-header__icon {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer;
    color: var(--bb-fg) !important;
    line-height: 1;
    transition: opacity var(--bb-transition-fast);
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none !important;
}

/* SVG Icon Styling - Heroicons */
.bb-header__icon .bb-icon,
.bb-header__icon svg {
    width: 20px !important;
    height: 20px !important;
    stroke: currentColor !important;
    fill: none !important;
    display: block !important;
    flex-shrink: 0;
}

.bb-header__icon:hover {
    opacity: 0.6;
    text-decoration: none !important;
    color: var(--bb-fg) !important;
}

.bb-header__icon:focus {
    outline: none;
    box-shadow: none !important;
}

/* Country Switcher (Global-e) */
.bb-header__country-switcher {
    position: relative;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
}

.bb-header__country-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* When Global-e injects a flag, hide the world icon */
.bb-header__country-switcher:has(.bb-header__country-flag:not(:empty)) .bb-icon {
    display: none !important;
}

/* Style for Global-e injected flag image */
.bb-header__country-flag img {
    width: 20px !important;
    height: 14px !important;
    object-fit: cover;
    border-radius: 2px;
}

/* Cart icon with badge */
.bb-header__cart {
    position: relative;
}

.bb-header__cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--bb-fg);
    color: var(--bb-bg);
    font-size: 9px;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    padding: 0 4px;
}

/* Menu toggle (hamburger) */
.bb-header__menu-toggle {
    display: inline-flex !important;
}

.bb-header__menu-toggle .bb-icon,
.bb-header__menu-toggle svg {
    width: 20px !important;
    height: 20px !important;
}

/* ===========================
   BREADCRUMB
   =========================== */
.bb-breadcrumb {
    max-width: var(--bb-max);
    margin: 0 auto;
    padding: 12px var(--bb-gutter);
    font-size: var(--bb-small);
    color: var(--bb-muted);
    letter-spacing: var(--bb-ls-tight);
}

.bb-breadcrumb a {
    color: var(--bb-muted);
    text-decoration: none;
    transition: color var(--bb-transition-fast);
}

.bb-breadcrumb a:hover {
    color: var(--bb-fg);
}

.bb-breadcrumb__separator {
    margin: 0 8px;
    opacity: 0.5;
}

/* ===========================
   SECONDARY NAVIGATION
   =========================== */
.bb-secondary-nav {
    display: none;
    border-bottom: 1px solid var(--bb-line);
    background: var(--bb-bg);
}

@media (max-width: 991px) {
    .bb-secondary-nav {
        display: block;
    }

    .bb-secondary-nav__inner {
        max-width: 100%;
        margin: 0 auto;
        padding: 0 var(--bb-gutter);
        display: flex;
        align-items: center;
        gap: 24px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .bb-secondary-nav__inner::-webkit-scrollbar {
        display: none;
    }

    .bb-secondary-nav a {
        font-size: 11px;
        letter-spacing: var(--bb-ls-wide);
        text-transform: uppercase;
        text-decoration: none;
        color: var(--bb-fg);
        white-space: nowrap;
        padding: 12px 0;
        border-bottom: 2px solid transparent;
        transition: border-color var(--bb-transition-fast);
    }

    .bb-secondary-nav a:hover,
    .bb-secondary-nav a.current {
        border-bottom-color: var(--bb-fg);
    }
}

/* ===========================
   SHOPTIMIZER OVERRIDES
   =========================== */
/* Hide the entire Shoptimizer navigation bar to avoid duplication */
.bb-navrow,
.col-full-nav {
    display: none !important;
}

/* Hide Shoptimizer's default cart/search/nav to use ours */
.main-header .secondary-navigation,
.main-header .header-cart,
.main-header .cart-contents,
.main-header .site-header-cart,
.main-header .shoptimizer-primary-navigation {
    display: none !important;
}

/* Override Shoptimizer main-header flex layout with our grid */
header#masthead .main-header,
.site-header .main-header {
    display: grid !important;
    flex-wrap: unset !important;
}

/* Ensure Shoptimizer elements don't break grid */
header#masthead .main-header .site-branding,
header#masthead .main-header .bb-header__left,
header#masthead .main-header .bb-header__right {
    position: relative;
    float: none !important;
}

/* Mobile responsive */
@media (max-width: 991px) {
    /* On mobile, use three-column layout (hamburger left, logo center, icons right) */
    header#masthead .main-header {
        grid-template-columns: auto 1fr auto !important;
    }

    /* Left section (hamburger only on mobile) stays in column 1 */
    .bb-header__left {
        grid-column: 1;
    }

    /* Logo goes to the center on mobile (column 2) */
    header#masthead .site-branding {
        justify-self: center;
        grid-column: 2;
    }

    /* Icons go to the right on mobile (column 3) */
    .bb-header__right {
        gap: 16px;
        justify-self: end;
        grid-column: 3;
    }

    .bb-header__icon .bb-icon,
    .bb-header__icon svg {
        width: 18px !important;
        height: 18px !important;
    }
}

/* Phone: logo left, search+cart+hamburger right */
@media (max-width: 767px) {
    header#masthead .main-header {
        display: flex !important;
        align-items: center;
        gap: 0;
    }

    /* Hide Shoptimizer menu overlay and menu-toggle button on mobile */
    header#masthead .menu-overlay,
    header#masthead .site-branding .menu-toggle {
        display: none !important;
    }

    /* Logo — left-aligned, takes available space */
    header#masthead .site-branding {
        flex: 1 1 0%;
        min-width: 0;
        justify-self: start;
        text-align: left;
        order: 1;
    }

    header#masthead .site-branding a {
        display: inline-block;
    }

    header#masthead .site-branding img {
        width: auto;
        height: 22px;
        max-height: 22px;
        object-fit: contain;
    }

    /* Icons — stay together, no grow */
    .bb-header__right {
        flex: 0 0 auto;
        order: 2;
        gap: 14px;
    }

    /* Hamburger moves to rightmost position */
    .bb-header__left {
        flex: 0 0 auto;
        order: 3;
        margin-left: 14px;
    }

    /* Hide desktop nav inside left section */
    .bb-header__left .bb-header__nav {
        display: none !important;
    }

    /* Hide country switcher and wishlist on mobile; account stays visible */
    .bb-header__country-switcher,
    .bb-header__wishlist {
        display: none !important;
    }
}

/* ===========================
   ELEMENTOR OVERRIDES
   =========================== */
/* Prevent Elementor from overriding our icon styles */
.bb-header__icon,
.bb-header__right .bb-header__icon,
.elementor-widget-container .bb-header__icon,
body .bb-header__icon {
    background-color: transparent !important;
    background-image: none !important;
}

.bb-header__icon svg,
.bb-header__icon .bb-icon,
.bb-header__right svg,
body .bb-header__icon svg {
    width: 20px !important;
    height: 20px !important;
    max-width: none !important;
    max-height: none !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.5 !important;
}

/* Ensure buttons don't get Elementor default styles */
button.bb-header__icon,
a.bb-header__icon {
    min-width: auto !important;
    min-height: auto !important;
    font-size: inherit !important;
    line-height: 1 !important;
    border-radius: 0 !important;
}
