/* ═══════════════════════════════════════════════════════════════
   Design System — عدالت گستران (بند ۳۱ بازبینی معماری)
   لایه مشترک توکن‌ها + کامپوننت‌های پایه UI
   ───────────────────────────────────────────────────────────────
   ساختار پیشنهادی برای توسعه آینده:
     tokens      → :root (رنگ/فاصله/شعاع/سایه/حرکت) — ارجاع به توکن‌های main.css
     utilities   → کلاس‌های تک‌منظوره (.u-*)
     components  → table / badge / toast / modal / skeleton /
                   empty-state / spinner / button-states / field-states
   قواعد:
     ۱) این فایل هرگز استایل صفحات خاص را override نمی‌کند — فقط افزودنی است.
     ۲) هر کامپوننت جدید UI باید فقط با توکن‌های همین لایه ساخته شود.
     ۳) RTL-first — هیچ استایل LTR-محور اینجا تعریف نمی‌شود.
   ═══════════════════════════════════════════════════════════════ */

/* ── tokens (فقط الحاقات جدید — پایه در main.css) ── */
:root {
  /* حرکت */
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 340ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
  /* لایه‌بندی */
  --z-sticky: 90;
  --z-modal: 200;
  --z-toast: 240;
  /* فوکوس دسترس‌پذیری */
  --focus-ring: 0 0 0 3px rgba(45, 108, 223, .35);
}

/* ── دسترس‌پذیری (بند ۳۲) ── */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}
.skip-link {
  position: absolute; right: 12px; top: -48px; z-index: calc(var(--z-modal) + 1);
  background: var(--navy-900, #1b2440); color: #fff; padding: 9px 16px;
  border-radius: 0 0 12px 12px; font-size: 13px; transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 0; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── utilities ── */
.u-muted { color: var(--muted); }
.u-ok { color: var(--ok); }
.u-err { color: var(--err); }
.u-warn { color: var(--warn); }
.u-center { text-align: center; }
.u-small { font-size: 12.5px; }
.u-mono { font-family: ui-monospace, monospace; direction: ltr; unicode-bidi: embed; }

/* ── جدول عمومی (privacy/گزارش‌های عمومی — پنل ادمین .adm-* خودش را دارد) ── */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin: 14px 0; }
.table th, .table td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); }
.table thead th { background: var(--bg); color: var(--text); font-weight: 700; white-space: nowrap; }
.table tbody tr:hover td { background: rgba(45, 108, 223, .04); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── نشان (badge) ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--info-bg); color: var(--info); white-space: nowrap;
}
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--err { background: var(--err-bg); color: var(--err); }
.badge--muted { background: var(--bg); color: var(--muted); }

/* ── حالت‌های دکمه (بند ۳۲ — loading) ── */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  animation: ag-spin .7s linear infinite;
}
.btn--outline.is-loading::after, .btn--ghost.is-loading::after {
  border-color: rgba(27, 36, 64, .2); border-top-color: var(--text);
}

/* ── اسپینر مستقل ── */
.spinner {
  display: inline-block; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--info);
  animation: ag-spin .75s linear infinite; vertical-align: middle;
}
@keyframes ag-spin { to { transform: rotate(360deg); } }

/* ── اسکلتون (بارگذاری اسکلت‌محور) ── */
.skeleton {
  position: relative; overflow: hidden; border-radius: 8px;
  background: var(--line); min-height: 14px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  transform: translateX(-100%); animation: ag-shimmer 1.4s infinite;
}
@keyframes ag-shimmer { to { transform: translateX(100%); } }
.skeleton--text { height: 13px; margin: 7px 0; }
.skeleton--title { height: 22px; width: 55%; margin: 10px 0; }
.skeleton--card { height: 120px; border-radius: var(--r-md); }
.skeleton--avatar { width: 56px; height: 56px; border-radius: 50%; }

/* ── حالت خالی ── */
.empty-state {
  text-align: center; padding: 42px 20px; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--r-md); background: var(--surface);
  margin: 14px 0;
}
.empty-state__icon { display: inline-flex; margin-bottom: 10px; color: var(--line); }
.empty-state__icon svg { width: 42px; height: 42px; }
.empty-state__title { font-weight: 800; color: var(--text); margin-bottom: 5px; font-size: 15px; }
.empty-state__desc { font-size: 13px; max-width: 420px; margin: 0 auto 14px; line-height: 1.9; }

/* ── حالت خطا / بارگذاری بخش ── */
.state-block { text-align: center; padding: 34px 18px; border-radius: var(--r-md); margin: 14px 0; }
.state-block--error { background: var(--err-bg); color: var(--err); font-size: 13.5px; }
.state-block--loading { background: var(--bg); color: var(--muted); }

/* ── توست (Toast) ── */
.toast-stack {
  position: fixed; bottom: 18px; right: 18px; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 9px; max-width: min(360px, calc(100vw - 36px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--navy-900, #1b2440); color: var(--on-navy, #f4f6fc);
  padding: 12px 14px; border-radius: var(--r-md); box-shadow: var(--sh-lg);
  font-size: 13.5px; line-height: 1.8; opacity: 0; transform: translateY(8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast--ok { border-right: 4px solid var(--ok); }
.toast--err { border-right: 4px solid var(--err); }
.toast--warn { border-right: 4px solid var(--warn); }
.toast__close {
  background: none; border: 0; color: inherit; opacity: .6; cursor: pointer;
  margin-inline-start: auto; font-size: 16px; padding: 0 2px; line-height: 1;
}
.toast__close:hover { opacity: 1; }

/* ── مودال / تأیید (Confirmation) ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(13, 27, 62, .5); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 18px;
}
.modal-backdrop.is-open { display: flex; animation: ag-fade var(--dur) var(--ease); }
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  width: 100%; max-width: 430px; padding: 22px;
  animation: ag-pop var(--dur) var(--ease);
}
.modal__title { font-weight: 800; font-size: 16px; margin-bottom: 8px; color: var(--text); }
.modal__body { font-size: 13.5px; color: var(--muted); line-height: 2; margin-bottom: 18px; }
.modal__actions { display: flex; gap: 9px; justify-content: flex-start; }
@keyframes ag-fade { from { opacity: 0; } }
@keyframes ag-pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }

/* ── بنر کوکی (بند ۳۵) ── */
.cookie-banner {
  position: fixed; bottom: 14px; inset-inline: 14px; z-index: calc(var(--z-toast) - 10);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); padding: 14px 18px;
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); line-height: 1.9;
}
.cookie-banner__actions { display: flex; gap: 8px; }
@media (max-width: 640px) {
  .cookie-banner { flex-direction: column; align-items: stretch; text-align: right; }
}
