/* ═══════════════════════════════════════════════════════
   Sama Header
   ═══════════════════════════════════════════════════════ */

.sama-header {
    margin-top: 0 !important;
}

.sama-header__bar {
    position: relative;
    z-index: 1040;
    padding: 0 !important;
    min-height: unset !important;
    background: #fff;
    border-bottom: none;
    box-shadow: none;
}

/* جستجو + لوگو + اکانت — ثابت می‌مانند */
.sama-header__sticky {
    position: sticky;
    top: 0;
    z-index: 1050;
    background: #fff;
    border-bottom: 1px solid #e8e8ee;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
    padding-top: 8px;
    padding-bottom: 8px;
}

.sama-header .sama-header__container {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding-top: 0;
    padding-bottom: 0;
    gap: 0;
}

/* ── Row 1 ── */
.sama-header__row--main {
    display: flex;
    align-items: center;
    width: 100%;
}

/* Logo + search grouped on the right (RTL start) */
.sama-header__cluster {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sama-header__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.sama-header__brand .logo {
    min-width: 0 !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0;
    line-height: 0;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
}

.sama-header__brand .sama-header__logo img {
    display: block;
    height: 88px;
    width: auto;
    max-width: 190px;
    object-fit: contain;
}

.sama-header__brand .sama-header__logo-mobile img {
    display: block;
    height: 44px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
}

.sama-header__brand .mobile-menu-toggle {
    display: none;
    font-size: 22px;
    color: #424750;
    line-height: 1;
    padding: 4px;
}

/* Actions pushed to far left (RTL end) */
.sama-header__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-right: auto;
    margin-left: 0 !important;
}

/* ── Search bar ── */
.sama-search {
    position: relative;
    display: flex;
    align-items: center;
    background: #f0f0f1;
    border-radius: 8px;
    border: 1px solid transparent;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.sama-live-search.is-open .sama-search {
    background: #fff;
    border-color: #c0c2c5;
    box-shadow: 0 0 0 3px rgba(239, 57, 78, 0.08);
}

.sama-search__icon {
    flex-shrink: 0;
    padding: 0 12px;
    font-size: 18px;
    color: #81858b;
    line-height: 1;
}

.sama-search__input {
    flex: 1;
    min-width: 0;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 10px 12px 10px 0;
    font-size: 13px;
    font-family: inherit;
    color: #3f4064;
}

.sama-search__input::placeholder {
    color: #a1a3a8;
}

/* Fixed width — same on all pages, sits next to logo */
.sama-header .sama-search--desktop {
    width: 400px !important;
    max-width: 400px !important;
    min-width: 400px !important;
    flex: 0 0 400px !important;
}

.sama-search--mobile {
    width: 100%;
    margin-top: 8px;
}

.sama-search--mobile .sama-search__input {
    padding-top: 9px;
    padding-bottom: 9px;
}

/* ── Live search dropdown ── */
.sama-live-search {
    position: relative;
}

.sama-live-search__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    z-index: 1100;
    background: #fff;
    border: 1px solid #e8e8ee;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(26, 28, 35, 0.14);
    overflow: hidden;
    max-height: 420px;
    overflow-y: auto;
}

.sama-live-search__dropdown[hidden] {
    display: none !important;
}

.sama-live-search__loading,
.sama-live-search__empty {
    padding: 20px 16px;
    text-align: center;
    color: #81858b;
    font-size: 13px;
}

.sama-live-search__loading::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 8px;
    border: 2px solid #e8e8ee;
    border-top-color: #ef394e;
    border-radius: 50%;
    animation: sama-spin 0.7s linear infinite;
    vertical-align: middle;
}

@keyframes sama-spin {
    to { transform: rotate(360deg); }
}

.sama-live-search__section {
    padding: 8px 0;
}

.sama-live-search__section + .sama-live-search__section {
    border-top: 1px solid #f0f0f1;
}

