/* ==========================================================================
   کیت قطعات: دکمه، چیپ، کارت، فرم، شیت، توست، اسکلتون، ...
   ========================================================================== */

/* ---------- دکمه‌ها ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 48px;
  padding: 0 var(--s5);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-md);
  font-weight: 700;
  white-space: nowrap;
  transition: background-color var(--t-fast) ease, transform var(--t-fast) var(--ease), opacity var(--t-fast) ease;
  user-select: none;
}

.btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--on-accent);
}

.btn-biz {
  --btn-bg: var(--biz);
  --btn-fg: #0B1220;
}

[data-theme="light"] .btn-biz {
  --btn-fg: #fff;
}

.btn-ghost {
  --btn-bg: transparent;
}

.btn-outline {
  --btn-bg: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.btn-soft {
  --btn-bg: var(--accent-soft);
  --btn-fg: var(--accent-text);
}

.btn-danger {
  --btn-bg: var(--err-soft);
  --btn-fg: var(--err);
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--s3);
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}

.btn-sm svg {
  width: 16px;
  height: 16px;
}

.btn-lg {
  min-height: 56px;
  font-size: 1.05rem;
  border-radius: var(--r-lg);
}

.btn-block {
  width: 100%;
}

@media (hover: hover) {
  .btn:hover {
    filter: brightness(1.08);
  }

  .btn-ghost:hover,
  .btn-outline:hover {
    background: var(--surface-2);
    filter: none;
  }
}

/* دکمه آیکونی (۴۴×۴۴) */
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  color: var(--text);
  flex-shrink: 0;
  position: relative;
  transition: background-color var(--t-fast) ease, transform var(--t-fast) var(--ease);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
}

.icon-btn:active {
  transform: scale(0.92);
  background: var(--surface-2);
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--surface-2);
  }
}

.icon-btn.on-media {
  background: rgba(10, 10, 12, 0.45);
  color: #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.dot-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ---------- چیپ‌ها ---------- */
.chips {
  display: flex;
  gap: var(--s2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-inline: var(--gutter);
  margin-inline: calc(var(--gutter) * -1);
  scroll-padding-inline: var(--gutter);
}

.chips::-webkit-scrollbar {
  display: none;
}

.chips.wrap {
  flex-wrap: wrap;
  overflow: visible;
  margin-inline: 0;
  padding-inline: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease, transform var(--t-fast) var(--ease);
  user-select: none;
}

.chip svg {
  width: 16px;
  height: 16px;
}

.chip:active {
  transform: scale(0.95);
}

.chip.is-on,
.chip[aria-pressed="true"],
.chip[aria-checked="true"] {
  background: var(--text);
  color: var(--bg);
}

.chip-lg {
  min-height: 44px;
  padding: 0 18px;
  font-size: var(--fs-md);
}

/* ---------- نشان‌ها ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.badge svg {
  width: 14px;
  height: 14px;
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-biz { background: var(--biz-soft); color: var(--biz); }

.badge-media {
  background: rgba(10, 10, 12, 0.55);
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
  flex-shrink: 0;
}

/* ---------- آواتار ---------- */
.avatar {
  --size: 44px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-3);
  flex-shrink: 0;
}

.avatar-initials {
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  font-size: calc(var(--size) * 0.38);
  color: var(--text);
  background: var(--biz-soft);
}

.avatar.square {
  border-radius: 28%;
}

/* ---------- کارت ---------- */
.card {
  background: var(--surface-1);
  border-radius: var(--r-lg);
  padding: var(--s4);
}

.card-flat {
  background: var(--surface-1);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.card-press {
  transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) ease;
}

.card-press:active {
  transform: scale(0.985);
}

@media (hover: hover) {
  .card-press:hover {
    background: var(--surface-2);
  }
}

/* ---------- سطر فهرست (مثل تنظیمات iOS) ---------- */
.list {
  background: var(--surface-1);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 56px;
  padding: var(--s3) var(--s4);
  width: 100%;
  text-align: start;
  position: relative;
  transition: background-color var(--t-fast) ease;
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 56px;
  inset-inline-end: 0;
  height: 1px;
  background: var(--line);
}

.row.no-icon + .row::before,
.row + .row.no-icon::before {
  inset-inline-start: var(--s4);
}

button.row:active,
a.row:active {
  background: var(--surface-2);
}

.row-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  flex-shrink: 0;
}

