/* ============================================
   Trades Endpoint — My Account / معاملات
   Mobile-First | Light Theme
   Breakpoints (هم‌تراز با trading.css):
   - پایه: 320px+ (موبایل)
   - @media (max-width: 579px) — تنظیمات ویژهٔ خیلی باریک
   - @media (min-width: 579px) — تبلت و بالاتر
   - @media (min-width: 1024px) — دسکتاپ
   - @media (max-width: 768px) and (orientation: landscape)
   - @media (min-width: 1400px) — صفحهٔ بزرگ
   ============================================ */

/* ============================================
   BASE STYLES — MOBILE (320px+)
   ============================================ */

/* ── Wrapper ── */
.trades-endpoint {
  width: 100%;
}

/* ── Ticker Bar ── */
.trades-ticker {
  background-color: transparent;
  border: none;
  border-radius: 0;
  margin-bottom: var(--spacing-xl);
  overflow: visible;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.trades-ticker__asset-bar {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-card);
  overflow: visible;
  position: relative;
}

/* Horizontally scrollable stats row */
.trades-ticker__scroll {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: stretch;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  min-height: 0;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-card);
  margin-top: var(--spacing-md);
}

.trades-ticker__scroll::-webkit-scrollbar {
  display: none;
}

/* ── Trading Pair ── */
.trades-ticker__asset-bar .trades-ticker__pair {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  width: 100%;
  min-width: 0;
  position: relative;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  border-bottom: none;
}

.trades-ticker__pair:hover {
  background-color: var(--color-bg-light);
}

.trades-ticker__asset-trigger {
  width: 100%;
  min-height: 72px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  text-align: right;
}

.trades-ticker__asset-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -3px;
  border-radius: var(--radius-card);
}

.trades-ticker__asset-select.is-open {
  background-color: var(--color-bg-light);
}

.trades-ticker__asset-select.is-open .trades-ticker__chevron {
  transform: rotate(180deg);
}

.trades-ticker__asset-menu {
  position: absolute;
  top: calc(100%);
  /* right: 8px; */
  width: 100%;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: 0px 0px var(--radius-card) var(--radius-card);
  /* box-shadow: var(--shadow-lg); */
  padding: 8px;
  z-index: 30;
}

.trades-ticker__asset-menu[hidden] {
  display: none;
}

.trades-ticker__asset-option {
  width: 100%;
  min-height: 50px;
  padding: 5px 12px;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: var(--radius-default);
  background: transparent;
  color: var(--color-text-primary);
  cursor: pointer;
  font-family: inherit;
  text-align: right;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.trades-ticker__asset-option:hover,
.trades-ticker__asset-option--active {
  background-color: var(--color-bg-light);
}

.trades-ticker__asset-option--active {
  color: var(--color-primary);
  font-weight: 700;
}

.trades-ticker__asset-option-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid var(--color-border-light);
  border-radius: 50%;
}

.trades-ticker__asset-option-icon img {
  width: 21px;
  height: 21px;
  display: block;
}

.trades-ticker__asset-option-text {
  font-size: 14px;
  line-height: 1.4;
}

.trades-ticker__asset-option-unit {
  padding: 4px 9px;
  border-radius: var(--radius-md);
  background: #f5f7fa;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* Overlapping coin icons */
.trades-ticker__pair-icons {
  position: relative;
  width: 48px;
  height: 46px;
  flex-shrink: 0;
}

.trades-ticker__coin {
  position: absolute;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: var(--color-bg-card);
  border: 1.5px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.trades-ticker__coin--back {
  right: 0;
  z-index: 1;
}

.trades-ticker__coin--front {
  right: 13px;
  z-index: 2;
}

.trades-ticker__coin--single {
  position: static;
  width: 46px;
  height: 46px;
  z-index: 1;
}

.trades-ticker__coin img {
  width: 26px;
  height: 26px;
  display: block;
}

/* Pair name + code */
.trades-ticker__pair-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trades-ticker__pair-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  line-height: 1.3;
}

.trades-ticker__pair-code {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-secondary);
  white-space: nowrap;
  line-height: 1.2;
  direction: rtl;
  text-align: right;
}

