/* site header: top bar (logo / search / cart + account) and menu row */

header.main-header.site-header {
    --sh-text: #1f2328;
    --sh-muted: #6b7280;
    --sh-line: #e8eaee;
    --sh-subtle: #f5f6f8;
    --sh-brand: var(--primary-color);
    --sh-brand-soft: color-mix(in srgb, var(--primary-color) 10%, #fff);
    --sh-shadow: 0 12px 32px rgba(17, 24, 39, 0.1);
    --sh-ease: cubic-bezier(0.2, 0, 0, 1);

    position: relative;
    z-index: 1000;
    background: #fff;
    border-bottom: 1px solid var(--sh-line);
}

/* ---------- top bar ---------- */

.site-header__bar {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 76px;
    padding: 12px 0;
}

.site-header__brand {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
}

.site-header__logo {
    display: flex;
    align-items: center;
    height: 44px;
}

.site-header__logo img {
    max-width: 140px;
    max-height: 44px;
    object-fit: contain;
}

/* hamburger (markup in partials/mobile-menu/menu) */
header.main-header.site-header .site-header__brand button.btn-menu {
    flex: 0 0 auto;
    width: 40px;
    max-width: none;
    height: 40px;
    padding: 0;
    border-radius: 10px;
    align-items: center;
    transition: background-color 0.16s var(--sh-ease);
}

header.main-header.site-header .site-header__brand button.btn-menu:hover {
    background-color: var(--sh-subtle);
}

header.main-header.site-header .site-header__brand button.btn-menu .align {
    margin: 0;
}

header.main-header.site-header .site-header__brand button.btn-menu .align span {
    width: 20px;
    margin-bottom: 5px;
    border-radius: 2px;
    background: var(--sh-text);
}

header.main-header.site-header .site-header__brand button.btn-menu .align span:last-child {
    margin-bottom: 0;
}

/* ---------- search ---------- */

header.main-header.site-header .site-header__search {
    flex: 1 1 auto;
    max-width: 640px;
    margin: 0 auto;
}

header.main-header.site-header .search-area form.search {
    position: relative;
    margin: 0;
}

header.main-header.site-header .search-area form.search input {
    width: 100%;
    height: 44px;
    padding: 0 16px 0 88px;
    border: 1px solid var(--sh-line);
    border-radius: 10px;
    background: var(--sh-subtle);
    color: var(--sh-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 400;
    line-height: 44px;
    transition: border-color 0.16s var(--sh-ease), background-color 0.16s var(--sh-ease),
        box-shadow 0.16s var(--sh-ease);
}

header.main-header.site-header .search-area form.search input::placeholder {
    color: #9ca3af;
    font-size: 13px;
}

header.main-header.site-header .search-area form.search input:hover {
    border-color: #d5d8de;
}

header.main-header.site-header .search-area form.search input:focus {
    border-color: var(--sh-brand);
    background: #fff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--sh-brand) 18%, transparent);
}

header.main-header.site-header .search-area form.search button.site-search__submit {
    position: absolute;
    top: 4px;
    right: auto;
    bottom: auto;
    left: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    background: transparent !important;
    color: var(--sh-text);
    font-size: 22px;
    transition: background-color 0.16s var(--sh-ease), color 0.16s var(--sh-ease);
}

header.main-header.site-header .search-area form.search button.site-search__submit:hover {
    background: #fff !important;
    color: var(--sh-brand);
}

header.main-header.site-header .search-area form.search .close-search-result {
    position: absolute;
    top: 50%;
    right: auto;
    left: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    background: #e5e7eb !important;
    color: var(--sh-muted);
    font-size: 15px;
    transform: translateY(-50%);
}

header.main-header.site-header .search-area form.search .close-search-result.show {
    display: flex;
}

header.main-header.site-header .search-area form.search .close-search-result:hover {
    background: #d1d5db !important;
    color: var(--sh-text);
}

/* results panel (filled by assets/js/scripts.js) */
header.main-header.site-header .search-area form.search .search-result {
    top: calc(100% + 8px);
    right: 0;
    left: 0;
    display: block;
    max-height: min(440px, 70vh);
    padding: 6px;
    overflow-y: auto;
    border: 1px solid var(--sh-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--sh-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.18s var(--sh-ease), transform 0.18s var(--sh-ease), visibility 0.18s;
}

header.main-header.site-header .search-area form.search .search-result.open {
    opacity: 1;
    visibility: visible;
    transform: none;
}

header.main-header.site-header .search-area form.search .search-result ul {
    margin: 0;
    padding: 0;
}

header.main-header.site-header .search-area form.search .search-result ul li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px !important;
    border-radius: 10px;
    line-height: 1.6;
    transition: background-color 0.14s var(--sh-ease);
}

header.main-header.site-header .search-area form.search .search-result ul li + li {
    margin-top: 2px;
}

header.main-header.site-header .search-area form.search .search-result ul li:hover {
    background: var(--sh-subtle);
}

header.main-header.site-header .search-area form.search .search-result ul li img {
    display: block;
    width: 48px;
    height: 48px;
    border: 1px solid var(--sh-line);
    border-radius: 10px;
    background: #fff;
    object-fit: contain;
}

header.main-header.site-header .search-result .search-result-text {
    min-width: 0;
    flex: 1 1 auto;
}

header.main-header.site-header .search-result .search-result-text .search-result-body {
    display: flex;
    width: auto;
    flex-direction: column;
    gap: 2px;
}

header.main-header.site-header .search-result .search-result-text .search-result-body a {
    margin: 0 !important;
    padding: 0;
    overflow: hidden;
    color: var(--sh-text);
    font-size: 14px;
    font-weight: 500;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* whole row is clickable */
header.main-header.site-header .search-result .search-result-text .search-result-body a::after {
    content: '';
    position: absolute;
    inset: 0;
}

header.main-header.site-header .search-result .search-result-text .search-result-body span {
    margin: 0 !important;
    color: var(--sh-muted) !important;
    font-size: 12px;
}

header.main-header.site-header .search-result .box-search-price {
    display: flex;
    flex-shrink: 0;
    align-items: center;
}

header.main-header.site-header .search-result .box-search-price span {
    margin: 0 !important;
    color: var(--sh-text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

header.main-header.site-header .search-result .box-search-price a {
    display: none !important;
}

/* ---------- actions (cart + account) ---------- */

.site-header__actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 4px;
    margin-right: auto;
}

.site-header__divider {
    width: 1px;
    height: 24px;
    margin: 0 4px;
    background: var(--sh-line);
}

.site-dropdown {
    position: relative;
}

header.main-header.site-header .site-action {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--sh-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.16s var(--sh-ease), color 0.16s var(--sh-ease);
}

header.main-header.site-header .site-action:hover,
.site-dropdown.is-open > .site-action {
    background: var(--sh-subtle);
    color: var(--sh-text);
}

header.main-header.site-header .site-action:focus-visible {
    outline: 2px solid var(--sh-brand);
    outline-offset: 2px;
}

.site-action__icon-wrap {
    position: relative;
    display: flex;
}

.site-action__icon {
    font-size: 24px;
    line-height: 1;
}

.site-action__label {
    max-width: 120px;
    /* room for Persian descenders; overflow is hidden for the ellipsis */
    padding: 2px 0;
    line-height: 1.7;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-action__chevron {
    color: var(--sh-muted);
    font-size: 18px;
    line-height: 1;
    transition: transform 0.18s var(--sh-ease);
}

.site-dropdown.is-open .site-action__chevron {
    transform: rotate(180deg);
}

.site-action__badge {
    position: absolute;
    top: -7px;
    left: -9px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: var(--sh-brand);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

/* dropdown panel */
.site-dropdown__menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1001;
    min-width: 240px;
    padding: 6px;
    border: 1px solid var(--sh-line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--sh-shadow);
    text-align: right;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.18s var(--sh-ease), transform 0.18s var(--sh-ease), visibility 0.18s;
}

/* invisible bridge so the menu stays open while the pointer crosses the gap */
.site-dropdown__menu::before {
    content: '';
    position: absolute;
    right: 0;
    bottom: 100%;
    left: 0;
    height: 10px;
}

.site-dropdown.is-open > .site-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: none;
}

@media (hover: hover) and (min-width: 992px) {
    .site-dropdown:hover > .site-dropdown__menu {
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .site-dropdown:hover .site-action__chevron {
        transform: rotate(180deg);
    }
}

header.main-header.site-header .site-dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--sh-text);
    font-size: 14px;
    transition: background-color 0.14s var(--sh-ease), color 0.14s var(--sh-ease);
}

header.main-header.site-header .site-dropdown__item i {
    color: var(--sh-muted);
    font-size: 20px;
    line-height: 1;
    transition: color 0.14s var(--sh-ease);
}

header.main-header.site-header .site-dropdown__item:hover,
header.main-header.site-header .site-dropdown__item:focus-visible {
    background: var(--sh-subtle);
    color: var(--sh-text);
    outline: none;
}

header.main-header.site-header .site-dropdown__item:hover i {
    color: var(--sh-brand);
}

header.main-header.site-header .site-dropdown__item--danger,
header.main-header.site-header .site-dropdown__item--danger i,
header.main-header.site-header .site-dropdown__item--danger:hover,
header.main-header.site-header .site-dropdown__item--danger:hover i {
    color: #dc2626;
}

header.main-header.site-header .site-dropdown__item--danger:hover {
    background: #fef2f2;
}

.site-dropdown__divider {
    height: 1px;
    margin: 6px 4px;
    background: var(--sh-line);
}

/* account */
.site-account__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--sh-line);
}

.site-account__avatar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--sh-brand-soft);
    color: var(--sh-brand);
    font-size: 22px;
}

