/* Above-the-fold shell for catalog style 4. Full v2.css is applied asynchronously. */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.1);
    --color-primary: var(--primary);
    --color-primary-hover: var(--primary-hover);
    --color-primary-light: var(--primary-light);
    --color-primary-ultra-light: rgba(37, 99, 235, 0.08);
    --green: #22c55e;
    --green-hover: #16a34a;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --surface: #fff;
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.06);
    --font-ar: 'Vazirmatn', sans-serif;
    --font-en: 'Inter', sans-serif;
}

[data-theme="dark"] {
    --primary: #38bdf8;
    --primary-hover: #7dd3fc;
    --primary-light: rgba(56, 189, 248, 0.12);
    --color-primary: var(--primary);
    --color-primary-hover: var(--primary-hover);
    --color-primary-light: var(--primary-light);
    --color-primary-ultra-light: rgba(56, 189, 248, 0.12);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.15);
    --bg: #0f172a;
    --surface: #1e293b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px -4px rgba(0, 0, 0, 0.4), 0 2px 8px -2px rgba(0, 0, 0, 0.25);
}

[hidden] { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light; scroll-behavior: smooth; overflow-x: hidden; }
[data-theme="dark"] { color-scheme: dark; }
body {
    min-height: 100vh;
    overflow-x: hidden;
    font-family: var(--font-ar);
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}
[dir="ltr"] body { font-family: var(--font-en); }
[data-theme="dark"] body { background: linear-gradient(180deg, #0f172a 0%, #0c1222 100%); }
button, input, select, textarea { font-family: inherit; }
.container { width: 90%; max-width: 1320px; margin-inline: auto; }

header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: 0;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.header-top { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.header-top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; color: var(--primary); text-decoration: none; line-height: 0; }
.logo img { display: block; width: auto; height: 34px; }
.search-form { flex: 1; min-width: 200px; max-width: 420px; }
.search-wrap { display: flex; overflow: hidden; border: 1px solid var(--border); border-radius: 9999px; background: var(--bg); }
.search-input { flex: 1; min-width: 0; padding: 0.5rem 1rem; border: 0; outline: 0; color: inherit; background: transparent; font-size: 0.9rem; }
.search-btn { display: flex; align-items: center; gap: 0.25rem; padding: 0.5rem 1rem; border: 0; color: #fff; background: var(--primary); cursor: pointer; }
.header-actions, .auth-links { display: flex; align-items: center; gap: 0.5rem; }
.nav-search-btn { display: none; padding: 0.5rem; border: 0; color: var(--text); background: transparent; cursor: pointer; }
.country-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: inherit;
    background: var(--surface);
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
}
.country-btn img.country-btn-flag { width: 1.25rem; height: 1rem; border-radius: 2px; object-fit: cover; }
.country-btn svg { width: 0.9rem; height: 0.9rem; flex-shrink: 0; color: var(--text-muted); }
.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    color: var(--primary);
    background: transparent;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    color: var(--text-muted);
    background: var(--bg);
    cursor: pointer;
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; color: #fbbf24; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.header-social-link { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); background: var(--surface); text-decoration: none; }
.nav-mobile-btn { display: none; padding: 0.5rem; border: 0; color: var(--text); background: transparent; cursor: pointer; }
.nav-bar { padding: 0.5rem 0; }
.nav-bar ul { display: flex; align-items: center; flex-wrap: wrap; gap: 1.25rem; list-style: none; }
.nav-bar a { color: var(--text); font-size: 0.95rem; font-weight: 500; text-decoration: none; }
.nav-dropdown-wrap { position: relative; }
.nav-dropdown-btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.75rem; border: 0; border-radius: var(--radius-sm); color: var(--text); background: transparent; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.nav-dropdown { position: absolute; top: calc(100% + 0.5rem); inset-inline-start: 0; z-index: 50; width: max-content; min-width: 200px; max-width: 280px; max-height: 320px; overflow-y: auto; padding: 0.75rem 0; border: 1px solid var(--border); border-radius: var(--radius-md); opacity: 0; visibility: hidden; background: var(--surface); list-style: none; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15); }
.nav-dropdown-wrap[aria-expanded="true"] .nav-dropdown { opacity: 1; visibility: visible; }
.nav-dropdown a { display: block; width: 100%; padding: 0.7rem 1.25rem; color: var(--text); text-decoration: none; }
.auth-dropdown-btn { border: 1px solid var(--border); border-radius: 0.75rem; background: var(--surface); }
.mobile-drawer, .mobile-drawer-backdrop { display: none; }

/* Keep overlays out of the initial flow; these rules also cover very early clicks. */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}
.auth-overlay.open, .auth-overlay[aria-hidden="false"] { display: flex; opacity: 1; visibility: visible; pointer-events: auto; }
.auth-overlay[aria-hidden="true"] { display: none; opacity: 0; visibility: hidden; pointer-events: none; }
.auth-modal { width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; border-radius: var(--radius); background: var(--surface); box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.auth-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.auth-header h2 { font-size: 1.25rem; font-weight: 600; }
.auth-close { display: flex; align-items: center; justify-content: center; padding: 0.5rem; border: 0; color: var(--text-muted); background: none; cursor: pointer; }
.auth-body { padding: 1.5rem; }
.auth-form label { display: block; margin-bottom: 0.35rem; font-size: 0.875rem; font-weight: 500; }
.auth-form input[type="text"], .auth-form input[type="email"], .auth-form input[type="password"] { width: 100%; margin-bottom: 1rem; padding: 0.6rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); color: inherit; background: var(--bg); font-size: 0.95rem; }
.auth-form-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.auth-submit { width: 100%; padding: 0.75rem 1rem; border: 0; border-radius: var(--radius-sm); color: #fff; background: var(--primary); font-size: 1rem; font-weight: 600; cursor: pointer; }
.auth-switch { margin-top: 1rem; color: var(--text-muted); font-size: 0.9rem; text-align: center; }
.auth-link-btn, .auth-forgot-link { padding: 0; border: 0; color: var(--primary); background: none; cursor: pointer; }
.country-lang-modal { max-width: 440px; }
.country-lang-current, .country-language-grid { display: flex; flex-direction: column; gap: 1rem; }
.country-lang-current-head { display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--primary-light); }
.country-lang-btns, .country-language-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.country-lang-btn, .country-language-option { padding: 0.5rem 0.8rem; border: 1px solid var(--border); border-radius: 999px; color: var(--text); text-decoration: none; }
.country-lang-btn.active, .country-language-option.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.country-lang-other-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.country-lang-other-item { display: flex; align-items: center; gap: 0.45rem; padding: 0.55rem; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }

@media (max-width: 768px) {
    .container { width: 94%; }
    header { padding-top: env(safe-area-inset-top, 0); }
    .header-top { padding-block: 0.75rem; }
    .header-top-inner { flex-wrap: nowrap; }
    .nav-bar, .header-social-link-desktop, .header-top-inner .search-form, .header-actions .auth-links { display: none !important; }
    .nav-mobile-btn { display: flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }
    .nav-search-btn { display: flex; align-items: center; justify-content: center; }
    .header-actions .country-btn .country-btn-text, .header-actions .country-btn .country-btn-lang { display: none !important; }
}