/* Chevron */
.trades-ticker__chevron {
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  transition: transform var(--transition-fast);
  margin-right: 2px;
}

.trades-ticker__pair:hover .trades-ticker__chevron {
  transform: translateY(2px);
}

/* ── Stats row ── */
.trades-ticker__stats {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.trades-ticker__stat {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  flex-shrink: 1;
  border-right: none;
  border-bottom: 1px solid var(--color-border-light);
  transition: background-color var(--transition-fast);
  order: 0;
}

.trades-ticker__stat:last-child {
  border-bottom: none;
}

.trades-ticker__stat:hover {
  background-color: var(--color-bg-light);
}

/* Stat label */
.trades-ticker__stat-label {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-secondary);
  line-height: 1.25;
  flex-wrap: wrap;
}

.trades-ticker__stat-title-inline {
  white-space: nowrap;
}

/* "24h" small tag */
.trades-ticker__stat-24h {
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-muted);
  background-color: rgba(0, 0, 0, 0.05);
  padding: 1px 4px;
  border-radius: var(--radius-md);
  letter-spacing: 0.02em;
  line-height: 1.4;
  flex-shrink: 0;
}

/* مقدار: فلکس LTR — عدد رشد می‌کند و راست‌چین؛ واحد عرض پایدار */
.trades-ticker__stat-val {
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: nowrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  direction: ltr;
}

.trades-ticker__stat-val .trades-ticker__stat-num {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.trades-ticker__stat-val .trades-ticker__stat-unit {
  flex: 0 0 auto;
  text-align: left;
}

/* موبایل: فلکس + عرض ثابت برای بلوک مقدار (بدون grid/table) */
@media (max-width: 578px) {
  
.trades-ticker__stat-val .trades-ticker__stat-unit {
  min-width: 1.4rem;
}
  .trades-ticker__stats {
    display: block;
    width: 100%;
  }

  .trades-ticker__stat {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    /* border-bottom: 1px solid var(--color-border-light); */
  }

  .trades-ticker__stat:last-child {
    border-bottom: none;
  }

  .trades-ticker__stat .trades-ticker__stat-label {
    padding: 0;
    border-bottom: none;
  }

  .trades-ticker__stat .trades-ticker__stat-val {
    flex: 0 0 clamp(9.5rem, 36vw, 12.75rem);
    width: clamp(9.5rem, 36vw, 12.75rem);
    min-width: 9.5rem;
    max-width: 12.75rem;
    padding: 0;
    border-bottom: none;
  }
}

.trades-ticker__stat-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

.trades-ticker__stat-unit {
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* High / Low / Change color variants */
.trades-ticker__stat-num--high {
  color: var(--color-status-positive);
}

.trades-ticker__stat-num--low {
  color: var(--color-status-error);
}

.trades-ticker__stat-num--down {
  color: var(--color-status-error);
}

.trades-ticker__stat-num--up {
  color: var(--color-status-positive);
}



/* ════════════════════════════════════════════════════════════════════════════
   MAIN TRADING PANEL
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Layout: موبایل = ستون (فرم بالا، دفتر سفارش پایین) ── */
.trades-main {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

/* ════════════════════════════════════════════════════════════════════════════
   ORDER BOOK  (nobitex exchange-order-list style, light theme)
   ════════════════════════════════════════════════════════════════════════════ */

.trades-orderbook {
  order: 2;
  width: 100%;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Trades chart ── */
#ayarkaTradesEndpoint .trades-chart-section {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border-top: 1px solid var(--color-border-light);
  /* جلوگیری از تداخل با chart.css داشبورد */
  height: auto !important;
  flex: none !important;
}

#ayarkaTradesEndpoint .trades-chart-section .chart-container {
  display: block;
  width: 100%;
  height: auto !important;
  flex: none !important;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

#ayarkaTradesEndpoint .trades-chart-section .trades-chart-price-box {
  width: 100%;
  box-sizing: border-box;
  padding: var(--spacing-xl) var(--spacing-md) 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

#ayarkaTradesEndpoint #obPanelHistory {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
}

#ayarkaTradesEndpoint .trades-chart-section .chart-wrapper {
  width: calc(100% + 20px);
  height: 200px;
  min-height: 200px;
  position: relative;
  background: transparent;
  padding: 0;
  flex: 1;
  margin: 0 -10px;
  overflow: hidden;
}

#ayarkaTradesEndpoint .trades-chart-section #tradesPriceChart {
  display: block;
  box-sizing: border-box;
  width: 100% !important;
  height: 100% !important;
}

