/* Top bar */
.top-bar {
    background: linear-gradient(90deg, #084a35 0%, #0d6e4f 55%, #0a5c42 100%);
    color: #ecfdf5;
    font-size: 0.8rem;
}

.top-bar__inner {
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-bar__messages {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
}

.top-bar__message {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.top-bar__message svg {
    flex-shrink: 0;
    opacity: 0.9;
}

/* Header shell */
.site-header {
    position: sticky;
    top: 0;
    z-index: 300;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    overflow: visible;
}

.header-main {
    border-bottom: 1px solid var(--color-border);
}

.header-main__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 1rem;
    min-height: 78px;
    padding: 0.85rem 0;
}

.header-main__brand .custom-logo,
.header-main__brand .site-title {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--color-text);
    text-decoration: none;
}

.header-main__search {
    min-width: 0;
    overflow: visible;
}

.header-main__cta {
    display: flex;
}

.header-builder-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(234, 88, 12, 0.25);
    white-space: nowrap;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.header-builder-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(234, 88, 12, 0.32);
    color: #fff;
}

.header-main__actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    overflow: visible;
}

.header-actions-group {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.85rem 0.5rem 0.6rem;
    background: linear-gradient(180deg, #fafcfb 0%, #f4f7f6 100%);
    border: 1px solid #e4ece8;
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
    overflow: visible;
}

.header-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    padding: 0.45rem 0.95rem 0.45rem 0.5rem;
    border-radius: 999px;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.header-action:hover {
    background: #fff;
    color: var(--color-primary);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    transform: translateY(-1px);
}

.header-action--icon-only {
    width: 46px;
    min-width: 46px;
    height: 46px;
    padding: 0;
    justify-content: center;
}

.header-action--account.is-logged-in {
    padding-right: 1.15rem;
}

.header-action__icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e8eeeb;
    color: var(--color-text);
    flex-shrink: 0;
}

.header-action:hover .header-action__icon-wrap {
    border-color: #cfe7dc;
    color: var(--color-primary);
}

.header-action__copy {
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
    min-width: 0;
    padding-right: 0.35rem;
}

.header-action__label {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--color-text);
}

.header-action__value {
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.1;
    color: var(--color-muted);
    white-space: nowrap;
}

.header-action__badge {
    position: absolute;
    top: -3px;
    right: -3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.64rem;
    font-weight: 800;
    line-height: 1;
}

.header-action--cart {
    margin-right: 3px;
}

.header-action--favorites .header-action__badge {
    background: #e11d48;
}

.header-action--favorites .header-action__badge:empty,
.header-action--favorites .header-action__badge[data-count="0"] {
    opacity: 0;
}

.header-action--cart .header-action__icon-wrap {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: var(--color-primary);
}

.header-action--cart .header-action__badge {
    background: var(--color-primary);
}

.header-action--account.is-logged-in .header-action__icon-wrap {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.header-action--favorites.is-active .header-action__icon-wrap,
.header-action--favorites:hover .header-action__icon-wrap {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #e11d48;
}

/* Live search */
.header-search {
    position: relative;
    width: 100%;
    z-index: 20;
}

.header-search.is-open {
    z-index: 120;
}

.header-search__form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 52px;
    padding: 0 0.45rem 0 1rem;
    border: 2px solid #d4ebe3;
    border-radius: 14px;
    background: #f8fcfa;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.header-search__form:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(13, 110, 79, 0.1);
    background: #fff;
}

.header-search__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--color-primary);
    line-height: 0;
}

.header-search__icon svg {
    display: block;
}

.header-search__input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 0.98rem;
    line-height: 1.4;
    color: var(--color-text);
    outline: none;
}

.header-search__input::placeholder {
    color: #94a3b8;
}

.header-search__submit {
    flex-shrink: 0;
    align-self: center;
    border: 0;
    border-radius: 10px;
    padding: 0.55rem 0.95rem;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
}

.header-search__results {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.header-search__results-inner {
    max-height: 420px;
    overflow: auto;
}

.header-search__item {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 0.85rem;
    align-items: center;
    padding: 0.8rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px solid #f1f5f9;
}

.header-search__item:hover {
    background: #f8fcfa;
}

.header-search__thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    background: #f1f5f9;
}

.header-search__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-search__meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.header-search__name {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.35;
}

.header-search__price {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--color-primary);
}

.header-search__empty,
.header-search__loading {
    margin: 0;
    padding: 1rem;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.header-search__view-all {
    display: block;
    padding: 0.85rem 1rem;
    background: #f8faf9;
    color: var(--color-primary);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
}

/* Nav row */
.header-nav {
    background: #fff;
}

.header-nav__inner {
    min-height: 52px;
    display: flex;
    align-items: center;
}

.header-nav .primary-nav__list {
    flex-wrap: wrap;
}

/* Brands mega */
.mega-menu__panel--brands .mega-menu__panel-card {
    max-height: 70vh;
    overflow: auto;
}

/* Responsive */
@media (max-width: 1100px) {
    .header-main__inner {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .header-main__cta {
        display: none;
    }

    .header-actions-group {
        gap: 0.4rem;
        padding: 0.4rem 0.65rem;
    }

    .header-action__copy {
        display: none;
    }

    .header-action {
        padding: 0;
    }

    .header-action--cart {
        padding-right: 0;
    }
}

@media (max-width: 900px) {
    .top-bar__messages {
        gap: 0.65rem;
        font-size: 0.74rem;
    }

    .header-main__inner {
        grid-template-columns: auto 1fr auto;
    }

    .header-main__search {
        grid-column: 1 / -1;
        order: 4;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .header-nav__inner {
        display: block;
        padding: 0;
    }

    #primary-nav {
        display: none;
        padding: 0.75rem 0 1rem;
    }

    #primary-nav.is-open {
        display: block;
    }

    #primary-nav .primary-nav__list {
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        padding: 0 1rem;
    }

    .mega-menu__panel {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        pointer-events: auto;
        padding: 0.35rem 0 0.5rem;
    }

    .mega-menu__panel[hidden] {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .top-bar__messages {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .top-bar__messages::-webkit-scrollbar {
        display: none;
    }

    .header-search__submit {
        padding: 0.55rem 0.75rem;
    }
}
