/* Компаратор «Белый обмен» — cryptozakon.ru
   Визуальный язык сайта: графит, светлый редакционный фон, бирюзовый акцент,
   умеренный фиолетовый. Без монет, неона, торговых графиков и элементов казино.
   Токены дублируются с фолбэком, чтобы компонент работал и автономно (прототип),
   и внутри сайта, где переменные уже объявлены в styles.css. */

.xc {
  --xc-bg: var(--bg, #f7f9fa);
  --xc-surface: var(--surface, #ffffff);
  --xc-surface-soft: var(--surface-soft, #f0f3f5);
  --xc-surface-accent: var(--surface-accent, #e8f5f4);
  --xc-brand: var(--brand, #0f2733);
  --xc-text: var(--text, #16303d);
  --xc-text-2: var(--text-2, #5f6873);
  --xc-border: var(--border, #e1e5ea);
  --xc-accent: var(--accent, #168c91);
  --xc-accent-strong: var(--accent-strong, #0d7176);
  --xc-crypto: var(--crypto, #6c4cff);
  --xc-crypto-soft: var(--crypto-soft, #f0ecff);
  --xc-radius: var(--radius-md, 14px);
  --xc-radius-lg: var(--radius-lg, 20px);
  color: var(--xc-text);
}

:root[data-theme="dark"] .xc,
.xc[data-theme="dark"] {
  --xc-bg: #0e161c;
  --xc-surface: #142129;
  --xc-surface-soft: #192a34;
  --xc-surface-accent: #123238;
  --xc-brand: #eef3f5;
  --xc-text: #eef3f5;
  --xc-text-2: #aab6bd;
  --xc-border: #2b3c46;
  --xc-crypto-soft: #1d1b3a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .xc {
    --xc-bg: #0e161c;
    --xc-surface: #142129;
    --xc-surface-soft: #192a34;
    --xc-surface-accent: #123238;
    --xc-brand: #eef3f5;
    --xc-text: #eef3f5;
    --xc-text-2: #aab6bd;
    --xc-border: #2b3c46;
    --xc-crypto-soft: #1d1b3a;
  }
}

/* ── Форма направления ──────────────────────────────────────────────── */

.xc-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) minmax(160px, 0.8fr);
  gap: 14px;
  align-items: end;
  padding: 22px 24px;
  border: 1px solid color-mix(in srgb, var(--xc-accent) 24%, var(--xc-border));
  border-radius: var(--xc-radius-lg);
  background: linear-gradient(140deg, var(--xc-surface), var(--xc-surface-accent));
}

.xc-field { display: grid; gap: 6px; min-width: 0; }
.xc-field label { font-size: .82rem; font-weight: 700; color: var(--xc-text-2); }
.xc-field select,
.xc-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--xc-border);
  border-radius: var(--xc-radius);
  background: var(--xc-surface);
  color: var(--xc-text);
  font: 600 .98rem/1.4 inherit;
}
.xc-field select:focus-visible,
.xc-field input:focus-visible,
.xc-swap:focus-visible,
.xc-controls select:focus-visible,
.xc-controls input:focus-visible,
.xc-registry-link:focus-visible {
  outline: 2px solid var(--xc-accent);
  outline-offset: 2px;
}
.xc-field-hint { font-size: .76rem; color: var(--xc-text-2); font-weight: 500; }
.xc-error { min-height: 1.1em; color: #b3261e; font-size: .78rem; font-weight: 650; }
:root[data-theme="dark"] .xc-error { color: #ff9a90; }

.xc-swap {
  align-self: end;
  width: 46px;
  height: 46px;
  margin-bottom: 2px;
  border: 1px solid var(--xc-border);
  border-radius: 50%;
  background: var(--xc-surface);
  color: var(--xc-accent-strong);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease;
}
.xc-swap:hover:not(:disabled) { border-color: var(--xc-accent); transform: rotate(180deg); }
/* Обратное направление бывает недоступно (в MVP операторы публикуют только
   рубли → криптовалюта): кнопка честно выключается, а не молчит при клике. */
.xc-swap:disabled { opacity: .45; cursor: not-allowed; }

/* ── Фильтры ────────────────────────────────────────────────────────── */

.xc-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: end;
  margin: 16px 0 8px;
  padding: 16px 20px;
  border: 1px solid var(--xc-border);
  border-radius: var(--xc-radius);
  background: var(--xc-surface);
}
.xc-controls .xc-field { flex: 0 1 190px; }
.xc-check { display: flex; gap: 8px; align-items: center; font-size: .85rem; font-weight: 650; color: var(--xc-text-2); }
.xc-check input { width: 18px; height: 18px; accent-color: var(--xc-accent); }

/* ── Служебные строки ───────────────────────────────────────────────── */

.xc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: space-between;
  margin: 14px 0;
  font-size: .85rem;
  color: var(--xc-text-2);
}
.xc-summary { font-weight: 700; color: var(--xc-text); }

.xc-disclaimer {
  margin: 12px 0 20px;
  padding: 14px 18px;
  border-left: 3px solid var(--xc-crypto);
  border-radius: 0 var(--xc-radius) var(--xc-radius) 0;
  background: var(--xc-crypto-soft);
  color: var(--xc-text-2);
  font-size: .86rem;
}
.xc-disclaimer strong { color: var(--xc-text); }

/* ── Таблица ────────────────────────────────────────────────────────── */

.xc-table-wrap { overflow-x: auto; }
.xc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  font-size: .9rem;
}
.xc-table caption {
  padding-bottom: 10px;
  color: var(--xc-text-2);
  font-size: .82rem;
  text-align: left;
}
.xc-table th {
  padding: 8px 12px;
  color: var(--xc-text-2);
  font-size: .76rem;
  font-weight: 750;
  letter-spacing: .03em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.xc-table td {
  padding: 12px 10px;
  border-top: 1px solid var(--xc-border);
  border-bottom: 1px solid var(--xc-border);
  background: var(--xc-surface);
  vertical-align: top;
}
.xc-table td:first-child { border-left: 1px solid var(--xc-border); border-radius: var(--xc-radius) 0 0 var(--xc-radius); }
.xc-table td:last-child { border-right: 1px solid var(--xc-border); border-radius: 0 var(--xc-radius) var(--xc-radius) 0; }
.xc-table tbody tr:first-child td { border-color: color-mix(in srgb, var(--xc-accent) 42%, var(--xc-border)); }
.xc-table tbody tr:first-child .xc-cell-receive strong { color: var(--xc-accent-strong); }

.xc-cell-receive strong { font-size: 1.12rem; }
.xc-amount { display: grid; gap: 2px; }
.xc-amount strong { font-variant-numeric: tabular-nums; }
.xc-asset { color: var(--xc-text-2); font-size: .78rem; }

.xc-exchange { display: grid; gap: 1px; min-width: 130px; }
.xc-exchange-give { color: var(--xc-text-2); font-size: .85rem; font-variant-numeric: tabular-nums; }
.xc-exchange-give .xc-asset { margin-left: 4px; font-size: .76rem; }
.xc-exchange-arrow { color: var(--xc-text-2); font-size: .74rem; line-height: 1; }
.xc-exchange-receive strong { font-size: 1.08rem; font-variant-numeric: tabular-nums; }
.xc-exchange-receive .xc-asset { margin-left: 4px; }
.xc-conditions { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; color: var(--xc-text-2); font-size: .82rem; }

.xc-operator { display: grid; gap: 4px; min-width: 168px; max-width: 220px; }
.xc-operator-name { line-height: 1.3; font-size: .88rem; }
.xc-operator-domain, .xc-operator-verified { color: var(--xc-text-2); font-size: .76rem; }
.xc-status {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  width: fit-content;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--xc-surface-accent);
  color: var(--xc-accent-strong);
  font-size: .72rem;
  font-weight: 750;
  white-space: nowrap;
}
/* Статус читается и без цвета: значок + текст. */
.xc-status-mark { font-weight: 800; }
.xc-registry-link { color: var(--xc-accent-strong); font-size: .78rem; font-weight: 700; }
.xc-registry-missing { color: #b3261e; font-size: .76rem; font-weight: 650; }

.xc-fees { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; color: var(--xc-text-2); font-size: .82rem; }
.xc-fresh { display: grid; gap: 2px; font-size: .8rem; color: var(--xc-text-2); }
.xc-fresh strong { font-size: .82rem; color: var(--xc-text); }
.xc-fresh-fresh strong { color: var(--xc-accent-strong); }
.xc-fresh-until { font-size: .74rem; }

.xc-row-limited td { opacity: .72; }
.xc-row-note-row td {
  padding: 8px 14px;
  border: 1px dashed var(--xc-border);
  border-radius: var(--xc-radius);
  background: var(--xc-surface-soft);
  color: var(--xc-text-2);
  font-size: .82rem;
}

/* ── Пустые состояния ───────────────────────────────────────────────── */

.xc-state {
  padding: 28px 26px;
  border: 1px solid var(--xc-border);
  border-radius: var(--xc-radius-lg);
  background: var(--xc-surface);
}
.xc-state h3 { margin: 0 0 8px; font-size: 1.2rem; }
.xc-state p { margin: 0 0 8px; color: var(--xc-text-2); }
.xc-state-next { font-weight: 650; color: var(--xc-text); }

/* ── Мобильная версия: строки превращаются в карточки ───────────────── */

@media (max-width: 900px) {
  .xc-form { grid-template-columns: 1fr; }
  .xc-swap { justify-self: start; transform: rotate(90deg); }
  .xc-swap:hover { transform: rotate(270deg); }
  .xc-table { border-spacing: 0; }
  .xc-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .xc-table tr { display: block; margin-bottom: 12px; }
  .xc-table td {
    display: grid;
    grid-template-columns: minmax(96px, 40%) minmax(0, 1fr);
    gap: 12px;
    border: 0;
    border-bottom: 1px solid var(--xc-border);
    border-radius: 0;
  }
  .xc-table tr td:first-child { border-radius: var(--xc-radius) var(--xc-radius) 0 0; border-top: 1px solid var(--xc-border); }
  .xc-table tr td:last-child { border-radius: 0 0 var(--xc-radius) var(--xc-radius); }
  .xc-table td::before {
    content: attr(data-label);
    color: var(--xc-text-2);
    font-size: .76rem;
    font-weight: 700;
  }
  .xc-table td:first-child,
  .xc-table td:last-child { border-left: 1px solid var(--xc-border); border-right: 1px solid var(--xc-border); }
  .xc-operator { max-width: none; }
  .xc-row-note-row td { grid-template-columns: 1fr; }
  .xc-row-note-row td::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  .xc-swap, .xc-swap:hover { transition: none; transform: none; }
}