#ayarkaTradesEndpoint .trades-chart-section .chart-wrapper.trades-chart-wrapper--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
}

@media (min-width: 578px) {
  #ayarkaTradesEndpoint .trades-chart-section .chart-wrapper {
    width: 100%;
    height: 220px;
    min-height: 220px;
    margin: 0;
  }
}

@media (min-width: 1024px) {
  #ayarkaTradesEndpoint .trades-chart-section .chart-wrapper {
    flex: 1;
    height: 248px;
    max-height: 248px;
    min-height: 120px;
    width: 100%;
    margin: 0;
  }
}

.trades-chart-empty {
  text-align: center;
  color: var(--color-text-muted, #888);
  font-size: 13px;
}

.trades-chart-trend {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 23px;
  height: 23px;
  flex-shrink: 0;
}

.trades-chart-trend[hidden] {
  display: none !important;
}

.trades-chart-trend-icon {
  width: 0;
  height: 0;
  display: inline-block;
}

.trades-chart-trend--up .trades-chart-trend-icon {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid var(--color-status-positive);
}

.trades-chart-trend--down .trades-chart-trend-icon {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--color-status-error);
}

.trades-ob-price--neutral {
  color: #000;
}

/* Header with tabs */
.trades-orderbook__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border-light);
  background-color: var(--color-bg-card);
  position: sticky;
  top: 0;
  z-index: 2;
}

.trades-orderbook__tabs {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}

.trades-ob-tab {
  /* flex: 1; */
  padding: 12px var(--spacing-md);
  font-size: var(--font-size-box-caption);
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
  text-align: center;
}

.trades-ob-tab:hover {
  color: var(--color-text-primary);
}

.trades-ob-tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Column labels */
.trades-ob-cols {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 8px var(--spacing-md);
  background-color: #f5f7fa;
  border-bottom: 1px solid var(--color-border-light);
  gap: 4px;
}

.trades-ob-col-header {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  gap: 5px;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.trades-ob-col-header:first-child {
  justify-content: flex-end;
}

.trades-ob-col-header:last-child {
  justify-content: flex-start;
}

.trades-ob-col-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  line-height: 1.2;
}

.trades-ob-col-unit {
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-muted);
  background-color: rgba(0, 0, 0, 0.05);
  padding: 1px 3px;
  border-radius: var(--radius-md);
  line-height: 1.4;
}


/* Panel containers */
.trades-ob-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.trades-ob-panel[hidden] {
  display: none;
}

/* Sections for sell & buy */
.trades-ob-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.trades-ob-section--sell {
  order: 1;
}

.trades-ob-section--buy {
  order: 2;
}

.trades-ob-section--history-full {
  flex: 1;
  order: 1;
}

.trades-ob-body {
  display: flex;
  flex-direction: column;
}

/* Row */
.trades-ob-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 7px var(--spacing-md);
  gap: 4px;
  align-items: center;
  position: relative;
  transition: background-color 0.15s, transform 0.1s;
  cursor: pointer;
  isolation: isolate;
}

/* Depth visualization background */
.trades-ob-row::before {
  content: '';
  position: absolute;
  top: 0;
  height: 100%;
  width: var(--depth, 0%);
  z-index: -1;
  transition: width 0.3s ease-out;
}

/* Sell orders: gradient from RIGHT to LEFT */
.trades-ob-row--sell::before {
  left: 0;
  background: #fee5e9;
}

/* Buy orders: عمق از راست (RTL) */
.trades-ob-row--buy::before {
  right: 0;
  left: auto;
  background: #dcffe0;
}

.trades-ob-row:hover {
  background-color: rgba(0, 0, 0, 0.03);
  transform: scale(1.005);
}

.trades-ob-row:active {
  transform: scale(0.998);
}

/* History rows: no depth visualization */
.trades-ob-row--history::before {
  display: none;
}

