/* Sổ Vàng — thành phần dùng chung (Components.swift): thẻ, ô, nhãn trạng thái, dòng giao dịch, ô nhập, sheet,
   hộp hỏi, toast, màn che. Token ở app.css. */

/* ---------------------------------------------------------------- thẻ / ô */

.card {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-card);
}

.tile,
.quick-tile {
  background: var(--g-tile);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-control);
}

.quick-tile {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 4px;
  color: var(--text);
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
}

.quick-tile:active {
  opacity: 0.85;
  transform: scale(0.98);
}

.qt-ic {
  display: flex;
  align-items: center;
  color: var(--gold400);
}

.qt-label {
  font-weight: 500;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: 52px;
  padding: 0 14px;
  text-align: left;
}

.menu-row .body {
  flex: 1;
}

.segmented {
  display: flex;
  align-items: stretch;
  height: 44px;
  padding: 2px;
  background: var(--chip-bg);
  border: 1px solid var(--divider);
  border-radius: var(--r-control);
}

.seg {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  border-radius: var(--r-chip);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg.is-on {
  background: var(--g-gold-button);
  color: var(--on-gold);
  font-weight: 600;
}

.seg-div {
  width: 1px;
  margin: 8px 0;
  background: var(--divider);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: #a0a0a0;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.pill-unpaid { color: #e9c46a; background: rgba(233, 196, 106, 0.15); }
.pill-review,
.pill-pickup { color: #ffb547; background: rgba(255, 181, 71, 0.15); }
.pill-payout { color: #8db8ff; background: rgba(91, 155, 255, 0.17); }
.pill-done { color: #3fd46b; background: rgba(63, 212, 107, 0.14); }
.pill-rejected { color: #ff6b6d; background: rgba(255, 77, 79, 0.15); }

.tx-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.tx-buy { color: #8cffa8; background: var(--success-bg); }
.tx-sell { color: #ff8a8a; background: var(--danger-bg); }
.tx-gold { color: var(--gold300); background: #2b2312; }
.tx-info { color: #dde8ff; background: var(--info-bg); }

.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 0 12px;
}

.tx-main,
.tx-side {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tx-main { flex: 1; }
.tx-side { align-items: flex-end; }
.tx-title { font-size: 17px; font-weight: 600; }
.tx-sub { font-size: var(--fs-body-sm); color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-qty { font-size: 17px; font-weight: 700; color: var(--text); }
.tx-qty.is-credit { color: var(--success); }
.tx-qty.is-debit { color: var(--danger); }
.tx-qty.is-dead { color: var(--text3); }
.tx-chev { color: var(--text3); flex: none; }

.currency-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--g-gold-button);
  color: var(--on-gold);
  font-weight: 700;
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.info-label {
  flex: 1;
  font-size: 15px;
  color: var(--text2);
}

.info-value {
  font-size: 15px;
  font-weight: 600;
  text-align: right;
  user-select: text;
  -webkit-user-select: text;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 120px var(--side) 0;
}

.demo-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-chip);
  background: rgba(122, 30, 30, 0.85);
  border: 1px solid rgba(255, 77, 79, 0.6);
  color: #ffe3e3;
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: 1.35;
}

.demo-banner .ic {
  flex: none;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-chip);
  font-size: var(--fs-body-sm);
  line-height: 1.4;
}

.notice .ic {
  flex: none;
  margin-top: 1px;
}

.notice.tone-warn { color: var(--warn); background: rgba(255, 181, 71, 0.08); }
.notice.tone-danger { color: #ff8a8a; background: rgba(255, 77, 79, 0.1); }
.notice.tone-info { color: var(--text2); background: rgba(255, 255, 255, 0.04); }

/* ---------------------------------------------------------------- ô nhập (≥ 16px ⇒ Safari không tự phóng) */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
}

.field-input,
.qty-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  caret-color: var(--gold400);
  font-family: inherit;
}

.field-input {
  height: 52px;
  padding: 0 16px;
  font-size: 18px;
  font-weight: 500;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-control);
}

.field-input:focus,
.qty-field:focus-within {
  border-color: var(--gold400);
}

.qty-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 18px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--r-control);
}

.qty-field.is-error {
  border-color: var(--danger);
}

.qty-input {
  font-size: 26px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.qty-unit {
  font-size: 18px;
  font-weight: 500;
}

.call-copy {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call-copy .caption {
  flex: 1;
}

.call-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
}

/* ---------------------------------------------------------------- sheet / hộp hỏi / toast / che */

.sheet-wrap {
  position: absolute;
  inset: 0;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  animation: fade-in 0.2s ease-out;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: calc(var(--safe-top) + 10px);
  background: var(--bg);
  border-radius: 12px 12px 0 0;
  border-top: 1px solid var(--border-subtle);
  overflow: hidden;
  animation: slide-up 0.32s var(--ease);
}

.sheet.medium {
  top: auto;
  height: min(62%, 560px);
}

.sheet-scroll {
  height: 100%;
}

.sheet-frame {
  padding: 20px 20px calc(24px + var(--safe-bottom));
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.overlay-full {
  height: 100%;
  background: var(--g-login);
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  animation: fade-in 0.15s ease-out;
}

.dialog {
  width: 100%;
  max-width: 300px;
  overflow: hidden;
  border-radius: 14px;
  background: #1e1e1e;
  border: 1px solid var(--border-subtle);
  text-align: center;
  animation: pop-in 0.2s var(--ease);
}

.dialog-title {
  padding: 18px 16px 4px;
  font-size: 17px;
  font-weight: 600;
}

.dialog-msg {
  padding: 4px 16px 16px;
  font-size: var(--fs-caption);
  line-height: 1.4;
  color: var(--text2);
  white-space: pre-line;
}

.dialog-buttons {
  display: flex;
  border-top: 1px solid var(--divider);
}

.dialog-buttons.stack {
  flex-direction: column;
}

.dialog-btn {
  flex: 1;
  min-height: 46px;
  padding: 8px 12px;
  font-size: 16px;
  color: var(--gold400);
}

.dialog-buttons:not(.stack) .dialog-btn + .dialog-btn { border-left: 1px solid var(--divider); }
.dialog-buttons.stack .dialog-btn + .dialog-btn { border-top: 1px solid var(--divider); }
.dialog-btn.cancel { font-weight: 600; color: var(--text); }
.dialog-btn.destructive { color: var(--danger); }
.dialog-btn:active { background: rgba(255, 255, 255, 0.06); }

.layer-toast {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 24px calc(96px + var(--safe-bottom));
}

.toast {
  max-width: 100%;
  padding: 11px 16px;
  border-radius: 22px;
  background: rgba(30, 30, 30, 0.96);
  border: 1px solid var(--border-gold);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  animation: toast-in 0.2s ease-out;
}

.toast-out {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.layer-net {
  padding: calc(var(--safe-top) + 6px) 12px 6px;
  background: var(--danger-bg);
  color: #ffe3e3;
  font-size: var(--fs-caption);
  font-weight: 600;
  text-align: center;
}

.cover-inner {
  padding: 24px;
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }
@keyframes pop-in { from { opacity: 0; transform: scale(1.06); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sheet-backdrop,
  .dialog,
  .dialog-backdrop,
  .toast {
    animation: none;
  }
}
