/* Dark Sistem – صفحه‌ی مقایسه
   RTL · light + dark (روی توکن‌های main.css) · Breakpoints: ≤1023 · ≤860 (کارت) · ≤560 · ≤380
   ساختار: جدول برای دسکتاپ، کارت‌های عمودی برای تبلت/موبایل. هر دو از یک payload ساخته می‌شوند. */

.cmp-page { padding-block: clamp(1.1rem, 2.6vw, 2rem) clamp(2.4rem, 5vw, 4rem); }

/* ---------- breadcrumbs ---------- */
.cmp-page .crumbs { margin-bottom: clamp(1rem, 2.2vw, 1.6rem); }
.cmp-page .crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin: 0; padding: 0; list-style: none; font-size: .82rem; color: var(--muted); }
.cmp-page .crumbs li { display: inline-flex; align-items: center; gap: .45rem; }
.cmp-page .crumbs li + li::before { content: "‹"; font-size: 1rem; line-height: 1; color: var(--muted); opacity: .7; }
.cmp-page .crumbs a { color: var(--muted); }
.cmp-page .crumbs a:hover { color: var(--accent); }
.cmp-page .crumbs [aria-current="page"] { color: var(--text-strong); font-weight: 600; }

/* ---------- head ---------- */
.cmp-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; }
.cmp-head__text { max-width: 62ch; }
.cmp-head h1 { margin: .25rem 0 .35rem; font-family: var(--display); font-size: clamp(1.75rem, 4vw, 2.6rem); font-weight: 400; line-height: 1.25; color: var(--text-strong); }
.cmp-head__lead { margin: 0; font-size: clamp(.88rem, 1.4vw, .98rem); line-height: 2; color: var(--muted); }
.cmp-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.cmp-head .eyebrow { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .02em; color: var(--accent); }

/* دکمه‌ی ghost مخصوص این صفحه (btn--ghost سراسری برای پس‌زمینه‌های تیره است) */
.cmp-ghost { background: var(--surface-2); color: var(--text-strong); border: 1px solid var(--line); box-shadow: none; }
.cmp-ghost:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-2); filter: none; }