.site-account__who {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.6;
}

.site-account__who strong {
    overflow: hidden;
    color: var(--sh-text);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-account__who span {
    color: var(--sh-muted);
    font-size: 12px;
    text-align: right;
}

/* cart */
.site-cart__menu {
    width: 360px;
    padding: 0;
}

.site-cart__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sh-line);
}

.site-cart__head strong {
    color: var(--sh-text);
    font-size: 15px;
    font-weight: 600;
}

.site-cart__head span {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--sh-subtle);
    color: var(--sh-muted);
    font-size: 12px;
}

.site-cart__list {
    max-height: 300px;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    list-style: none;
}

header.main-header.site-header .site-cart__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--sh-text);
    transition: background-color 0.14s var(--sh-ease);
}

header.main-header.site-header .site-cart__item:hover {
    background: var(--sh-subtle);
}

.site-cart__thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    overflow: hidden;
    border: 1px solid var(--sh-line);
    border-radius: 10px;
    background: #fff;
}

.site-cart__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.site-cart__info {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
}

.site-cart__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.7;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.site-cart__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.site-cart__qty {
    color: var(--sh-muted);
}

.site-cart__price {
    color: var(--sh-text);
    font-weight: 600;
    white-space: nowrap;
}

.site-cart__price del {
    margin-left: 4px;
    color: #9ca3af;
    font-weight: 400;
}

