/* ─────────────────────────────────────────────────────────────────
 * Money Cell · атомарный компонент денег в UZS
 *
 * Используется на: B7 (новая заявка, итог), B9 (placement detail),
 * C4 (входящие, payout), C6 (earnings), D1/D5/D8 (admin tables).
 *
 * Принцип:
 * - числа в Sora tnum (таблица моноширных цифр)
 * - валюта ВСЕГДА с числом (12 500 000 so'm, не 12 500 000)
 * - 3 размера: lg (итог), md (таблица), sm (inline)
 * - 3 знака: + (поступление, --color-success-fg), − (списание, --color-danger-fg),
 *   ничего (нейтральная, --color-ink)
 * - 3 контекста: amount (база), fee (комиссия), total (итого с меткой)
 * - 3 состояния: value · loading (skeleton) · error (muted)
 *
 * Цвет берём через [data-state] — без utility-модификаторов.
 * ───────────────────────────────────────────────────────────────── */

.money-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-num);
  font-feature-settings: 'tnum' 1, 'ss01' 1;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-ink);
  white-space: nowrap;
  vertical-align: baseline;
}

.money-cell__sign {
  font-family: var(--font-num);
  font-weight: 500;
  font-size: 0.85em;
  /* letter-spacing нужен для визуального центрирования +/− */
  min-width: 0.6em;
  display: inline-block;
  text-align: center;
}

/* знаки (только цвет, не размер) */
.money-cell[data-sign="plus"] { color: var(--color-success); }
.money-cell[data-sign="minus"] { color: var(--color-danger); }
.money-cell[data-sign="plus"] .money-cell__sign { color: var(--color-success); }
.money-cell[data-sign="minus"] .money-cell__sign { color: var(--color-danger); }

/* 3 размера */
.money-cell--lg {
  font-size: 24px;
  line-height: 1.1;
}
.money-cell--md {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 500;
}
.money-cell--sm {
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
}

.money-cell__amount {
  font-feature-settings: 'tnum' 1, 'ss01' 1;
  /* неразрывный пробел после суммы — защита от переноса «сум» */
  white-space: nowrap;
}

.money-cell__currency {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.55em;
  letter-spacing: 0;
  color: var(--color-ink-2);
  /* поднимаем валюту чуть выше — на cap-height,
     чтобы визуально садилась на базовую линию цифр */
  position: relative;
  top: -0.05em;
}
:root[data-theme="dark"] .money-cell__currency {
  color: var(--color-ink-3);
}

/* в нейтральном (без знака) и для total — валюта чуть ярче */
.money-cell[data-sign="none"] .money-cell__currency {
  color: var(--color-ink-2);
}

/* === context: total (с меткой «итого») === */
.money-cell--total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  /* визуально крупнее и плотнее, чем базовая amount */
  padding-top: 6px;
  border-top: 1px solid var(--color-divider);
  margin-top: 6px;
}
.money-cell--total .money-cell__label {
  /* на мобиле (<=360px) label уходит на свой ряд, сумма — на свой */
  flex: 1 1 100%;
  min-width: 0;
}
.money-cell--total .money-cell__value {
  /* обёртка amount+currency: не разрывать «1 248 500 сум» */
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-left: auto;
  min-width: 0;
  flex: 0 1 auto;
}
:root[data-theme="dark"] .money-cell--total {
  border-top-color: var(--color-divider-dark);
}
.money-cell__label {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.6em;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  margin-right: 8px;
  /* justify-self: start в grid; для inline-flex — display: flex родитель */
}

/* === context: fee (комиссия) === */
.money-cell--fee {
  font-weight: 500;
  color: var(--color-ink-2);
}
.money-cell--fee .money-cell__currency { color: var(--color-ink-3); }
.money-cell--fee[data-sign="plus"] { color: var(--color-success); }
.money-cell--fee[data-sign="minus"] { color: var(--color-danger); }

/* === состояния === */

/* loading — скелетон из ширины текста, не spinner */
.money-cell[data-state="loading"] {
  color: transparent;
  position: relative;
  pointer-events: none;
}
.money-cell[data-state="loading"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-muted-bg);
  border-radius: var(--radius-sm);
  opacity: 0.6;
  animation: money-cell-skeleton 1.4s ease-in-out infinite;
}
@keyframes money-cell-skeleton {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

/* error — muted + зачёркивание не нужно, просто без знака и muted */
.money-cell[data-state="error"] {
  color: var(--color-ink-3);
  font-style: italic;
}
.money-cell[data-state="error"] .money-cell__sign,
.money-cell[data-state="error"] .money-cell__currency {
  display: none;
}

/* === dark theme === */
:root[data-theme="dark"] .money-cell {
  color: var(--color-ink);
}
:root[data-theme="dark"] .money-cell[data-sign="plus"] { color: var(--color-success); }
:root[data-theme="dark"] .money-cell[data-sign="minus"] { color: var(--color-danger); }
:root[data-theme="dark"] .money-cell[data-state="loading"]::before {
  background: var(--color-muted-bg);
  opacity: 0.4;
}

/* === таблица — money-cell в td/tr === */
td .money-cell,
th .money-cell {
  vertical-align: baseline;
}

/* tabular align — для таблиц */
.money-cell[data-align="right"] {
  display: inline-flex;
  justify-content: flex-end;
}

/* === i18n — рубль/сум отображается в RU/UZ строке, но в CTX данных всегда «сум»/«so'm»,
   data-text обрабатывается JS, который перепишет currency === */
