/* قانون سراسری: [hidden] همیشه برنده است — کلاس‌هایی که display:flex/grid می‌گذارند
   با specificity برابر، قانون UA را له می‌کردند و عنصرِ مخفی‌شده دیده می‌ماند
   (نمونه: دکمه‌ی «نمایش همه‌ی مدل‌ها» بعد از فیلتر DeepSeek). */
[hidden] { display: none !important; }

/* ============================================================
   SINOX API — COMPONENTS.CSS
   کتابخانه‌ی کامپوننت‌های قابل‌استفاده‌ی مجدد، استخراج‌شده از فایل‌های
   طراحی. همه‌ی چیدمان‌ها با ویژگی‌های منطقی (inline-start/end) نوشته
   شده تا در RTL درست کار کنند. وابسته به tokens.css.
   فهرست: دکمه‌ها · کارت‌ها · بج/چیپ · سگمنت · تب · فرم · بلوک کد ·
   کالاوت · اسکلتون · جدول · نقطه‌ی وضعیت · کارت آماری · حالت خالی ·
   آکاردئون · مودال · توست · تول‌تیپ · نوار/حلقه‌ی پیشرفت
   ============================================================ */

/* ================= ۱. دکمه‌ها (Button) ================= */
.btn {
  --btn-h: 44px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-h);
  padding-inline: var(--space-5);
  border: none;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: transform var(--dur-base) var(--ease-standard),
              box-shadow var(--dur-base) var(--ease-standard),
              background var(--dur-base) var(--ease-standard),
              border-color var(--dur-base) var(--ease-standard),
              color var(--dur-base) var(--ease-standard),
              filter var(--dur-base) var(--ease-standard),
              opacity var(--dur-base) var(--ease-standard);
}
.btn svg { flex-shrink: 0; }

/* --- variants --- */
.btn-primary {
  background: var(--grad-brand);
  color: var(--text-on-accent);
  box-shadow: var(--glow-primary-sm);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: var(--glow-primary-md); }
.btn-primary:active { transform: translateY(0); filter: brightness(0.96); }

.btn-secondary {
  background: var(--elev-1);
  color: var(--text-1);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--elev-2); border-color: var(--border-3); }
.btn-secondary:active { background: var(--elev-1); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-1);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--text-1); }
.btn-ghost:active { background: var(--primary-tint); }

.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-danger:active { background: rgba(239, 68, 68, 0.32); }

.btn-danger-solid { background: var(--red); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.08); }

.btn-success { background: var(--green-tint); color: var(--green); }
.btn-success:hover { background: rgba(16, 185, 129, 0.25); }

.btn-warning { background: var(--yellow); color: var(--text-on-yellow); }
.btn-warning:hover { filter: brightness(1.08); }

.btn-link {
  height: auto;
  padding: 0;
  background: none;
  /* فیکس: متن و فلش نباید دوخطی شوند */
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--primary-light);
  font-weight: var(--fw-semibold);
}
.btn-link:hover { color: var(--primary-lighter); }

/* --- sizes --- */
.btn-sm { --btn-h: 36px; padding-inline: var(--space-3); font-size: var(--fs-sm); border-radius: var(--radius-md); gap: 6px; }
.btn-lg { --btn-h: 52px; padding-inline: var(--space-6); font-size: var(--fs-md); border-radius: var(--radius-lg); }
.btn-icon { --btn-h: 40px; width: var(--btn-h); padding: 0; border-radius: var(--radius-md); }
.btn-icon.btn-sm { --btn-h: 32px; }

.btn-block { width: 100%; }

/* --- states --- */
.btn:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  filter: none !important;
}

.btn-loading { color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: sx-spin 0.8s linear infinite;
}
.btn-ghost.btn-loading::after,
.btn-secondary.btn-loading::after { border-color: var(--border-2); border-top-color: var(--text-1); }

@keyframes sx-spin { to { transform: rotate(360deg); } }

