/* ============================================================
   Vazirmatn — self-hosted (no CDN). The portal runs on the store LAN
   with no public internet, so the Google Fonts CDN never resolves and
   Persian text falls back to Tahoma. These weights (400–800) cover the
   whole design system; files live in css/fonts/. font-display:swap keeps
   text visible during the (local, near-instant) load.
   ============================================================ */
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');   font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Medium.woff2') format('woff2');    font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-SemiBold.woff2') format('woff2');  font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');      font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('fonts/Vazirmatn-ExtraBold.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }

/* ============================================================
   باشگاه مشتریان ایوب — design system
   Mood: a well-run store's members' lounge — warm, trustworthy,
   generous, calm authority. Deep indigo primary + warm amber for
   reward moments; pure-white canvas; Vazirmatn throughout.
   ============================================================ */

:root {
    /* brand */
    --brand: oklch(0.47 0.15 285);
    --brand-hover: oklch(0.42 0.15 285);
    --brand-ink: oklch(0.99 0.01 285);
    --brand-soft: oklch(0.95 0.03 285);

    /* accent — reward / points moments only, used sparingly */
    --accent: oklch(0.80 0.14 74);
    --accent-strong: oklch(0.66 0.13 66);
    --accent-soft: oklch(0.96 0.045 82);

    /* surfaces */
    --bg: oklch(1 0 0);
    --surface: oklch(0.985 0.004 285);
    --surface-2: oklch(0.965 0.006 285);

    /* ink */
    --ink: oklch(0.26 0.015 285);
    --ink-strong: oklch(0.19 0.02 285);
    --muted: oklch(0.50 0.02 285);
    --border: oklch(0.915 0.006 285);
    --border-strong: oklch(0.85 0.008 285);

    /* semantic */
    --success: oklch(0.60 0.14 150);
    --danger: oklch(0.58 0.19 27);

    /* radii / shadow / spacing */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;
    --shadow-sm: 0 1px 2px oklch(0.2 0.02 285 / 0.06), 0 2px 6px oklch(0.2 0.02 285 / 0.05);
    --shadow-md: 0 6px 18px oklch(0.2 0.02 285 / 0.09);
    --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem; --sp-6: 2rem; --sp-8: 3rem;

    --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;

    /* z-index scale */
    --z-appbar: 100; --z-dropdown: 200; --z-modal-backdrop: 300; --z-modal: 400; --z-toast: 500;
}

/* ---- dark theme (system-resolved to data-theme by the boot script; toggle overrides) ---- */
:root[data-theme="dark"] {
    color-scheme: dark;

    --brand: oklch(0.63 0.16 286);
    --brand-hover: oklch(0.69 0.15 286);
    --brand-ink: oklch(0.99 0.01 285);
    --brand-soft: oklch(0.32 0.06 286);

    --accent: oklch(0.82 0.13 76);
    --accent-strong: oklch(0.85 0.12 80);
    --accent-soft: oklch(0.31 0.05 74);

    --bg: oklch(0.165 0.012 285);
    --surface: oklch(0.205 0.014 285);
    --surface-2: oklch(0.245 0.016 285);

    --ink: oklch(0.92 0.01 285);
    --ink-strong: oklch(0.98 0.005 285);
    --muted: oklch(0.70 0.02 285);
    --border: oklch(0.30 0.014 285);
    --border-strong: oklch(0.40 0.018 285);

    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.40), 0 2px 8px oklch(0 0 0 / 0.30);
    --shadow-md: 0 8px 24px oklch(0 0 0 / 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    color: var(--ink-strong);
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-wrap: balance;
    margin: 0 0 .5em;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; max-width: 68ch; }

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

::selection { background: var(--brand-soft); color: var(--ink-strong); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
    font-family: var(--font);
    font-weight: 600;
    font-size: .95rem;
    line-height: 1.2;
    border-radius: var(--r-md);
    padding: .62rem 1.15rem;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: none; }
.btn-sm { padding: .42rem .85rem; font-size: .9rem; }

.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--brand-ink); }
.btn-primary:disabled { background: var(--surface-2); color: var(--muted); border-color: var(--border); cursor: not-allowed; transform: none; }