.sama-live-search__section-title {
    padding: 6px 16px 8px;
    margin: 0;
    font-size: 11px;
    font-weight: 800;
    color: #81858b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sama-live-search__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #3f4064 !important;
    text-decoration: none !important;
    transition: background 0.12s;
}

.sama-live-search__item:hover {
    background: #f8f8f9;
    color: #3f4064 !important;
}

.sama-live-search__thumb {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: #f0f0f1;
    border: 1px solid #eee;
}

.sama-live-search__thumb--brand {
    object-fit: contain;
    padding: 4px;
}

.sama-live-search__thumb--empty {
    display: inline-block;
    background: linear-gradient(135deg, #f5f5f6, #ececef);
}

.sama-live-search__info {
    flex: 1;
    min-width: 0;
}

.sama-live-search__name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #3f4064;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sama-live-search__meta {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #81858b;
}

.sama-live-search__unavailable {
    color: #9b1c1c;
    font-weight: 700;
}

.sama-live-search__footer {
    display: block;
    padding: 12px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #ef394e !important;
    background: #fff7f8;
    border-top: 1px solid #f0f0f1;
    text-decoration: none !important;
    transition: background 0.12s;
}

.sama-live-search__footer:hover {
    background: #ffeff1;
    color: #c6283d !important;
}

/* ── Actions ── */
.sama-header__action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 8px;
    color: #424750 !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s;
    position: relative;
    line-height: 1;
}

.sama-header__action:hover {
    background: #f0f0f1;
    color: #424750 !important;
}

.sama-header__action .w-icon-account,
.sama-header__action .w-icon-cart {
    font-size: 24px;
    line-height: 1;
}

.sama-header__action-label {
    font-size: 12px;
    font-weight: 600;
}

.sama-header__cart .cart-count {
    background: #ef394e;
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    border-radius: 50%;
    text-align: center;
    position: absolute;
    top: 2px;
    right: 2px;
}

.sama-header__cart .w-icon-cart {
    position: relative;
    display: inline-block;
}

.sama-header .logo {
    min-width: 0 !important;
    margin: 0 !important;
}

/* ── Nav row — با اسکرول بالا می‌رود ── */
.sama-header__nav {
    width: 100%;
    border-top: 1px solid #f0f0f1;
    margin-top: 0;
    padding: 2px 0 4px;
    background: transparent;
}

.sama-header__menu {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    min-height: 0;
}

.sama-header__menu > li {
    position: relative;
}

.sama-header__menu > li > a {
    display: block;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    color: #424750 !important;
    text-decoration: none !important;
    white-space: nowrap;
}

.sama-header__menu > li.active > a {
    color: #333 !important;
}

.sama-header__menu .megamenu {
    top: 100%;
}

/* ── Tablet ── */
@media (max-width: 1199px) {
    .sama-header .sama-search--desktop {
        width: 320px !important;
        max-width: 320px !important;
        min-width: 320px !important;
        flex: 0 0 320px !important;
    }
}

/* ── Mobile ── */
@media (max-width: 991px) {
    .sama-header__brand .mobile-menu-toggle {
        display: block;
    }

    .sama-header__cluster {
        gap: 6px;
    }

    .sama-header__brand .sama-header__logo-mobile img {
        height: 48px;
        max-width: 155px;
    }

    .sama-header__actions {
        margin-right: auto;
        margin-left: 0 !important;
    }

    .sama-header__action {
        padding: 5px 6px;
    }

    .sama-header__action .w-icon-account,
    .sama-header__action .w-icon-cart {
        font-size: 22px;
    }

    .sama-header__nav {
        display: none !important;
    }

    .sama-header__sticky {
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .sama-live-search--mobile .sama-live-search__dropdown {
        position: static;
        margin-top: 6px;
        max-height: 320px;
    }
}

@media (max-width: 479px) {
    .sama-header__brand .sama-header__logo-mobile img {
        height: 44px;
        max-width: 145px;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .sama-header__brand .sama-header__logo img {
        height: 80px;
        max-width: 170px;
    }
}
