/* ==========================================================================
   پشتیبان PSP — پایه طراحی (توکن‌ها، ریست، تایپوگرافی، دارک‌مود)
   ترتیب بارگذاری: base.css → components.css → layout.css → pages.css
   ========================================================================== */

/* ---------------------------------------------------------------- توکن‌ها */
:root {
    color-scheme: light;

    /* برند */
    --brand-50: #eef8f3;
    --brand-100: #d4efe2;
    --brand-200: #a9dfc6;
    --brand-300: #74c9a5;
    --brand-400: #43ad83;
    --brand-500: #238d63;
    --brand-600: #17714f;
    --brand-700: #135b41;
    --brand-800: #114834;

    /* رنگ‌های معنایی */
    --info-50: #eff6ff;
    --info-500: #2563eb;
    --warning-50: #fff7ec;
    --warning-500: #e08214;
    --danger-50: #fef2f2;
    --danger-500: #dc2626;
    --success-500: #16a34a;

    /* سطوح */
    --bg: #f4f6f5;
    --bg-elevated: #ffffff;
    --surface: #ffffff;
    --surface-2: #f7f9f8;
    --surface-3: #eef2f0;
    --border: #e3e8e5;
    --border-strong: #cfd8d3;

    /* متن */
    --text: #12211b;
    --text-muted: #5c6b64;
    --text-subtle: #8a9791;
    --on-brand: #ffffff;

    /* شکل و سایه */
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 20, .06);
    --shadow: 0 6px 20px -8px rgba(16, 40, 30, .18), 0 2px 6px rgba(16, 40, 30, .05);
    --shadow-lg: 0 20px 40px -20px rgba(16, 40, 30, .35);
    --ring: 0 0 0 3px rgba(35, 141, 99, .22);

    /* ابعاد */
    --header-h: 60px;
    --nav-h: 64px;
    --page-pad: 16px;
    --maxw: 560px;
    --card-pad: 16px;

    /* حرکت */
    --ease: cubic-bezier(.2, .8, .2, 1);
    --dur: .22s;

    /* فونت */
    --font: "Vazirmatn", "IRANSansX", "Segoe UI", Tahoma, sans-serif;
    --font-num: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
}

/* ---------------------------------------------------------------- دارک‌مود */
:root[data-theme="dark"] {
    color-scheme: dark;

    --brand-50: #10261e;
    --brand-100: #143428;
    --brand-200: #1b4a37;
    --brand-300: #2b7a58;
    --brand-400: #47b489;
    --brand-500: #5ad3a3;
    --brand-600: #7ee0b8;
    --brand-700: #a6ecd0;

    --info-50: #12233f;
    --warning-50: #33240d;
    --danger-50: #38181a;

    --bg: #0b1210;
    --bg-elevated: #121b18;
    --surface: #131d1a;
    --surface-2: #182421;
    --surface-3: #1f2d29;
    --border: #26332f;
    --border-strong: #37463f;

    --text: #e9f1ed;
    --text-muted: #9db0a7;
    --text-subtle: #74877e;
    --on-brand: #06110c;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow: 0 10px 26px -14px rgba(0, 0, 0, .75), 0 2px 8px rgba(0, 0, 0, .4);
    --shadow-lg: 0 28px 60px -30px rgba(0, 0, 0, .9);
    --ring: 0 0 0 3px rgba(90, 211, 163, .28);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --brand-50: #10261e;
        --brand-100: #143428;
        --brand-200: #1b4a37;
        --brand-300: #2b7a58;
        --brand-400: #47b489;
        --brand-500: #5ad3a3;
        --brand-600: #7ee0b8;
        --brand-700: #a6ecd0;
        --info-50: #12233f;
        --warning-50: #33240d;
        --danger-50: #38181a;
        --bg: #0b1210;
        --bg-elevated: #121b18;
        --surface: #131d1a;
        --surface-2: #182421;
        --surface-3: #1f2d29;
        --border: #26332f;
        --border-strong: #37463f;
        --text: #e9f1ed;
        --text-muted: #9db0a7;
        --text-subtle: #74877e;
        --on-brand: #06110c;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
        --shadow: 0 10px 26px -14px rgba(0, 0, 0, .75), 0 2px 8px rgba(0, 0, 0, .4);
        --shadow-lg: 0 28px 60px -30px rgba(0, 0, 0, .9);
        --ring: 0 0 0 3px rgba(90, 211, 163, .28);
    }
}

/* ---------------------------------------------------------------- فونت */
/* فونت را در wwwroot/fonts قرار بده (README را ببین)؛ در نبود فایل، فونت سیستم استفاده می‌شود. */
@font-face {
    font-family: "Vazirmatn";
    src: url("/fonts/Vazirmatn-Regular.woff2") format("woff2");
    font-weight: 400;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("/fonts/Vazirmatn-Medium.woff2") format("woff2");
    font-weight: 500;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("/fonts/Vazirmatn-Bold.woff2") format("woff2");
    font-weight: 700;
    font-display: swap;
    font-style: normal;
}

/* ---------------------------------------------------------------- ریست */
*, *::before, *::after { box-sizing: border-box; }

/* مهم: روی <html> هیچ overflow-x اعمال نمی‌شود. اگر overflow-x روی html باشد،
   مرورگر «containing block» عناصر fixed را به آن منتقل می‌کند؛ این یکی از
   دلایل بیرون‌زدگی و جابه‌جایی کارت‌هاست. محافظت از سرریز در body انجام می‌شود. */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    /* هیچ overflow روی body نمی‌گذاریم: body را به scroll container تبدیل
       می‌کند و در RTL باعث جابه‌جایی محتوای fixed/sticky می‌شود.
       مهار سرریز در .app و .shell انجام می‌شود. */
}

img, svg, video, canvas { display: block; max-width: 100%; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button { cursor: pointer; background: none; border: 0; padding: 0; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.4; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-radius: var(--radius-sm);
}

::selection { background: var(--brand-200); color: var(--text); }

/* اسکرول‌بار نازک در دسکتاپ */
@media (hover: hover) and (pointer: fine) {
    * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
}

/* ---------------------------------------------------------------- ابزارک‌ها */
.icon {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    stroke-width: 1.8;
}

/* آیکون‌های جهت‌دار در RTL آینه می‌شوند («بعدی» باید به چپ اشاره کند).
   آیکون‌های خنثی (خانه، زنگ، کاربر ...) دست‌نخورده می‌مانند. */
[dir="rtl"] .icon-chevron,
[dir="rtl"] .icon-arrow,
[dir="rtl"] .icon-logout,
[dir="rtl"] .icon-forward {
    transform: scaleX(-1);
}

/* استثنا: هر آیکونی که کلاس icon-fixed دارد هیچ‌گاه آینه نمی‌شود. */
[dir="rtl"] .icon.icon-fixed {
    transform: none !important;
}



.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 26px; height: 26px; }
.icon-xl { width: 34px; height: 34px; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.num { font-variant-numeric: tabular-nums; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: .82rem; }
.tiny { font-size: .74rem; }
.strong { font-weight: 700; }
.center { text-align: center; }

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap { flex-wrap: wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.stack > * + * { margin-top: 12px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

[hidden] { display: none !important; }

/* احترام به تنظیم کاهش حرکت */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
