:root {
    --brand-red-1: #ee1d4d;
    --brand-red-2: #ff4d6d;
    --brand-red-dark: #c8102e;
    --ink: #1c1c22;
    --ink-soft: #5b5b66;
    --line: #e9e9ee;
    --surface: #ffffff;
    --surface-muted: #f6f6f9;
    --shadow-sm: 0 1px 2px rgba(20, 20, 30, .04);
    --shadow-md: 0 8px 24px rgba(20, 20, 30, .08);
    --shadow-lg: 0 24px 60px rgba(20, 20, 30, .22);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --header-h: 64px;
    --subnav-h: 46px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }
body { font-family: 'Vazirmatn', Tahoma, sans-serif; background: #fafafc; color: var(--ink); direction: rtl; }
a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

#pageRoot { transition: filter .28s ease; }
#pageRoot.blurred { filter: blur(6px) brightness(.94); pointer-events: none; user-select: none; }

/* ===================== HEADER ===================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.header-top {
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    height: var(--header-h);
}

.brand {
    display: flex;
    align-items: center;
    margin-inline-start: 6px;
    flex-shrink: 0;
}

.brand svg { height: 30px; display: block; }

/* Search */
.search-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    height: 46px;
    overflow: visible;
    position: relative;
    transition: border-color .15s ease, box-shadow .15s ease;
    min-width: 0;
}

.search-wrap:focus-within {
    border-color: var(--brand-red-2);
    box-shadow: 0 0 0 3px rgba(238, 29, 77, .10);
    background: var(--surface);
}

.search-icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 100%; flex-shrink: 0;
    background: none; border: none; color: var(--ink-soft);
}

.search-input {
    flex: 1 1 auto; min-width: 0; border: none; background: transparent;
    outline: none; font-size: 14px; color: var(--ink); padding: 0 4px; height: 100%;
}
.search-input::placeholder { color: #a7a7b3; }

.category-trigger {
    flex-shrink: 0; display: flex; align-items: center; gap: 6px;
    height: 100%; padding: 0 16px 0 14px;
    background: linear-gradient(135deg, var(--brand-red-1), var(--brand-red-dark));
    color: #fff; border: none; border-radius: var(--radius-md) 0 0 var(--radius-md);
    font-size: 14px; font-weight: 600; white-space: nowrap;
    transition: filter .15s ease; margin-inline-start: -1px;
}
.category-trigger:hover { filter: brightness(1.05); }
.category-trigger .chev { width: 14px; height: 14px; transition: transform .2s ease; flex-shrink: 0; }
.category-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* Search results */
.search-results {
    position: absolute; top: calc(100% + 8px); inset-inline-start: 0; inset-inline-end: 0;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; z-index: 60;
    opacity: 0; transform: translateY(-6px); pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}
.search-results.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.search-results-header {
    padding: 10px 16px; font-size: 12px; color: var(--ink-soft);
    border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
}
.search-result-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    font-size: 13.5px; border-bottom: 1px solid var(--line); transition: background .12s ease;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-muted); }
.sri-icon {
    width: 30px; height: 30px; border-radius: 8px; background: var(--surface-muted);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--brand-red-1);
}
.sri-text mark { background: rgba(238, 29, 77, .16); color: var(--brand-red-dark); border-radius: 3px; padding: 0 1px; }
.sri-tag { margin-inline-start: auto; font-size: 11px; color: var(--ink-soft); background: var(--surface-muted); padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.search-empty { padding: 28px 16px; text-align: center; color: var(--ink-soft); font-size: 13px; }

/* Account */
.account-btn {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface-muted); border: 1px solid var(--line);
    border-radius: var(--radius-md); padding: 6px 8px 6px 12px;
    height: 46px; flex-shrink: 0; transition: background .15s ease, border-color .15s ease;
}
.account-btn:hover { background: #eee; }
.account-btn .chev-sm { width: 12px; height: 12px; color: var(--ink-soft); }
.account-label { font-size: 13px; color: var(--ink); white-space: nowrap; }
.account-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--surface);
    border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
    color: var(--ink-soft); flex-shrink: 0;
}

/* Cart */
.cart-btn {
    position: relative; display: flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: var(--radius-md);
    background: var(--surface-muted); border: 1px solid var(--line); color: var(--ink); flex-shrink: 0;
}
.cart-btn:hover { background: #eee; }
.cart-badge {
    position: absolute; top: -6px; inset-inline-end: -6px;
    background: var(--brand-red-1); color: #fff; font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--surface); padding: 0 3px;
}

/* Help */
.help-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
    background: transparent; border: 1px solid var(--line); color: var(--ink-soft); flex-shrink: 0;
}
.help-btn:hover { background: var(--surface-muted); }