.row-icon svg {
  width: 18px;
  height: 18px;
}

.row-body {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: block;
  font-weight: 600;
  line-height: 1.45;
}

.row-sub {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-3);
  line-height: 1.5;
}

.row-end {
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--fs-sm);
}

.row-end svg {
  width: 18px;
  height: 18px;
}

/* ---------- عنوان بخش ---------- */
.section {
  margin-top: var(--s8);
}

.section:first-child {
  margin-top: var(--s4);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s3);
}

.section-title {
  font-size: var(--fs-lg);
  font-weight: 800;
}

.section-link {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent-text);
  padding: var(--s2) 0;
}

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.muted {
  color: var(--text-3);
}

.text-2 {
  color: var(--text-2);
}

/* ---------- فرم ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field + .field {
  margin-top: var(--s4);
}

.label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-2);
}

.hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 52px;
  padding: 0 var(--s4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--text);
  transition: border-color var(--t-fast) ease, background-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
  appearance: none;
  -webkit-appearance: none;
}

.textarea {
  min-height: 120px;
  padding: var(--s3) var(--s4);
  resize: vertical;
  line-height: 1.8;
}

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E9095' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 18px;
  background-position: left 14px center;
  padding-inline-end: 40px;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-disabled);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  background: var(--surface-1);
  box-shadow: 0 0 0 4px var(--accent-softer);
}

.input.is-invalid {
  border-color: var(--err);
}

.input-wrap {
  position: relative;
}

.input-wrap > svg {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-3);
  pointer-events: none;
}

.input-wrap > .input {
  padding-inline-start: 44px;
}

.input-suffix {
  position: absolute;
  inset-inline-end: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--fs-sm);
  color: var(--text-3);
  pointer-events: none;
}

/* کلید روشن/خاموش */
.switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  transition: background-color var(--t) var(--ease);
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-1);
  transition: transform var(--t) var(--ease-spring);
}

.switch input:checked + span {
  background: var(--ok);
}

.switch input:checked + span::after {
  transform: translateX(-20px);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* کنترل تب‌دار */
.segmented {
  display: flex;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  position: relative;
}

.segmented button {
  flex: 1;
  min-height: 38px;
  border-radius: 9px;
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-3);
  transition: color var(--t-fast) ease, background-color var(--t) var(--ease);
}