.trades-ob-row--history {
  background: transparent;
}

.trades-ob-row--history:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.trades-ob-cell {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-primary);
  font-feature-settings: "tnum";
  white-space: nowrap;
  text-align: center;
}

.trades-ob-cell--price {
  font-weight: 700;
  text-align: right;
}

/* فروش (RTL): از راست → مجموع | مقدار | قیمت */
.trades-ob-section--sell .trades-ob-cell--total {
  text-align: right;
}

.trades-ob-section--sell .trades-ob-cell--price {
  text-align: left;
}

.trades-ob-price--buy {
  color: #1a7c1f;
}

.trades-ob-price--sell {
  color: var(--color-status-error);
}

.trades-ob-cell--total {
  text-align: left;
  font-size: 12px;
  color: var(--color-text-muted);
}

.trades-ob-cell--time {
  text-align: left;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Empty state */
.trades-ob-empty {
  padding: var(--spacing-xl) var(--spacing-md);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}

/* Skeleton shimmer alignment inside ticker + order book header */
#ayarkaTradesEndpoint .trades-ticker__value-skeleton {
  vertical-align: middle;
}

/* ════════════════════════════════════════════════════════════════════════════
   BUY / SELL FORM  (inherits calculator-ts__right style)
   ════════════════════════════════════════════════════════════════════════════ */

/* تب خرید / فروش — پس‌زمینهٔ برچسب فعال */
.calculator-ts--trades-shell .indicator-ts {
  display: none;
}

.calculator-ts--trades-shell .tab_label-ts {
  border-radius: calc(var(--radius-default) - 2px);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.calculator-ts--trades-shell #tradeTabBuy:checked + .tab_label-ts {
  background-color: #1a7c1f;
  color: #fff;
}

.calculator-ts--trades-shell #tradeTabSell:checked + .tab_label-ts {
  background-color: var(--color-status-error);
  color: #fff;
}

/* والد لازم برای سلکتورهای `.calculator-ts …` در trading.css */
.calculator-ts--trades-shell {
  width: 76%;
  overflow: visible;
}

.trades-form {
  flex: 1;
  order: 1;
}

/* Floating label fields */
.trades-floating-field {
  position: relative;
}


.trades-floating-label {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  font-size: 13px;
  color: #d7d7d7;
  background-color: #fff;
  padding: 0 4px;
  pointer-events: none;
  transition: top var(--transition-fast), transform var(--transition-fast), font-size var(--transition-fast), color var(--transition-fast);
}

.trades-floating-field .amount-input-ts:focus + .trades-floating-label,
.trades-floating-field .amount-input-ts:not(:placeholder-shown) + .trades-floating-label {
  top: 0;
  transform: translateY(-50%);
  font-size: 11px;
  color: #d7d7d7;
  font-weight: 600;
}

.trades-floating-field .amount-input-ts:focus + .trades-floating-label {
  color: var(--color-border-focus);
}

.trades-floating-field .amount-input-ts {
  border: 1px solid var(--color-border-light);
}

.trades-toman-unit {
  margin-right: 12px;
}

/* Calculation summary */
.trades-calc-summary {
  background-color: #f5f7fa;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-default);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trades-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-caption);
}