.btn-outline { background: transparent; color: var(--brand); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--brand-soft); }

.btn-link { background: transparent; color: var(--brand); border: none; padding: .5rem .25rem; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }

/* ---------- forms ---------- */
.form-label { display: block; font-weight: 600; font-size: .9rem; color: var(--ink-strong); margin-bottom: .35rem; }
.form-control {
    font-family: var(--font);
    width: 100%;
    padding: .62rem .8rem;
    font-size: 1rem;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control::placeholder { color: var(--muted); }
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.form-control { min-height: 4.5rem; resize: vertical; }

.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check-input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.form-check-input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.form-check-label { font-size: .95rem; color: var(--ink); }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); }
.panel-elevated { background: var(--bg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); border-radius: var(--r-lg); padding: var(--sp-6); }

/* ---------- alerts (full border + tint, never side-stripe) ---------- */
.alert { border-radius: var(--r-md); padding: .75rem 1rem; border: 1px solid transparent; font-size: .95rem; margin: 0; }
.alert-warning { background: var(--accent-soft); border-color: oklch(0.85 0.09 80); color: oklch(0.40 0.10 66); }
.alert-success { background: oklch(0.95 0.05 150); border-color: oklch(0.80 0.10 150); color: oklch(0.34 0.10 150); }
.alert-danger { background: oklch(0.96 0.04 27); border-color: oklch(0.85 0.10 27); color: oklch(0.44 0.16 27); }
:root[data-theme="dark"] .alert-warning { background: oklch(0.28 0.06 75); border-color: oklch(0.42 0.09 75); color: oklch(0.90 0.08 82); }
:root[data-theme="dark"] .alert-success { background: oklch(0.26 0.06 150); border-color: oklch(0.40 0.09 150); color: oklch(0.88 0.10 150); }
:root[data-theme="dark"] .alert-danger { background: oklch(0.28 0.08 27); border-color: oklch(0.44 0.12 27); color: oklch(0.90 0.10 27); }
:root[data-theme="dark"] #blazor-error-ui { background: oklch(0.28 0.06 75); color: oklch(0.90 0.08 82); }

/* ---------- app shell ---------- */
.appbar {
    position: sticky;
    top: 0;
    z-index: var(--z-appbar);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.appbar__brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.05rem; color: var(--ink-strong); letter-spacing: -0.01em; }
.appbar__brand:hover { text-decoration: none; }
.appbar__brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; font-size: 1rem; }
.appbar__actions { display: flex; align-items: center; gap: var(--sp-4); }
.appbar__link { color: var(--muted); font-weight: 600; font-size: .95rem; }
.appbar__link:hover { color: var(--ink-strong); text-decoration: none; }
.icon-btn { width: 38px; height: 38px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg); color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
.icon-btn:hover { color: var(--ink-strong); border-color: var(--border-strong); background: var(--surface); }
.icon-btn svg { width: 18px; height: 18px; }

.app-content { max-width: 760px; margin: 0 auto; padding: var(--sp-6) var(--sp-5) var(--sp-8); }

/* ---------- points / balance display (no hero-metric slop) ---------- */
.balance { display: flex; align-items: baseline; gap: .5rem; }
.balance__value { font-size: 2rem; font-weight: 800; color: var(--ink-strong); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.balance__unit { color: var(--muted); font-weight: 600; font-size: 1rem; }
.reward-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: .85rem; }

.muted { color: var(--muted); }
.stack > * + * { margin-top: var(--sp-4); }
.subtitle { color: var(--muted); font-size: 1rem; margin-top: -.35rem; }