/* ===================== SUBNAV ===================== */
.subnav { border-top: 1px solid var(--line); background: var(--surface-muted); }
.subnav-inner {
    max-width: 1320px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; height: var(--subnav-h); gap: 18px;
}
.subnav-links {
    display: flex; align-items: center; gap: 22px; font-size: 13.5px;
    color: var(--ink-soft); overflow-x: auto; scrollbar-width: none;
}
.subnav-links::-webkit-scrollbar { display: none; }
.subnav-link { display: flex; align-items: center; gap: 6px; white-space: nowrap; transition: color .15s ease; }
.subnav-link:hover { color: var(--ink); }
.subnav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.all-categories { position: relative; flex-shrink: 0; }
.all-categories-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: none; font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.all-categories-btn .grid-ico { width: 18px; height: 18px; }
.all-categories-btn .chev { width: 12px; height: 12px; transition: transform .2s ease; color: var(--ink-soft); }
.all-categories-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* ===================== CATEGORY MEGA DROPDOWN ===================== */
.category-panel {
    position: absolute; top: calc(100% + 10px); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 10px; z-index: 55;
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    max-height: 70vh; overflow-y: auto; width: 450px;
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: translateY(-8px) scale(.98); transition: .18s;
}
.category-panel.open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
.cat-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius-sm); transition: background .14s ease;
}
.cat-item:hover { background: var(--surface-muted); }
.cat-item .cat-ico {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, #fff0f2, #ffe4e8);
    display: flex; align-items: center; justify-content: center; color: var(--brand-red-1); flex-shrink: 0;
}
.cat-item-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cat-item-text strong { font-size: 13px; font-weight: 600; color: var(--ink); }
.cat-item-text span { font-size: 11px; color: var(--ink-soft); }
.category-panel.from-header { inset-inline-end: auto; inset-inline-start: 0; width: min(560px, 90vw); transform-origin: top right; }

/* ===================== OVERLAY + MODAL (login) ===================== */
.overlay {
    position: fixed; inset: 0; background: rgba(15, 15, 20, .45); z-index: 100;
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.auth-modal {
    background: var(--surface); width: min(420px, 100%); border-radius: var(--radius-lg);
    padding: 32px 30px 28px; box-shadow: var(--shadow-lg); position: relative;
    transform: translateY(16px) scale(.96); opacity: 0;
    transition: transform .28s cubic-bezier(.2, .8, .2, 1), opacity .22s ease;
}
.overlay.open .auth-modal { transform: translateY(0) scale(1); opacity: 1; }
.modal-close {
    position: absolute; top: 16px; inset-inline-start: 16px;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--surface-muted); border: 1px solid var(--line);
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-soft); transition: background .15s ease, color .15s ease, transform .15s ease;
}
.modal-close:hover { background: #fde8ec; color: var(--brand-red-dark); transform: rotate(90deg); }
.modal-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.modal-logo svg { height: 34px; }
.modal-title { text-align: center; font-size: 18px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.modal-sub { text-align: center; font-size: 13px; color: var(--ink-soft); margin: 0 0 20px; }
.phone-field {
    display: flex; align-items: center; border: 1px solid var(--line);
    border-radius: var(--radius-md); height: 50px; padding: 0 14px; margin-bottom: 18px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.phone-field:focus-within { border-color: var(--brand-red-2); box-shadow: 0 0 0 3px rgba(238, 29, 77, .10); }
.phone-field input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; text-align: center; direction: ltr; }
.phone-field input::placeholder { color: #b6b6c0; letter-spacing: 1px; }
.phone-field svg { width: 20px; height: 20px; color: #c7c7d1; flex-shrink: 0; }
.submit-btn {
    width: 100%; height: 50px; border: none; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--brand-red-2), var(--brand-red-1));
    color: #fff; font-size: 15px; font-weight: 700;
    box-shadow: 0 10px 24px rgba(238, 29, 77, .30); transition: filter .15s ease, transform .1s ease;
}
.submit-btn:hover { filter: brightness(1.04); }
.submit-btn:active { transform: scale(.98); }
.modal-terms { margin-top: 16px; text-align: center; font-size: 11.5px; line-height: 1.9; color: var(--ink-soft); }
.modal-terms a { color: var(--brand-red-1); font-weight: 600; }
.modal-terms a:hover { text-decoration: underline; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 980px) { .subnav-links .ml-text { display: none; } }
@media (max-width: 860px) {
    .account-label { display: none; }
    .account-btn { padding: 6px; }
}
@media (max-width: 720px) {
    .header-top { flex-wrap: wrap; height: auto; row-gap: 10px; padding: 10px 14px 12px; }
    .brand { order: 1; margin-inline-start: 0; }
    .help-btn { order: 2; }
    .account-btn { order: 3; }
    .cart-btn { order: 4; }
    .search-wrap { order: 5; flex-basis: 100%; width: 100%; }
    .category-trigger span.label-text { display: none; }
    .category-trigger { padding: 0 12px; }
    .subnav-inner { flex-wrap: wrap; height: auto; padding: 8px 14px; row-gap: 8px; }
    .subnav-links { order: 2; width: 100%; }
    .all-categories { order: 1; }
    .category-panel.from-header { inset-inline-start: 0; inset-inline-end: auto; width: 94vw; }
}
@media (max-width: 480px) {
    .category-panel { grid-template-columns: 1fr; }
    .auth-modal { padding: 26px 20px 22px; }
    .account-avatar { width: 28px; height: 28px; }
    .cart-btn, .account-btn { height: 42px; }
    .search-wrap { height: 42px; }
    .help-btn { width: 34px; height: 34px; }
}
@media (max-width: 720px) {
    .category-panel {
        width: calc(100vw - 20px); max-width: calc(100vw - 20px);
        right: 10px; left: 10px; box-sizing: border-box;
    }
}

button:focus-visible, input:focus-visible, a:focus-visible {
    outline: 2px solid var(--brand-red-1); outline-offset: 2px;
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
