/* =====================================================================
   سیستم طراحی مشترک سایت و پنل ادمین: رنگ‌ها، تم تیره، انیمیشن‌ها و اجزای پایه
   ===================================================================== */
:root {
  --color-primary: #0a8fa6;
  --color-primary-dark: #0b5f86;
  --color-primary-soft: #e0f4fa;
  --color-accent: #38b6f2;
  --color-bg: #f4f4ee;
  --color-surface: #ffffff;
  --color-surface-2: #ebeeea;
  --color-text: #0d2238;
  --color-muted: #587086;
  --color-border: #d3e3ee;
  --color-danger: #c0392b;
  --color-danger-soft: #fbe9e6;
  --color-warn-soft: #e3f3fd;
  --color-sidebar-bg: #0b2545;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(11, 37, 69, .07), 0 1px 3px rgba(11, 37, 69, .06);
  --shadow-md: 0 8px 22px rgba(11, 37, 69, .12);
  --shadow-lg: 0 20px 55px rgba(11, 37, 69, .25);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --t-fast: .18s;
  --t-med: .32s;
  --font-main: "Nian", "Lotus", "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --color-primary: #2cc4d6;
  --color-primary-dark: #1b9bc4;
  --color-primary-soft: #0f3550;
  --color-accent: #5cc8fb;
  --color-bg: #07111f;
  --color-surface: #0e1d31;
  --color-surface-2: #15283f;
  --color-text: #e5f1f9;
  --color-muted: #8fa8bd;
  --color-border: #1c3550;
  --color-danger: #ef6a5b;
  --color-danger-soft: #3a2220;
  --color-warn-soft: #0f3550;
  --color-sidebar-bg: #040b16;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 55px rgba(0, 0, 0, .65);
  color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { background: var(--color-bg); color: var(--color-text); }
body { transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease); }
/* فونت پیش‌فرض همه‌ی بخش‌ها: نیان */
html, body, input, button, select, textarea, h1, h2, h3, h4, .app-title, .heading { font-family: var(--font-main); }

/* آیکون‌های SVG (جایگزین ایموجی‌ها) */
.ic { width: 1.2em; height: 1.2em; flex-shrink: 0; vertical-align: -0.22em; stroke: currentColor; fill: none; }
.btn .ic, .btn-primary .ic, .btn-secondary .ic { margin-inline-end: 2px; }

/* ---------- انیمیشن‌ها ---------- */
@keyframes ui-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes ui-fade-up { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes ui-pop { from { opacity: 0; transform: scale(.94) translateY(8px) } to { opacity: 1; transform: none } }
@keyframes ui-slide-in { from { opacity: 0; transform: translateX(-24px) } to { opacity: 1; transform: none } }
@keyframes ui-shimmer { 100% { transform: translateX(-100%) } }
@keyframes ui-spin { to { transform: rotate(360deg) } }

.anim-fade-up { animation: ui-fade-up .5s var(--ease) both; }
.anim-fade-in { animation: ui-fade-in .4s var(--ease) both; }
.stagger > * { animation: ui-fade-up .45s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s }
.stagger > *:nth-child(2) { animation-delay: .07s }
.stagger > *:nth-child(3) { animation-delay: .12s }
.stagger > *:nth-child(4) { animation-delay: .17s }
.stagger > *:nth-child(5) { animation-delay: .22s }
.stagger > *:nth-child(6) { animation-delay: .27s }
.stagger > *:nth-child(n+7) { animation-delay: .32s }

/* اسکلت بارگذاری (skeleton) */
.skeleton { position: relative; overflow: hidden; background: var(--color-surface-2); border-radius: 8px; min-height: 1em; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent);
  animation: ui-shimmer 1.3s infinite;
}
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .07), transparent); }

.spinner {
  width: 1.1em; height: 1.1em; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  display: inline-block; animation: ui-spin .7s linear infinite; vertical-align: -0.15em;
}

/* حالت تمرکز قابل‌مشاهده برای کیبورد */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 6px; }

/* ---------- دکمه‌ها ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: .9rem; cursor: pointer; text-decoration: none; line-height: 1.3;
  background: var(--color-surface-2); color: var(--color-text); border-color: var(--color-border);
  transition: transform var(--t-fast) var(--ease), background-color var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: var(--color-primary); }
.btn:active { transform: translateY(0) scale(.98); box-shadow: none; }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn-primary-solid, .btn.primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn.primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn.danger { background: var(--color-danger-soft); color: var(--color-danger); border-color: transparent; }
.btn.danger:hover { background: var(--color-danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--color-surface-2); box-shadow: none; }
.btn.sm { padding: 5px 10px; font-size: .8rem; border-radius: 8px; }

.theme-toggle { width: 38px; height: 38px; padding: 0; font-size: 1.05rem; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- اعلان (toast) ---------- */
.toast-stack { position: fixed; bottom: 18px; inset-inline-start: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; max-width: min(92vw, 380px); }
.toast {
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border);
  border-inline-start: 4px solid var(--color-primary); border-radius: 10px; padding: 11px 14px;
  box-shadow: var(--shadow-md); font-size: .88rem; animation: ui-slide-in .35s var(--ease) both;
  transition: opacity .3s, transform .3s;
}
.toast.error { border-inline-start-color: var(--color-danger); }
.toast.leaving { opacity: 0; transform: translateX(-20px); }

/* ---------- پنجره‌ی مودال ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 12, 16, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 9000;
  animation: ui-fade-in .2s ease both;
}
.modal {
  background: var(--color-surface); color: var(--color-text); border-radius: 16px; width: min(560px, 100%);
  max-height: 92vh; overflow: auto; padding: 22px; box-shadow: var(--shadow-lg); animation: ui-pop .3s var(--ease) both;
}
.modal h3 { margin: 0 0 14px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