.segmented button[aria-selected="true"] {
  background: var(--surface-1);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

[data-theme="light"] .segmented button[aria-selected="true"] {
  background: #fff;
}

/* تب‌های خطی (پروفایل) */
.tabs {
  display: flex;
  gap: var(--s6);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs button {
  position: relative;
  padding: var(--s3) 0;
  font-weight: 700;
  color: var(--text-3);
  white-space: nowrap;
}

.tabs button[aria-selected="true"] {
  color: var(--text);
}

.tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  bottom: -1px;
  inset-inline: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

/* OTP */
.otp {
  display: flex;
  gap: var(--s2);
  direction: ltr;
  justify-content: center;
}

.otp input {
  width: 48px;
  height: 56px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid transparent;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  caret-color: var(--accent);
  transition: border-color var(--t-fast) ease, transform var(--t-fast) var(--ease);
}

.otp input:focus {
  border-color: var(--accent);
  background: var(--surface-1);
}

.otp input.filled {
  transform: scale(1.04);
}

/* پیشرفت */
.progress {
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--t-slow) var(--ease);
}

.ring {
  --p: 0;
  --c: var(--accent);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ring::before {
  content: attr(data-label);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-1);
  font-size: var(--fs-sm);
  font-weight: 800;
}

/* ---------- شیت پایین صفحه ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--scrim);
  opacity: 0;
  transition: opacity var(--t) ease;
}

.sheet-backdrop.is-open {
  opacity: 1;
}

.sheet {
  position: fixed;
  z-index: 201;
  inset-inline: 0;
  bottom: 0;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  transform: translateY(100%);
  transition: transform var(--t-slow) var(--ease);
  padding-bottom: var(--safe-bottom);
  outline: none;
}

.sheet.is-open {
  transform: translateY(0);
}

.sheet-grip {
  display: grid;
  place-items: center;
  height: 24px;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}

.sheet-grip::before {
  content: "";
  width: 40px;
  height: 5px;
  border-radius: 5px;
  background: var(--surface-3);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 0 var(--s4) var(--s3);
  flex-shrink: 0;
}

.sheet-title {
  font-size: var(--fs-lg);
  font-weight: 800;
}

.sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 var(--s4) var(--s4);
}

.sheet-foot {
  display: flex;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .sheet {
    inset-inline: auto;
    left: 50%;
    bottom: auto;
    top: 50%;
    width: min(520px, calc(100vw - 48px));
    max-height: min(720px, calc(100dvh - 64px));
    border-radius: var(--r-xl);
    transform: translate(-50%, -46%) scale(0.98);
    opacity: 0;
    transition: transform var(--t) var(--ease), opacity var(--t) ease;
    padding-bottom: 0;
  }

  .sheet.is-open {
    transform: translate(-50%, -50%);
    opacity: 1;
  }

  .sheet-grip {
    height: 12px;
  }

  .sheet-grip::before {
    display: none;
  }
}

/* ---------- توست ---------- */
.toast-host {
  position: fixed;
  z-index: 300;
  inset-inline: 0;
  top: calc(var(--safe-top) + 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  pointer-events: none;
  padding: 0 var(--gutter);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: 440px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 700;
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toastIn var(--t) var(--ease) both;
}

.toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast.is-ok svg { color: var(--ok); }
.toast.is-err svg { color: var(--err); }

[data-theme="light"] .toast.is-ok svg { color: #7ee2b4; }
[data-theme="light"] .toast.is-err svg { color: #ff9aac; }

.toast.is-leaving {
  animation: toastOut var(--t) ease both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ---------- اسکلتون ---------- */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* ---------- حالت خالی ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s3);
  padding: var(--s10) var(--s6);
}

.empty-art {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-1);
  color: var(--text-3);
  margin-bottom: var(--s2);
}

.empty-art svg {
  width: 40px;
  height: 40px;
}

.empty h3 {
  font-size: var(--fs-lg);
}

.empty p {
  color: var(--text-3);
  max-width: 320px;
  font-size: var(--fs-sm);
}

/* ---------- آمار ---------- */
.stat {
  background: var(--surface-1);
  border-radius: var(--r-lg);
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label svg {
  width: 14px;
  height: 14px;
}

.stat-value {
  font-size: var(--fs-xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.stat-delta {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ok);
}

.stat-delta.down {
  color: var(--err);
}

/* ---------- تصویر رسانه با نسبت ثابت ---------- */
.media {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}

.media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity var(--t-slow) ease, transform 600ms var(--ease);
}

.media > img[data-loading] {
  opacity: 0;
}

/* ---------- جداکننده ---------- */
.divider {
  height: 1px;
  background: var(--line);
  margin: var(--s4) 0;
}

.or-sep {
  display: flex;
  align-items: center;
  gap: var(--s3);
  color: var(--text-3);
  font-size: var(--fs-sm);
  margin: var(--s4) 0;
}

.or-sep::before,
.or-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- گزینه‌های انتخابی بزرگ (ویزارد) ---------- */
.option {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 60px;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--surface-1);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: start;
  font-weight: 600;
  transition: box-shadow var(--t-fast) ease, background-color var(--t-fast) ease, transform var(--t-fast) var(--ease);
}

.option + .option {
  margin-top: var(--s2);
}

.option:active {
  transform: scale(0.985);
}

.option .option-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-2);
  flex-shrink: 0;
}

.option .option-icon svg {
  width: 22px;
  height: 22px;
}

.option .option-check {
  margin-inline-start: auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--line-strong);
  display: grid;
  place-items: center;
  color: transparent;
  flex-shrink: 0;
}

.option .option-check svg {
  width: 14px;
  height: 14px;
}

.option[aria-checked="true"] {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: var(--accent-softer);
}

.option[aria-checked="true"] .option-check {
  background: var(--accent);
  box-shadow: none;
  color: #fff;
}

.option[aria-checked="true"] .option-icon {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ---------- دکمه شناور ---------- */
.fab {
  position: fixed;
  z-index: 60;
  inset-inline-start: var(--gutter);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  height: 56px;
  padding: 0 var(--s5);
  border-radius: var(--r-lg);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow-2);
  transition: transform var(--t-fast) var(--ease);
}

.fab svg {
  width: 22px;
  height: 22px;
}

.fab:active {
  transform: scale(0.95);
}