/* ================= ۲. کارت‌ها (Card) ================= */
.card {
  background: var(--card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  transition: border-color var(--dur-base) var(--ease-standard),
              background var(--dur-base) var(--ease-standard),
              transform var(--dur-base) var(--ease-standard),
              box-shadow var(--dur-base) var(--ease-standard);
}

.card-interactive { cursor: pointer; }
.card-interactive:hover,
.card:hover.card-interactive {
  border-color: var(--primary-border-tint);
  background: var(--elev-3);
  transform: translateY(-4px);
}
.card-interactive:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.card-flat { background: transparent; border-color: var(--border-1); }

/* کارت با حاشیه‌ی گرادیانتی — یک لایه‌ی بیرونی با پدینگ ۱px */
.card-gradient-border {
  padding: 1px;
  border-radius: var(--radius-2xl);
  background: var(--grad-card-border);
  box-shadow: var(--shadow-hero-card);
}
.card-gradient-border > .card-gradient-inner {
  border-radius: calc(var(--radius-2xl) - 1px);
  background: var(--bg2);
  padding: var(--space-6);
  height: 100%;
}

.card-title { font-size: var(--fs-lg); font-weight: var(--fw-extrabold); margin-bottom: var(--space-3); }
.card-desc { color: var(--text-muted); font-size: var(--fs-base); line-height: var(--lh-relaxed); }

/* ================= ۳. بج و چیپ (Badge / Chip) ================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: var(--fw-bold);
  line-height: 1.4;
  white-space: nowrap;
}
.badge-solid { background: var(--grad-brand); color: #fff; }
.badge-green { background: var(--green-tint); color: var(--green-light); }
.badge-red { background: var(--red-tint); color: var(--red-light); }
.badge-yellow { background: var(--yellow-tint); color: var(--yellow-light); }
.badge-cyan { background: var(--cyan-tint); color: var(--cyan-light); }
.badge-purple { background: var(--primary2-tint); color: var(--primary2-light); }
.badge-outline { background: transparent; border: 1px solid var(--border-2); color: var(--text-muted); }
.badge-count { background: var(--red); color: #fff; padding: 2px 8px; font-size: 10.5px; }

/* چیپ — قابل کلیک، با حالت انتخاب‌شده */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-1);
  background: var(--elev-1);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: border-color var(--dur-base), color var(--dur-base), background var(--dur-base);
}
.chip:hover { border-color: var(--border-2); color: var(--text-1); }
.chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chip.is-active {
  border-color: var(--border-2);
  background: var(--elev-3);
  color: var(--text-1);
}
.chip .chip-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.chip .chip-x { flex-shrink: 0; opacity: 0.8; }
.chip .chip-x:hover { opacity: 1; }

/* ================= ۴. سگمنت (Segmented control) ================= */
.segmented {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-full);
  background: var(--elev-1);
  border: 1px solid var(--border-1);
  isolation: isolate;
}
.segmented-option {
  position: relative;
  z-index: 1;
  padding: 9px 20px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: color var(--dur-base) var(--ease-standard);
  white-space: nowrap;
}
.segmented-option:hover { color: var(--text-1); }
.segmented-option:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.segmented-option[aria-selected="true"] { color: #fff; font-weight: var(--fw-bold); }

/* اندیس لغزنده — با جاوااسکریپت (ui.js) روی موقعیت گزینه‌ی فعال جابه‌جا می‌شود.
   از inset-inline-start استفاده می‌شود تا در RTL درست بلغزد. */
.segmented-indicator {
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  inset-inline-start: 4px;
  width: 0;
  border-radius: var(--radius-full);
  background: var(--grad-brand);
  transition: inset-inline-start var(--dur-slow) var(--ease-standard),
              width var(--dur-slow) var(--ease-standard);
}
@media (prefers-reduced-motion: reduce) {
  .segmented-indicator { transition: none; }
}

/* ================= ۵. تب (Tabs) ================= */
.tabs { display: flex; flex-direction: column; }
.tablist {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  border-bottom: 1px solid var(--border-1);
  overflow-x: auto;
}
.tab {
  position: relative;
  padding-block: var(--space-4);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-base);
}
.tab:hover { color: var(--text-1); }
.tab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tab[aria-selected="true"] { color: var(--text-1); }
.tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad-brand-reverse);
}
.tab-panel { padding-block: var(--space-5); }
.tab-panel[hidden] { display: none; }

/* تب کد (سبک titlebar کد در هیرو) */
.code-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.code-tab {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}
.code-tab:hover { color: var(--text-1); }
.code-tab[aria-selected="true"] { background: var(--elev-3); border-color: var(--border-2); color: var(--text-1); }