.cmp-clear { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.cmp-clear:hover { background: color-mix(in srgb, var(--red) 10%, transparent); color: var(--red); }

/* ---------- status / loading / states ---------- */
.cmp-status { min-height: 1.4rem; margin: .9rem 0 1rem; font-size: .84rem; font-weight: 600; color: var(--muted); }
.cmp-status b { color: var(--text-strong); }

.cmp-loading { display: grid; gap: .65rem; padding: clamp(1rem, 2.5vw, 1.5rem); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.cmp-loading[hidden] { display: none; }
.cmp-loading__row { display: grid; grid-template-columns: 140px repeat(3, minmax(0, 1fr)); gap: .65rem; }
.cmp-sk { height: 96px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: cmp-shimmer 1.3s ease-in-out infinite; }
.cmp-sk--label { height: 38px; align-self: center; }
@keyframes cmp-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.cmp-empty, .cmp-error {
  display: grid; justify-items: center; gap: .55rem; padding: clamp(1.6rem, 4vw, 3rem) 1.2rem; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r-lg); background: var(--surface);
}
.cmp-empty[hidden], .cmp-error[hidden] { display: none; }
.cmp-empty__icon { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: .25rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.cmp-empty__icon .i { width: 30px; height: 30px; }
.cmp-empty h2, .cmp-error h2 { margin: 0; font-size: clamp(1.05rem, 2.4vw, 1.3rem); font-weight: 800; color: var(--text-strong); }
.cmp-empty p, .cmp-error p { max-width: 52ch; margin: 0 0 .7rem; font-size: .88rem; line-height: 2; color: var(--muted); }

.cmp-note { display: flex; align-items: center; justify-content: center; gap: .45rem; margin: 1.4rem 0 0; font-size: .78rem; line-height: 1.9; color: var(--muted); text-align: center; }
.cmp-note .i { color: var(--accent); }

/* =========================================================
   Desktop table
   ========================================================= */
.cmp-root[hidden] { display: none; }
.cmp-scroll {
  overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
}
.cmp-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cmp-table { width: 100%; min-width: 700px; border-collapse: separate; border-spacing: 0; text-align: start; }
.cmp-table th, .cmp-table td { padding: .8rem 1rem; vertical-align: middle; }

.cmp-table thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); vertical-align: top; }
.cmp-table thead th:first-child { z-index: 4; }
.cmp-table tbody th {
  position: sticky; inset-inline-start: 0; z-index: 2; width: 168px; min-width: 168px;
  background: var(--surface-2); text-align: start; font-size: .82rem; font-weight: 700; color: var(--text-strong);
  border-bottom: 1px solid var(--line);
}
.cmp-table tbody td { min-width: 190px; font-size: .88rem; line-height: 1.85; color: var(--text); border-bottom: 1px solid var(--line); }
.cmp-table tbody tr:last-child th, .cmp-table tbody tr:last-child td { border-bottom: 0; }
.cmp-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.cmp-table td.is-best { color: #1f9d55; font-weight: 800; }
:root[data-theme="dark"] .cmp-table td.is-best { color: #4ade80; }
.cmp-table td.is-muted { color: var(--muted); }
.cmp-best {
  display: inline-block; margin-inline-start: .45rem; padding: .08rem .5rem; border-radius: 99px;
  background: rgba(31, 157, 85, .12); color: #1f9d55; font-size: .66rem; font-weight: 700; line-height: 1.8; vertical-align: middle;
}
:root[data-theme="dark"] .cmp-best { background: rgba(74, 222, 128, .14); color: #4ade80; }

/* header product cell */
.cmp-table th:first-child { width: 168px; }
.cmp-table thead th:first-child > span { display: block; padding-top: 5.4rem; font-size: .8rem; color: var(--muted); }
.cmp-th { position: relative; display: flex; flex-direction: column; align-items: center; gap: .35rem; min-width: 176px; padding-top: .2rem; text-align: center; }
.cmp-th__remove {
  position: absolute; top: -.15rem; inset-inline-end: -.2rem; display: grid; place-items: center;
  width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--muted); transition: color .18s, border-color .18s, background-color .18s;
}
.cmp-th__remove .i { width: 15px; height: 15px; }
.cmp-th__remove:hover { color: var(--red); border-color: var(--red); background: color-mix(in srgb, var(--red) 8%, var(--surface)); }
.cmp-th__img { display: block; width: 100%; aspect-ratio: 4 / 3; padding: .5rem; border-radius: 12px; background: var(--media-bg); }
.cmp-th__img img { width: 100%; height: 100%; object-fit: contain; }
.cmp-th__type { padding: .1rem .6rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .68rem; font-weight: 700; line-height: 1.8; }
.cmp-th__name { margin: 0; font-size: .92rem; font-weight: 700; line-height: 1.7; color: var(--text-strong); }
.cmp-th__name a:hover { color: var(--accent); }
.cmp-th__sub { margin: 0; font-size: .74rem; color: var(--muted); }
.cmp-th .btn { margin-top: .35rem; }
.cmp-th__actions { display: grid; gap: .35rem; width: 100%; margin-top: .4rem; }

/* =========================================================
   Mobile cards
   ========================================================= */
.cmp-cards { display: none; }
.cmp-card {
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow);
}
.cmp-card__head { position: relative; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: .8rem; padding: .85rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cmp-card__img { width: 96px; aspect-ratio: 1; padding: .35rem; border-radius: 12px; background: var(--media-bg); }
.cmp-card__img img { width: 100%; height: 100%; object-fit: contain; }
.cmp-card__body { min-width: 0; display: flex; flex-direction: column; gap: .25rem; padding-inline-end: 1.9rem; }
.cmp-card__type { align-self: flex-start; padding: .05rem .55rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .66rem; font-weight: 700; line-height: 1.8; }
.cmp-card__name { margin: 0; font-size: .92rem; font-weight: 700; line-height: 1.7; color: var(--text-strong); }
.cmp-card__sub { margin: 0; font-size: .74rem; color: var(--muted); }
.cmp-card__remove {
  position: absolute; top: .7rem; inset-inline-end: .7rem; display: grid; place-items: center;
  width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted);
}
.cmp-card__remove .i { width: 15px; height: 15px; }
.cmp-card__remove:hover { color: var(--red); border-color: var(--red); }
.cmp-card dl { margin: 0; }
.cmp-card dl > div { display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: .6rem; padding: .6rem .9rem; border-bottom: 1px solid var(--line); }
.cmp-card dl > div:last-child { border-bottom: 0; }
.cmp-card dl > div:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
.cmp-card dt { font-size: .78rem; font-weight: 700; color: var(--muted); }
.cmp-card dd { margin: 0; font-size: .85rem; line-height: 1.85; color: var(--text); }
.cmp-card dd.is-best { color: #1f9d55; font-weight: 800; }
:root[data-theme="dark"] .cmp-card dd.is-best { color: #4ade80; }
.cmp-card dd.is-muted { color: var(--muted); }
.cmp-card__actions { display: flex; gap: .5rem; padding: .8rem .9rem; border-top: 1px solid var(--line); }
.cmp-card__actions .btn { flex: 1; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1023px) {
  .cmp-table tbody th, .cmp-table th:first-child { width: 148px; min-width: 148px; }
  .cmp-table tbody td { min-width: 172px; }
  .cmp-table th, .cmp-table td { padding: .7rem .8rem; }
}

@media (max-width: 860px) {
  .cmp-scroll { display: none; }
  .cmp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: .9rem; }
  .cmp-head { align-items: flex-start; }
  .cmp-head__actions { width: 100%; }
  .cmp-head__actions .btn { flex: 1; justify-content: center; }
  .cmp-note { font-size: .74rem; }
}

@media (max-width: 560px) {
  .cmp-cards { grid-template-columns: minmax(0, 1fr); }
  .cmp-head h1 { font-size: 1.7rem; }
  .cmp-card { border-radius: 16px; }
  .cmp-empty, .cmp-error { border-radius: 16px; }
  .cmp-page .crumbs { font-size: .76rem; }
  .cmp-status { margin: .7rem 0 .8rem; }
}

@media (max-width: 380px) {
  .cmp-card__head { grid-template-columns: 76px minmax(0, 1fr); padding: .7rem; gap: .6rem; }
  .cmp-card__img { width: 76px; }
  .cmp-card dl > div { grid-template-columns: minmax(80px, 40%) minmax(0, 1fr); padding: .5rem .7rem; }
  .cmp-card__actions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .cmp-sk { animation: none; }
  .cmp-th__remove, .cmp-card__remove { transition: none; }
}

@media print {
  .cmp-head__actions, .cmp-th__remove, .cmp-card__remove, .cmp-card__actions, .cmp-note { display: none !important; }
  .cmp-scroll { overflow: visible; border: 0; box-shadow: none; }
  .cmp-table { min-width: 0; }
  .cmp-table thead th, .cmp-table tbody th { position: static; }
}
