/* ===== صفحه خرید و فروش ===== */
:root{
  --surface-2: #141B1F;       /* brand guide: --surface-2 */
  --border-strong: #2A353A;   /* brand guide: --border-strong */
  --market-up: #2FD98A;
  --market-down: #FF5C6C;
  --success: #2FD98A;
  --warning: #EF921C;
  --error: #E5484D;
  --pending: #9FACA9;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

.num{ font-variant-numeric: tabular-nums; }
.mono{ font-family: var(--mono); }
.btn-sm{ padding: 8px 16px; font-size: 13px; }

/* ===== سرتیتر و ۲. چیپ احراز هویت ===== */
.trade-main{ padding-top: 8px; padding-bottom: 48px; }
.trade-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 16px;
}
.trade-head h1{ font-size: 24px; }

.kyc-chip{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid currentColor;
}
.kyc-chip::before{
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.kyc-chip[data-state="none"]{ color: var(--warning); }
.kyc-chip[data-state="pending"]{ color: var(--pending); }
.kyc-chip[data-state="pending"]::before{ animation: pulse 1.2s ease-in-out infinite; }
.kyc-chip[data-state="verified"]{ color: var(--success); pointer-events: none; }
.kyc-chip[data-state="rejected"]{ color: var(--error); }
.kyc-chip b{ font-weight: normal; text-decoration: underline; }
@keyframes pulse{ 50%{ opacity: .25; } }

/* ===== ۱۳. بنر پیش‌نویس ===== */
.draft-banner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.draft-banner[hidden]{ display: none; }
.draft-banner > div{ display: flex; gap: 8px; }
.draft-time{ color: var(--text-muted); font-size: 12.5px; }

/* ===== چیدمان دوستونه ===== */
.trade-layout{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.trade-card{
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ۳. انتخاب جهت */
.direction{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  margin-bottom: 22px;
}
.direction-btn{
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: bold;
  font-size: 15px;
  color: var(--text-muted);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.direction-btn.is-active{
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}
.direction-btn.is-active svg{ color: var(--accent); }

/* فیلدها */
.field{ margin-bottom: 18px; }
.field > label, .label-row label, .dest .field > label{
  display: block;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.label-row{ display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-hint{ font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.field-hint:empty{ display: none; }
.field-hint-accent{ color: var(--accent); }
.field-error{ font-size: 12.5px; color: var(--error); margin-top: 6px; }
.field-error:empty{ display: none; }

.amount-input, .wallet-input, .sheba-input{
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  height: 56px;
  transition: border-color .2s ease;
}
.amount-input:focus-within, .wallet-input:focus-within, .sheba-input:focus-within{ border-color: var(--accent); }
.is-invalid{ border-color: var(--error) !important; }

.amount-input input, .wallet-input input, .sheba-input input{
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  font-weight: 500;
  direction: ltr;
  text-align: left;
}
.wallet-input input, .sheba-input input{ font-family: var(--mono); font-size: 15px; }
.wallet-input input::placeholder{ font-family: 'Yekan', Tahoma, sans-serif; font-size: 14px; text-align: right; direction: rtl; }
.amount-unit, .sheba-prefix{
  flex-shrink: 0;
  font-size: 14px;
  font-weight: bold;
  color: var(--text-muted);
}
.sheba-input{ flex-direction: row-reverse; }
.sheba-prefix{ font-family: var(--mono); }

.swap-btn{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: -6px auto 12px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  transition: transform .2s ease;
}
.swap-btn:hover{ transform: rotate(180deg); }

/* ۵. نرخ زنده */
.rate-box{
  padding: 16px;
  margin-bottom: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}
.rate-main{ display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.rate-label{ font-size: 13px; color: var(--text-muted); width: 100%; }
.rate-value{ font-size: 44px; font-weight: bold; line-height: 1.2; min-width: 6ch; }
.rate-unit{ font-size: 14px; color: var(--text-muted); }
.rate-meta{ display: flex; gap: 16px; font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.rate-change.is-up{ color: var(--market-up); }
.rate-change.is-down{ color: var(--market-down); }
.rate-note{ font-size: 12.5px; color: var(--accent); margin-top: 8px; }
.rate-error{ font-size: 13px; color: var(--error); margin-top: 8px; }
.rate-box.is-loading .rate-value{
  color: transparent;
  background: linear-gradient(90deg, var(--card-bg), var(--surface-2), var(--card-bg));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border-radius: 8px;
}
@keyframes shimmer{ to{ background-position: -200% 0; } }
.link-btn{ color: var(--accent); text-decoration: underline; font-size: 13px; }

/* ۶. شبکه و آدرس */
.dest{ border: none; margin: 0; padding: 0; min-width: 0; }
.dest[hidden]{ display: none; }
.network-list{ display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.network-opt{
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 56px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: right;
  transition: border-color .2s ease;
}
.network-opt strong{ font-size: 14px; direction: ltr; }
.network-opt span{ font-size: 12px; color: var(--text-muted); }
.network-opt.is-active{ border-color: var(--accent); background: var(--surface-2); }

.saved-select, .select{
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  padding: 4px 8px;
  max-width: 55%;
}
.select{ width: 100%; max-width: none; height: 48px; font-size: 14px; padding: 0 12px; border-radius: var(--radius-sm); }

.icon-btn{
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
}
.icon-btn:hover{ color: var(--accent); background: var(--card-bg); }
.qr-btn{ display: none; }
.mono-preview{ direction: ltr; text-align: left; font-family: var(--mono); color: var(--text); }
.mono-preview b{ color: var(--accent); font-weight: normal; }

.check{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 18px;
}
.check input{ width: 16px; height: 16px; accent-color: var(--accent); }

/* تأیید مقصد جدید با کد پیامکی */
.verify-box{
  margin: -6px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: 13px;
}
.verify-box[hidden]{ display: none; }
.verify-text{ color: var(--text-muted); margin-bottom: 10px; }
.verify-row{ display: flex; gap: 8px; align-items: center; }
.verify-code{
  width: 140px;
  height: 40px;
  padding: 0 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 4px;
  direction: ltr;
  text-align: center;
  outline: none;
}
.verify-code:focus{ border-color: var(--accent); }
.verify-code[hidden], .verify-row button[hidden]{ display: none; }
.verify-timer{ font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.verify-timer:empty{ display: none; }
.verify-box.is-done{ border-color: var(--success); color: var(--success); }
.btn:disabled{ opacity: .5; cursor: not-allowed; }

/* ۷. کارت حساب بانکی */
.account-card{
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.account-card[hidden]{ display: none; }
.account-bank{ font-weight: bold; }
.account-owner{ color: var(--text-muted); }
.account-owner.is-ok{ color: var(--success); }
.account-owner.is-bad{ color: var(--error); }
.account-sheba{ color: var(--text-muted); text-align: left; }

/* ۱۰. دروازه احراز هویت */
.kyc-gate{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  background: rgba(239, 146, 28, .06);
  font-size: 13.5px;
}
.kyc-gate[hidden]{ display: none; }
.kyc-gate .btn{ flex-shrink: 0; }

/* ۹. دکمه اقدام */
.action-bar{ display: flex; align-items: center; gap: 12px; }
.action-total{ display: none; }
.action-btn{ flex: 1; height: 48px; font-size: 16px; }
.action-btn svg{ margin-inline-start: auto; }
.action-btn:disabled{ opacity: .45; cursor: not-allowed; transform: none; }
.action-reason{ font-size: 12.5px; color: var(--text-muted); text-align: center; margin-top: 8px; }
.action-reason:empty{ display: none; }

.risk-note{ font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 14px; }
.risk-note a{ color: var(--accent); }

/* ===== ستون کناری ===== */
.trade-side{ position: sticky; top: 88px; display: flex; flex-direction: column; gap: 16px; }

.summary-card{
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.summary-card summary{ font-weight: bold; font-size: 16px; cursor: pointer; list-style: none; }
.summary-card summary::-webkit-details-marker{ display: none; }
.summary-list{ margin-top: 12px; }
.summary-list > div{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 13.5px;
}
.summary-list > div:last-child{ border-bottom: none; }
.summary-list > div[hidden]{ display: none; }
.summary-list dt{ color: var(--text-muted); flex-shrink: 0; }
.summary-list dd{ text-align: left; word-break: break-all; }
.summary-total dd{ color: var(--accent); font-weight: bold; font-size: 15px; }

.trust-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text-muted);
}
.trust-list li{ display: flex; align-items: flex-start; gap: 8px; }
.trust-list svg{ flex-shrink: 0; color: var(--accent); margin-top: 3px; }
.trust-list li[hidden]{ display: none; }
.trust-list a{ color: var(--accent); }


/* ===== موبایل ===== */
@media (max-width: 900px){
  .trade-layout{ grid-template-columns: 1fr; }
  .trade-side{ position: static; }
  .trade-card{ padding: 18px 16px; }
  .container{ padding: 0 16px; }
  .network-list{ grid-template-columns: 1fr; }
  .network-opt{ min-height: 48px; flex-direction: row; justify-content: space-between; align-items: center; }
  .qr-btn{ display: flex; }
  .rate-value{ font-size: 34px; }

  /* نوار اقدام چسبان با مبلغ نهایی */
  .action-bar{
    position: sticky;
    bottom: 0;
    z-index: 50;
    margin: 0 -16px;
    padding: 10px 16px;
    background: rgba(12, 17, 20, .96);
    border-top: 1px solid var(--card-border);
  }
  .action-total{ display: flex; flex-direction: column; font-size: 11.5px; color: var(--text-muted); }
  .action-total strong{ font-size: 15px; color: var(--text); }
  .action-btn{ height: 52px; }
}