.trades-best-price {
  margin-top: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.trades-best-price__value {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.trades-calc-label {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 13px;
}

.label-long {
  font-size: 15px;
}

.trades-calc-val {
  font-weight: 600;
  color: var(--color-text-primary);
  font-feature-settings: "tnum";
  direction: rtl;
}

.trades-calc-row--total {
  padding-top: 8px;
  border-top: 1px solid var(--color-border-light);
  margin-top: 4px;
}

.trades-calc-row--total .trades-calc-label {
  color: var(--color-text-primary);
  font-weight: 700;
}

.trades-calc-row--total .trades-calc-val {
  font-size: var(--font-size-body);
  color: var(--color-primary);
}

#tradesBuyGrandTotal,
#tradesSellGrandTotal {
  background-color: #fff;
}

/* Submit buttons */
.submit-btn--buy {
  background-color: #1a7c1f;
  color: #fff;
  border: none;
}

.submit-btn--buy:hover,
.submit-btn--buy:focus {
  background-color: #155e19;
}

.submit-btn--sell {
  background-color: var(--color-status-error);
  color: #fff;
  border: none;
}

.submit-btn--sell:hover,
.submit-btn--sell:focus {
  background-color: #b22020;
}

/* Form notice / feedback */
.trades-form-notice {
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  border-radius: var(--radius-default);
  font-size: var(--font-size-caption);
  text-align: center;
}

.trades-form-notice[hidden] {
  display: none;
}

.trades-form-notice--success {
  background-color: var(--color-status-positive-bg);
  color: var(--color-status-positive);
  border: 1px solid rgba(34, 113, 40, 0.2);
}

.trades-form-notice--error {
  background-color: rgba(211, 47, 47, 0.08);
  color: var(--color-status-error);
  border: 1px solid rgba(211, 47, 47, 0.2);
}


/* ════════════════════════════════════════════════════════════════════════════
   USER TRADE HISTORY TABLE
   ════════════════════════════════════════════════════════════════════════════ */

.trades-history-section {
  margin-top: var(--spacing-xl);
}

/* Operation badge (buy/sell) */
.trades-op-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-card);
  font-size: 12px;
  font-weight: 600;
}

.trades-op-badge--buy {
  background-color: rgba(34, 113, 40, 0.1);
  color: #1a7c1f;
}

.trades-op-badge--sell {
  background-color: rgba(211, 47, 47, 0.1);
  color: var(--color-status-error);
}

/* Table empty state */
.trades-tbl-empty {
  text-align: center;
  padding: var(--spacing-xl) !important;
  color: var(--color-text-muted);
  font-size: var(--font-size-caption);
}