/* ================= ۶. فیلد فرم (Form) ================= */
.field { display: flex; flex-direction: column; gap: 9px; }
.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
}
.field-label .optional { font-size: var(--fs-2xs); color: var(--text-dim); font-weight: var(--fw-regular); }
.field-label .required { color: var(--red-light); }

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 48px;
  padding-inline: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--elev-1);
  border: 1px solid var(--border-1);
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.input-wrap svg { flex-shrink: 0; color: var(--text-muted); }
.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: var(--ring-primary);
}
.input-wrap.is-error { border-color: var(--red); }
.input-wrap.is-success { border-color: var(--green); }
.input-wrap.is-disabled { opacity: 0.55; }

.input-wrap input,
.input-wrap select,
.input-wrap textarea,
.field input,
.field select,
.field textarea {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  background: none;
  outline: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--fs-md);
}
.field input,
.field select {
  width: 100%;
  height: 48px;
  padding-inline: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg2);
  border: 1px solid var(--border-2);   /* فیکس: روی مودال/کارت، border-1 عملاً دیده نمی‌شد */
  color: var(--text-1);
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.field input:focus-visible,
.field select:focus-visible {
  border-color: var(--primary);
  box-shadow: var(--ring-primary);
  outline: none;
}
.field textarea {
  height: auto;
  min-height: 110px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg2);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  resize: vertical;
  line-height: var(--lh-snug);
}
.field textarea:focus-visible { border-color: var(--primary); box-shadow: var(--ring-primary); outline: none; }
::placeholder { color: var(--text-dim); opacity: 1; }

.field.is-error input,
.field.is-error select,
.field.is-error textarea { border-color: var(--red); }
.field input:disabled,
.field select:disabled,
.field textarea:disabled,
.field input:disabled + * { opacity: 0.55; cursor: not-allowed; }

.field-hint { font-size: var(--fs-xs); color: var(--text-muted); line-height: var(--lh-snug); }
.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--red-light);
}
.field-success {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--green-light);
}
.field-error svg, .field-success svg { flex-shrink: 0; }

/* چک‌باکس سفارشی */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  user-select: none;
}
.checkbox input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  overflow: hidden;
}
.checkbox .box {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--border-2);
  background: var(--elev-1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-base), border-color var(--dur-base);
}
.checkbox .box svg {
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--dur-fast), transform var(--dur-fast);
  color: #fff;
}
.checkbox input:checked + .box {
  background: var(--grad-brand);
  border-color: transparent;
}
.checkbox input:checked + .box svg { opacity: 1; transform: scale(1); }
.checkbox input:focus-visible + .box { outline: 2px solid var(--primary); outline-offset: 2px; }
.checkbox input:disabled + .box { opacity: 0.5; cursor: not-allowed; }

/* سنجه‌ی قدرت رمز عبور */
.pw-strength { display: flex; align-items: center; gap: var(--space-3); }
.pw-strength-bars { flex: 1; display: flex; gap: 5px; }
.pw-strength-bars i {
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--border-1);
  transition: background var(--dur-base);
}
.pw-strength-label { width: 44px; font-size: var(--fs-xs); font-weight: var(--fw-bold); text-align: end; }
.pw-strength[data-level="weak"] .pw-strength-bars i:nth-child(-n+1) { background: var(--red); }
.pw-strength[data-level="weak"] .pw-strength-label { color: var(--red-light); }
.pw-strength[data-level="medium"] .pw-strength-bars i:nth-child(-n+2) { background: var(--yellow); }
.pw-strength[data-level="medium"] .pw-strength-label { color: var(--yellow); }
.pw-strength[data-level="good"] .pw-strength-bars i:nth-child(-n+3) { background: #facc15; }
.pw-strength[data-level="good"] .pw-strength-label { color: #facc15; }
.pw-strength[data-level="strong"] .pw-strength-bars i { background: var(--green); }
.pw-strength[data-level="strong"] .pw-strength-label { color: var(--green-light); }

/* ردیف کپچا */
.captcha-row { display: flex; align-items: center; gap: var(--space-2); }
.captcha-question {
  flex-shrink: 0;
  width: 104px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--border-1);
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--primary-light);
}
.captcha-refresh {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--elev-1);
  border: 1px solid var(--border-1);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-base), border-color var(--dur-base), color var(--dur-base);
}
.captcha-refresh:hover { background: var(--elev-2); border-color: var(--border-2); color: var(--text-1); }
.captcha-refresh:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ================= ۷. بلوک کد (Code block) ================= */
.code-window {
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border-1);
  background: var(--bg2);
  overflow: hidden;
  direction: ltr;
  text-align: left;
}
.code-window-titlebar {
  height: 46px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: var(--space-4);
  background: var(--card);
  border-bottom: 1px solid var(--border-1);
}
.code-window-dots { display: flex; align-items: center; gap: 7px; }
.code-window-dots span { width: 11px; height: 11px; border-radius: 50%; opacity: 0.85; }
.code-window-dots span:nth-child(1) { background: var(--red); }
.code-window-dots span:nth-child(2) { background: var(--yellow); }
.code-window-dots span:nth-child(3) { background: var(--green); }