.site-cart__price small,
.site-cart__sum small {
    color: var(--sh-muted);
    font-size: 11px;
    font-weight: 400;
}

.site-cart__foot {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px 16px;
    border-top: 1px solid var(--sh-line);
}

.site-cart__sum {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--sh-muted);
    font-size: 13px;
}

.site-cart__sum strong {
    color: var(--sh-text);
    font-size: 16px;
    font-weight: 600;
}

header.main-header.site-header .site-cart__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border-radius: 10px;
    background: var(--sh-brand);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    transition: filter 0.16s var(--sh-ease);
}

header.main-header.site-header .site-cart__btn:hover {
    color: #fff;
    filter: brightness(0.94);
}

.site-cart__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 20px;
    text-align: center;
}

.site-cart__empty i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--sh-subtle);
    color: #9ca3af;
    font-size: 28px;
}

.site-cart__empty strong {
    color: var(--sh-text);
    font-size: 14px;
    font-weight: 600;
}

.site-cart__empty span {
    color: var(--sh-muted);
    font-size: 12px;
}

/* ---------- menu row ---------- */

header.main-header.site-header .bottom-header {
    margin: 0;
    border-top: 1px solid var(--sh-line);
}

header.main-header.site-header .main-menu {
    float: none;
}

header.main-header.site-header .main-menu > .list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    width: 100%;
}

/* ---------- tablet & phone ---------- */

@media (max-width: 991.98px) {
    .site-header__bar {
        min-height: 64px;
        gap: 12px;
        padding: 10px 0;
    }

    header.main-header.site-header .site-header__search,
    header.main-header.site-header .bottom-header,
    .site-action__label,
    .site-action__chevron {
        display: none;
    }

    header.main-header.site-header .site-action {
        width: 44px;
        justify-content: center;
        padding: 0;
    }

    .site-header__logo img {
        max-width: 120px;
        max-height: 40px;
    }

    /* anchor menus to the bar so they never run off the screen edge */
    .site-header__bar {
        position: relative;
    }

    .site-dropdown {
        position: static;
    }

    .site-dropdown__menu {
        top: calc(100% - 4px);
        left: 0;
    }

    .site-cart__menu {
        width: min(360px, 100%);
    }
}

@media (max-width: 575.98px) {
    .site-header__bar {
        min-height: 60px;
        gap: 8px;
    }

    .site-header__brand {
        gap: 4px;
    }

    .site-header__actions {
        gap: 0;
    }

    .site-header__logo img {
        max-width: 104px;
        max-height: 36px;
    }

    .site-account__menu {
        min-width: min(260px, 100%);
    }

    .site-cart__menu {
        width: 100%;
    }
}

/* quiet scrollbars inside header panels */
header.main-header.site-header .search-area form.search .search-result,
.site-cart__list {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}