.trades-history-section .recent-tx-table tbody td {
  padding: 10px var(--spacing-md);
  font-size: 13px;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.trades-history-section .recent-tx-table tbody tr:last-child td {
  border-bottom: none;
}

.trades-history-section .recent-tx-table tbody tr:hover {
  background-color: #f9fafb;
}

/* ============================================
   LANDSCAPE MOBILE (max-width: 768px)
   هم‌تراز با trading.css
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
  .trades-history-section .recent-tx-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================
   LARGE DESKTOP (1400px+)
   هم‌تراز با trading.css
   ============================================ */
@media (min-width: 1400px) {
  .trades-main {
    gap: var(--spacing-2xl);
  }
}


/* ============================================
   MOBILE ONLY (max-width: 579px)
   هم‌تراز با trading.css — تنظیمات ویژهٔ خیلی باریک
   ============================================ */
   @media (max-width: 579px) {
    .trades-main {
      gap: var(--spacing-md);
    }
  
    .trades-history-section {
      margin-top: var(--spacing-lg);
    }
  }
  
  /* ============================================
     TABLET ENHANCEMENT (579px+)
     هم‌تراز با trading.css
     ============================================ */
  @media (min-width: 579px) {
    
.trades-ob-tab {
  font-size: var(--font-size-caption);
}
    .trades-ob-tab, .trades-orderbook__tabs {
      width: 50%;
    }
    .trades-ticker__scroll {
      min-height: 76px;
      flex-wrap: wrap;
      margin-top: var(--spacing-md);
    }

    .trades-ticker__asset-bar .trades-ticker__pair {
      width: 100%;
      max-width: none;
      min-width: 0;
      flex: 0 0 100%;
    }

    .trades-ticker__stat--last-trade {
      order: 1;
    }

    .trades-ticker__stat--vol {
      order: 2;
    }

    .trades-ticker__stat--high {
      order: 3;
    }

    .trades-ticker__stat--low {
      order: 4;
    }

    .trades-ticker__stat--vol-toman {
      order: 5;
    }
  
    .trades-ticker__stats {
      flex: 0 0 100%;
      flex-direction: row;
    }
  
    .trades-ticker__stat {
      flex: 1 1 0;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      border-bottom: none;
      border-right: 1px solid var(--color-border-light);
    }

    .trades-ticker__stat .trades-ticker__stat-label,
    .trades-ticker__stat .trades-ticker__stat-val {
      border-bottom: none;
      padding: 0;
    }

    .trades-ticker__stat-val {
      max-width: 100%;
    }
  
    .trades-ticker__pair-name {
      font-size: 17px;
    }
  
    .trades-ticker__stat-num {
      font-size: 15px;
    }
  
    .trades-ticker__stat-label {
      font-size: 12px;
    }
  
    .trades-ticker__stat {
      padding: 14px 18px;
    }
  
    .trades-ticker__asset-trigger {
      padding: 14px 20px;
    }
  
    /* پنل اصلی: دو ستون از 579px (همان نقطهٔ شکست trading) */
    .trades-main {
      flex-direction: row;
      flex-wrap: wrap;
      align-items: flex-start;
      gap: var(--spacing-lg);
    }
  
    /* دفتر سفارش: ستون ثابت + ترتیب flex (قبلاً از ۹۰۰px) */
    .trades-orderbook {
      order: 1;
      /* flex: 0 0 320px; */
      /* max-height: 600px; */
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: var(--color-border-light) transparent;
    }

    .trades-orderbook {
      flex: 1 1 280px;
      min-width: 0;
      max-width: 100%;
    }

    .calculator-ts--trades-shell {
      flex: 1 1 300px;
      min-width: 0;
      max-width: 100%;
    }
  
    .trades-form {
      width: 100%;
      order: 2;
    }
    .trades-main {
      flex-direction: row;
    }
  }
  
  /* ============================================
     DESKTOP ENHANCEMENT (1024px+)
     هم‌تراز با trading.css
     ============================================ */
  @media (min-width: 1024px) {
    div.trades-ticker__stat:nth-child(1) {
      border: 0px !important;
    }
    .trades-ticker {
      flex-direction: row;
      align-items: stretch;
      gap: var(--spacing-md);
    }

    .trades-ticker__asset-bar {
      flex: 0 0 auto;
      border-radius: var(--radius-card);
    }

    .trades-ticker__scroll {
      flex: 1 1 auto;
      min-height: 80px;
      flex-wrap: nowrap;
      margin-top: 0;
    }

    .trades-ticker__asset-menu {
      min-width: 320px;
    }

    .trades-ticker__asset-bar .trades-ticker__pair {
      width: max-content;
      max-width: 430px;
      min-width: 0;
      flex: 0 0 auto;
      border-bottom: none;
    }

    .trades-ticker__asset-trigger {
      width: auto;
      min-width: 280px;
      min-height: 80px;
      padding: 16px 22px;
    }

    .trades-ticker__stats {
      flex: 1 1 auto;
      flex-direction: row;
    }

    .trades-ticker__stat {
      flex: 0 0 auto;
      flex-direction: column;
      align-items: flex-start;
      justify-content: center;
      border-bottom: none;
      border-right: 1px solid var(--color-border-light);
      padding: 16px 20px;
    }

    .trades-ticker__stat:last-child {
      border-right: none;
    }

    /* Order Book: دو ستون (sell راست، buy چپ) */
    #obPanelMarket {
      flex-direction: row;
      gap: 1px;
      background-color: var(--color-border-light);
    }

    #obPanelMarket .trades-ob-section--sell {
      order: 1;
      border-left: 1px solid var(--color-border-light);
    }

    #obPanelMarket .trades-ob-section--buy {
      order: 2;
    }

    #obPanelMarket .trades-ob-section {
      flex: 1;
      background-color: var(--color-bg-card);
    }
  }

/* ═══════════════════════════════════════════════════════════════════════
   Mobile/Tablet (≤1028px): sticky خرید/فروش بالای منوی پایین + bottom sheet
   ═══════════════════════════════════════════════════════════════════════ */

.trades-mob-actions,
.trades-mob-sheet {
  display: none;
}

.trades-mob-actions[aria-hidden="true"] {
  display: none !important;
}