.code-block {
  position: relative;
  direction: ltr;   /* فیکس: در بستر RTL، اسکرول از انتهای خط شروع می‌شد و ابتدای کد بریده بود */
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: var(--lh-loose);
  padding-block: var(--space-5);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  color: var(--text-2);
}
.code-line { display: grid; grid-template-columns: 40px 1fr; }
.code-line.is-highlighted { background: var(--primary-tint-strong); border-inline-start: 2px solid var(--primary); }
.code-line-no {
  color: var(--text-faint);
  text-align: right;
  padding-inline-end: 14px;
  user-select: none;
}
.code-line-content { padding-inline-start: 18px; white-space: pre; }

/* توکن‌های نحو (syntax) */
.tok-kw { color: var(--primary2); }      /* کلیدواژه: from / import / const */
.tok-fn { color: var(--cyan); }          /* فراخوانی تابع/متد */
.tok-str { color: var(--green); }        /* رشته */
.tok-com { color: var(--text-faint); }   /* کامنت */
.tok-num { color: var(--yellow-light); } /* عدد */
.tok-var { color: var(--text-2); }       /* متغیر عادی */

.code-copy {
  position: absolute;
  top: var(--space-3);
  inset-inline-end: var(--space-3);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border-1);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-base), color var(--dur-base), border-color var(--dur-base);
}
.code-copy:hover { background: var(--elev-3); color: var(--text-1); border-color: var(--border-2); }
.code-copy:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.code-copy.is-copied { color: var(--green-light); border-color: var(--green-border-tint); }

/* نمایش کلید (مثل کلید API) */
.key-display {
  background: var(--bg2);
  border: 1px dashed var(--border-1);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  direction: ltr;
  text-align: center;
  word-break: break-all;
  color: var(--cyan);
}

/* ================= ۸. کالاوت (Callout) ================= */
.callout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: 15px 20px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-1);
  border-inline-start: 3px solid var(--border-2);
  background: var(--elev-2);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
}
.callout > svg { flex-shrink: 0; margin-top: 2px; }
.callout-body { flex: 1; min-width: 0; }
.callout-title { font-weight: var(--fw-bold); margin-bottom: 4px; }

.callout-note { border-color: var(--border-1); background: var(--elev-2); }
.callout-note > svg { color: var(--cyan); }

.callout-tip {
  border-color: var(--green-border-tint);
  border-inline-start-color: var(--green);
  background: var(--green-tint);
}
.callout-tip > svg { color: var(--green); }

.callout-warn {
  border-color: var(--yellow-border-tint);
  border-inline-start-color: var(--yellow);
  background: var(--yellow-tint);
}
.callout-warn > svg { color: var(--yellow); }

.callout-danger {
  border-color: var(--red-border-tint);
  border-inline-start-color: var(--red);
  background: var(--red-tint);
}
.callout-danger > svg { color: var(--red-light); }

/* ================= ۹. اسکلتون (Skeleton) ================= */
.skeleton {
  background: var(--grad-shimmer);
  background-size: 200% 100%;
  animation: sx-shimmer var(--dur-shimmer) linear infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  pointer-events: none;
}
@keyframes sx-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; border-radius: var(--radius-full); }
.skeleton-title { height: 20px; width: 60%; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-lg); }
.skeleton-btn { height: 34px; width: 90px; border-radius: var(--radius-full); }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; background: var(--elev-3); }
}