/* button loading spinner */
.spinner { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; display: inline-block; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* OTP code input */
.otp-input { text-align: center; font-size: 1.5rem; font-weight: 700; letter-spacing: .5em; padding-inline: .5rem; }
.otp-input::placeholder { letter-spacing: normal; font-size: 1rem; }

/* entrance — enhancement only; content is fully visible without it */
@media (prefers-reduced-motion: no-preference) {
    .fade-rise { animation: fadeRise .45s cubic-bezier(0.22, 1, 0.36, 1) both; }
}
@keyframes fadeRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* benefits (icon + text rows, not cards) */
.benefits { display: grid; gap: var(--sp-4); margin: var(--sp-2) 0; }
.benefit { display: flex; align-items: flex-start; gap: .8rem; }
.benefit__icon { flex: none; width: 42px; height: 42px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; }
.benefit__icon svg { width: 22px; height: 22px; }
.benefit__title { font-weight: 700; color: var(--ink-strong); }
.benefit__desc { color: var(--muted); font-size: .92rem; }

/* ---- dashboard: sections, lists, badges, skeletons ---- */
.section-title { font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: .5rem; }
.list { display: grid; gap: .5rem; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.list-row__title { font-weight: 600; color: var(--ink-strong); display: flex; align-items: center; gap: .5rem; }
.list-row__meta { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.badge { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: var(--r-pill); font-size: .78rem; font-weight: 700; }
.badge--inperson { background: var(--brand-soft); color: var(--brand); }
.badge--online { background: var(--accent-soft); color: var(--accent-strong); }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; border-radius: var(--r-md); animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---- member card (identity + scannable code) ---- */
.member-card {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--sp-5);
    align-items: center;
    padding: var(--sp-5);
    border-radius: var(--r-lg);
    color: var(--brand-ink);
    background:
        radial-gradient(120% 130% at 88% -10%, oklch(0.62 0.17 286) 0%, transparent 52%),
        linear-gradient(135deg, var(--brand) 0%, var(--brand-hover) 100%);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}
.member-card__brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .9rem; opacity: .92; }
.member-card__mark { width: 26px; height: 26px; border-radius: 8px; background: oklch(1 0 0 / 0.16); display: grid; place-items: center; font-weight: 800; }
.member-card__name { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin-top: var(--sp-4); }
.member-card__code { margin-top: var(--sp-3); }
.member-card__code-label { display: block; font-size: .78rem; opacity: .82; margin-bottom: .12rem; }
.member-card__code-value { font-size: 1.15rem; font-weight: 700; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.member-card__qr { flex: none; }
.member-card__qr-img { width: 118px; height: 118px; padding: 7px; background: #fff; border-radius: var(--r-md); box-shadow: 0 2px 8px oklch(0 0 0 / 0.18); }
.member-card__qr-img svg { display: block; width: 100%; height: 100%; }

@media (max-width: 460px) {
    .member-card { grid-template-columns: 1fr; justify-items: start; }
    .member-card__qr { margin-top: var(--sp-2); }
}

/* quick actions row (below the member card, on forms) */
.quick-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
    * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------- validation (Blazor) ---------- */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: .85rem; }

/* ---------- Blazor boot + error (kept, brand-tuned) ---------- */
#blazor-error-ui {
    color-scheme: light only;
    background: var(--accent-soft);
    color: oklch(0.40 0.10 66);
    bottom: 0; left: 0; width: 100%;
    box-sizing: border-box;
    box-shadow: 0 -1px 2px oklch(0 0 0 / 0.15);
    display: none;
    padding: .7rem 1.25rem;
    position: fixed;
    z-index: var(--z-toast);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; left: 0.9rem; top: 0.6rem; }

.blazor-error-boundary { background: var(--danger); padding: 1rem 1.25rem; color: white; border-radius: var(--r-md); }
.blazor-error-boundary::after { content: "خطایی رخ داد."; }

.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 24vh auto 1rem auto; }
.loading-progress circle { fill: none; stroke: var(--border); stroke-width: 0.5rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child { stroke: var(--brand); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress-text { position: absolute; text-align: center; font-weight: 700; color: var(--muted); inset: calc(24vh + 3.25rem) 0 auto 0; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "در حال بارگذاری"); }