@media (max-width: 1028px) {
  /*
   * تا قبل از اجرای JS فرم از anchor به شیت منتقل شود، نباید یک فریم دیده شود.
   * داخل شیت سلکتور #tradesFormDesktopAnchor دیگر match نمی‌شود و نمایش عادی برمی‌گردد.
   */
  #tradesFormDesktopAnchor > #tradesFormPanel {
    display: none !important;
  }

  .trades-mob-actions {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 1001;
    gap: 10px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, #fff 100%);
    border-top: 1px solid var(--color-border-light);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.06);
    justify-content: stretch;
    align-items: stretch;
    box-sizing: border-box;
  }

  body.trades-mob-sheet--open .mobile-nav-bar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(120%);
  }

  .trades-mob-actions__btn {
    flex: 1;
    min-height: 46px;
    border: 0;
    border-radius: var(--radius-card, 10px);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    font-family: inherit;
    transition: filter var(--transition-fast, 0.15s ease), transform 0.12s ease;
  }

  .trades-mob-actions__btn:active {
    transform: scale(0.98);
  }

  .trades-mob-actions__btn--buy {
    background: var(--color-status-positive, #16a34a);
  }

  .trades-mob-actions__btn--sell {
    background: var(--color-status-error, #dc2626);
  }

  /* فرم به شیت منتقل می‌شود؛ :empty با فاصلهٔ بین تگ‌ها قابل اتکا نیست */
  .calculator-ts--trades-shell .trades-form-desktop-anchor:not(:has(#tradesFormPanel)) {
    display: none !important;
  }

  .trades-mob-sheet {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1002;
    pointer-events: none;
  }

  .trades-mob-sheet.is-open {
    pointer-events: auto;
  }

  .trades-mob-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.28s ease;
    touch-action: none;
  }

  .trades-mob-sheet.is-open .trades-mob-sheet__backdrop {
    opacity: 1;
  }

  .trades-mob-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(88vh, 640px);
    background: var(--color-bg-card);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.32s;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .trades-mob-sheet.is-open .trades-mob-sheet__panel {
    transform: translateY(0);
    visibility: visible;
    transition-delay: 0s, 0s;
  }

  .trades-mob-sheet__calc-root {
    width: 100%;
    min-width: 0;
  }

  #tradesMobSheet #tradesFormPanel {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
  }

  .trades-mob-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border-light);
    gap: 10px;
  }

  .trades-mob-sheet__title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-primary);
  }

  .trades-mob-sheet__close {
    width: 40px;
    height: 40px;
    border: 0;
    background: var(--color-bg-light);
    border-radius: 10px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    flex-shrink: 0;
  }

  .trades-mob-sheet__close:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }

  .trades-mob-sheet__body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 20px 16px;
  }


  .trades-endpoint {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  @media (max-width: 768px) {
    .trades-mob-actions {
      bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }

    .trades-endpoint {
      padding-bottom: calc(136px + env(safe-area-inset-bottom, 0px));
    }
  }
}

/* ── Trades Invoice (compact/factored) ────────────────────────────── */
.trades-invoice {
  background: #f8f9fb;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.trades-invoice__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  color: #333;
}

.trades-invoice__label {
  color: #6b7280;
  font-size: 12.5px;
}

.trades-invoice__value {
  font-weight: 600;
  font-size: 13px;
  color: #1f2937;
  direction: ltr;
  text-align: left;
}

.trades-invoice__unit {
  font-size: 10px;
  color: #9ca3af;
  margin-right: 2px;
}

.trades-invoice__divider {
  border-top: 1px dashed #e5e7eb;
  margin: 4px 0;
}

.trades-invoice__row--total {
  padding-top: 6px;
}

.trades-invoice__row--total .trades-invoice__label {
  font-weight: 700;
  color: #1f2937;
  font-size: 13px;
}

.trades-invoice__row--total .trades-invoice__value {
  font-weight: 800;
  font-size: 14px;
  color: #1c2474;
}

/* ── Insufficient balance actions ─────────────────────────────────── */
.trades-verify-insufficient {
  margin-top: 8px;
}

.trades-verify-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
}

.trades-verify-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--spacing-md);
  border-radius: var(--radius-card);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
  box-sizing: border-box;
  border: 2px solid var(--color-border-light);
  outline: none;
  text-decoration: none;
  background-color: var(--color-bg-light);
  color: var(--color-text-primary);
  text-align: center;
  justify-content: flex-start;
}

.trades-verify-nav-btn:hover {
  background-color: var(--color-bg-lighter);
  border-color: var(--color-primary-blue);
  color: var(--color-primary-blue);
}