/* ================= ۱۰. جدول (Table) ================= */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sx-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.sx-table th {
  text-align: start;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  border-bottom: 1px solid var(--border-1);
  white-space: nowrap;
}
.sx-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
.sx-table tbody tr { transition: background var(--dur-base); }
.sx-table tbody tr:hover td { background: rgba(99, 102, 241, 0.04); }
.sx-table tbody tr:last-child td { border-bottom: none; }

/* واکشن موبایل — هر ردیف به یک کارت تبدیل می‌شود */
@media (max-width: 720px) {
  .sx-table.table-collapse thead { display: none; }
  .sx-table.table-collapse,
  .sx-table.table-collapse tbody,
  .sx-table.table-collapse tr,
  .sx-table.table-collapse td { display: block; width: 100%; }
  .sx-table.table-collapse tr {
    margin-bottom: var(--space-3);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-4);
    background: var(--card);
  }
  .sx-table.table-collapse td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    white-space: normal;
    text-align: end;
  }
  .sx-table.table-collapse td:last-child { border-bottom: none; }
  .sx-table.table-collapse td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-align: start;
  }
}

/* ================= ۱۱. نقطه‌ی وضعیت (Status dot) ================= */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-inline-start: 6px;
  flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); }
.status-dot.busy { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.status-dot.unknown { background: var(--muted); }
.status-dot.pulse { animation: sx-pulse-ring 2.2s infinite; }
@keyframes sx-pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot.pulse { animation: none; }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--green-border-tint);
  background: rgba(16, 185, 129, 0.07);
  color: var(--green-light);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

/* ================= ۱۲. کارت آماری (Stat card) ================= */
.stat-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2xl);
  padding: var(--space-5);
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--cyan));
}
.stat-card .stat-label { color: var(--text-muted); font-size: var(--fs-xs); margin-bottom: 6px; }
.stat-card .stat-value { font-size: var(--fh-h3); font-weight: var(--fw-black); line-height: var(--lh-tight); }
.stat-card .stat-sub { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 4px; }
.stat-card .stat-icon { color: var(--primary-light); }

/* ================= ۱۳. حالت خالی (Empty state) ================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
  padding: var(--space-14) var(--space-8);
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius-2xl);
  background: var(--bg2);
}
.empty-state .empty-icon { color: var(--border-2); }
.empty-state .empty-title { font-size: var(--fs-lg); font-weight: var(--fw-extrabold); color: var(--text-1); }
.empty-state .empty-desc { max-width: 340px; font-size: var(--fs-base); line-height: var(--lh-relaxed); color: var(--text-muted); }

/* ================= ۱۴. آکاردئون (Accordion) ================= */
.accordion-item { border-top: 1px solid var(--border-1); }
.accordion-item:first-child { border-top: none; }
.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: var(--space-4);
  background: none;
  border: none;
  color: var(--text-1);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  text-align: start;
  cursor: pointer;
}
.accordion-trigger:hover { color: var(--primary-light); }
.accordion-trigger:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.accordion-trigger .chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--dur-base) var(--ease-standard);
}
.accordion-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.accordion-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--dur-slow) var(--ease-standard);
}
.accordion-panel.is-open { max-height: var(--panel-h, 600px); }
.accordion-panel-inner { padding-block: 2px var(--space-4); color: var(--text-muted); font-size: var(--fs-base); line-height: var(--lh-relaxed); }
@media (prefers-reduced-motion: reduce) {
  .accordion-panel { transition: none; }
}

/* ================= ۱۵. مودال (Modal) ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}
.modal-overlay.is-open { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border-1);
  background: var(--card);
  padding: var(--space-7);
  box-shadow: var(--shadow-panel);
  animation: sx-modal-in var(--dur-slow) var(--ease-out);
}
@keyframes sx-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .modal { animation: none; }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.modal-title { font-size: var(--fs-2xl); font-weight: var(--fw-extrabold); }
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text-1); background: var(--elev-1); }
.modal-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.modal-body { color: var(--text-2); font-size: var(--fs-base); line-height: var(--lh-relaxed); }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-6); }
body.modal-open { overflow: hidden; }

/* ================= ۱۶. توست (Toast) ================= */
.toast-region {
  position: fixed;
  bottom: var(--space-6);
  inset-inline: 0;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding-inline: var(--space-4);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-2);
  background: var(--elev-3);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-row { display: flex; align-items: center; gap: var(--space-3); padding: 15px 17px; }
.toast-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.toast-msg { flex: 1; font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--text-1); }
.toast-dismiss { flex-shrink: 0; color: var(--text-muted); cursor: pointer; }
.toast-dismiss:hover { color: var(--text-1); }
.toast-bar { height: 3px; background: var(--elev-4); }
/* ui.js عرض این span را از ۱۰۰٪ به ۰٪ کم می‌کند (شمارش معکوس تا بسته‌شدن خودکار) */
.toast-bar > span { display: block; height: 100%; width: 100%; transition: width linear; }

.toast-success { border-color: var(--green-border-tint); }
.toast-success .toast-icon { background: var(--green-tint); color: var(--green); }
.toast-success .toast-bar > span { background: var(--green); }

.toast-error { border-color: var(--red-border-tint); }
.toast-error .toast-icon { background: var(--red-tint); color: var(--red-light); }
.toast-error .toast-bar > span { background: var(--red); }

.toast-warning { border-color: var(--yellow-border-tint); }
.toast-warning .toast-icon { background: var(--yellow-tint); color: var(--yellow); }
.toast-warning .toast-bar > span { background: var(--yellow); }

.toast-info { border-color: rgba(6, 182, 212, 0.35); }
.toast-info .toast-icon { background: var(--cyan-tint); color: var(--cyan); }
.toast-info .toast-bar > span { background: var(--cyan); }

/* ================= ۱۷. تول‌تیپ (Tooltip) ================= */
.tooltip-wrap { position: relative; display: inline-flex; }
.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  inset-inline-start: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--elev-4);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard), transform var(--dur-base) var(--ease-standard);
  z-index: 50;
}
.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border-2);
}
.tooltip-wrap:hover .tooltip,
.tooltip-wrap:focus-within .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ================= ۱۸. نوار و حلقه‌ی پیشرفت (Progress) ================= */
.progress {
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--bg2);
  overflow: hidden;
}
.progress .progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  transition: width var(--dur-slower) var(--ease-standard);
}
.progress.progress-thin { height: 6px; }
.progress-track-danger .progress-bar { background: var(--red); }
.progress-track-warning .progress-bar { background: var(--yellow); }

.quota-text {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 6px;
}

/* حلقه‌ی پیشرفت — با conic-gradient، مثل طراحی داشبورد */
.progress-ring {
  --ring-pct: 0%;
  --ring-color: var(--primary);
  --ring-size: 96px;
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
  border-radius: 50%;
  flex-shrink: 0;
  background: conic-gradient(var(--ring-color) var(--ring-pct), var(--border-1) var(--ring-pct));
  display: flex;
  align-items: center;
  justify-content: center;
}
.progress-ring::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--card);
}
.progress-ring-label {
  position: relative;
  text-align: center;
  font-weight: var(--fw-black);
}
.progress-ring-label .n { display: block; font-size: 20px; line-height: 1.1; }
.progress-ring-label .u { display: block; margin-top: 2px; font-size: 10.5px; color: var(--text-muted); font-weight: var(--fw-semibold); }


/* فیکس ممیزی موبایل: جدول پهن‌تر از کارت به‌جای بریده‌شدن از لبه، اسکرول بخورد */
@media (max-width: 640px) {
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}


/* فیکس: selectهای بومی مرورگر (فلش پیش‌فرض) → ظاهر یکدست با شورون سفارشی */
.field select, .pnl-select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239c9cba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-inline-end: var(--space-4);
  padding-inline-start: 34px;
  cursor: pointer;
}
.pnl-select { background-color: var(--bg2); border-color: var(--border-2); }

/* فیکس: اینپوت داخل .input-wrap نباید قاب/پس‌زمینه‌ی خودش را داشته باشد —
   فیکس کنتراست فیلدها (v5) ناخواسته به این‌ها هم قاب داده بود → قاب توی قاب
   (نمونه: فیلدهای تغییر رمز عبور). قاب فقط مال خود رپر است. */
.input-wrap input,
.input-wrap select,
.field .input-wrap input,
.field .input-wrap select {
  height: 100%;
  border: 0;
  background: none;
  border-radius: 0;
  box-shadow: none;
  padding-inline: 0;
}
.input-wrap input:focus-visible,
.input-wrap select:focus-visible { border: 0; box-shadow: none; outline: none; }