.trades-verify-nav-btn:active {
  background-color: var(--color-bg-lighter);
}

.trades-verify-nav-btn .wallet-action-text {
  flex: 1;
  text-align: right;
}

.trades-verify-nav-btn__arrow {
  flex-shrink: 0;
  opacity: 0.45;
  width: 12px;
  height: 12px;
}

.trades-verify-nav-btn--credit {
  border-color: var(--color-secondary-gold, #b49659);
}

.trades-verify-nav-btn--credit:hover {
  border-color: var(--color-primary-blue);
}

/* ── دکمه لغو سفارش در histPanelOpen ───────────────────────────────────── */
#histPanelOpen .recent-tx-table-wrap.is-loading {
    pointer-events: none;
}

#histPanelOpen .recent-tx-table-wrap.is-loading .ayarka-skeleton-table-row td {
    padding: 14px 12px;
}
.btn-cancel-trade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--color-danger, #d9534f);
  border-radius: 6px;
  background: transparent;
  color: var(--color-danger, #d9534f);
  line-height: 1.4;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-cancel-trade:hover {
  background: var(--color-danger, #d9534f);
  color: #fff;
}
.btn-cancel-trade:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── نوار پیشرفت معامله جزئی (minor) ──────────────────────────────────── */
.trade-minor-progress {
  position: relative;
  width: 100%;
  min-width: 64px;
  height: 20px;
  background: var(--color-bg-light, #f0f0f0);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--color-border-light, #ddd);
}
.trade-minor-progress__bar {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background: #27ae60;
  border-radius: 10px;
  transition: width 0.3s;
}
.trade-minor-progress__label {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-primary, #222);
  line-height: 20px;
  white-space: nowrap;
}

/* ── Validity picker (verify modals) ─────────────────────────────────────── */
.modal-footer.trades-verify-footer {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.trades-verify-footer__actions {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: var(--spacing-md, 12px);
  width: 100%;
}

.trades-verify-footer__actions .cancel-btn,
.trades-verify-footer__actions .submit-btn {
  flex: 1;
}

.trades-validity-picker {
  margin: 0;
  padding: 0;
  border-top: 0;
}

.trades-validity-picker__label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-family-body, inherit);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary, #1e2a38);
}

.trades-validity-picker .trades-validity-dropdown {
  width: 100%;
}

/* هم‌ارتفاع با دکمه‌های انصراف/تایید (۴۴px) */
.trades-validity-dropdown .asset-type-dropdown__toggle {
  min-height: 44px;
  height: 44px;
}

.trades-validity-dropdown .asset-type-dropdown__toggle-inner,
.trades-validity-dropdown .asset-type-dropdown__option .asset-type-dropdown__item {
  min-height: 42px;
  padding: 0 14px 0 30px;
  align-items: center;
}

.trades-validity-dropdown .asset-type-dropdown__option .asset-type-dropdown__item {
  padding: 0 14px;
}

.trades-validity-dropdown .asset-type-dropdown__name {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.25;
}

.trades-validity-dropdown .asset-type-dropdown__toggle::before {
  left: 12px;
}

/* منوی داخل footer مودال — باز شدن به سمت بالا تا بریده نشود */
#verifyTradesBuy .modal-footer.trades-verify-footer,
#verifyTradesSell .modal-footer.trades-verify-footer {
  overflow: visible;
}

.trades-validity-dropdown .asset-type-dropdown__menu {
  top: auto;
  bottom: calc(100% + 6px);
  z-index: 30;
}

/* ── Open orders expiry countdown ────────────────────────────────────────── */
.trades-expiry-countdown {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.trades-expiry-countdown__value {
  display: inline-block;
  min-width: 72px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-primary, #222);
}
.trades-expiry-countdown__value.is-ticking {
  animation: trades-expiry-countdown-tick 0.32s ease-out;
}
@keyframes trades-expiry-countdown-tick {
  0% {
    opacity: 0.55;
  }
  100% {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .trades-expiry-countdown__value.is-ticking {
    animation: none;
  }
}
.trades-expiry-countdown[data-expires-ts=""] .trades-expiry-countdown__value {
  font-weight: 400;
  color: var(--color-text-muted, #888);
}
