/* ============================================================
   NORDIC CRYPTO — TRADE TERMINAL v3.0
   Professional trading terminal. Binance-grade UI.
   ============================================================ */

/* ---------- Terminal container ---------- */
.trade-terminal {
  position: fixed;
  inset: 0;
  background: #080b12;
  z-index: 9500;
  display: none;
  flex-direction: column;
  color: #e7edf5;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}
.trade-terminal.on { display: flex; }

/* ---------- Header ---------- */
.tt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  height: 64px;
  background: linear-gradient(180deg, #0f1720 0%, #0a0e15 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  gap: 20px;
}
.tt-header-left,
.tt-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tt-header-center {
  display: flex;
  align-items: center;
  gap: 40px;
  flex: 1;
  justify-content: center;
}

/* ---------- Coin selector ---------- */
.tt-coin-selector {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.02);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.tt-coin-selector button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #8b95a5;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: 0.5px;
}
.tt-coin-selector button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}
.tt-coin-selector button.on {
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(139, 92, 246, 0.6);
}

/* ---------- Price display ---------- */
.tt-price-display {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.tt-price {
  font-size: 24px;
  font-weight: 800;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: #fff;
  letter-spacing: -0.02em;
}
.tt-price.up { color: #10b981; }
.tt-price.down { color: #ef4444; }

.tt-change {
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}
.tt-change.up { color: #10b981; background: rgba(16, 185, 129, 0.12); }
.tt-change.down { color: #ef4444; background: rgba(239, 68, 68, 0.12); }

.tt-stats {
  display: flex;
  gap: 24px;
  font-size: 11px;
  color: #7a8a9e;
  font-family: ui-monospace, monospace;
}
.tt-stats b { color: #e7edf5; margin-left: 4px; }

.tt-close {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b95a5;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
  font-family: inherit;
}
.tt-close:hover {
  background: rgba(255, 84, 112, 0.15);
  border-color: rgba(255, 84, 112, 0.4);
  color: #ff5470;
}

/* ---------- Body grid ---------- */
.tt-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(220px, 1fr) minmax(280px, 1.1fr);
  gap: 1px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
  min-height: 0;
}

/* ---------- Chart panel ---------- */
.tt-chart-panel {
  background: #0a0e15;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.tt-chart-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #0f1720;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.tt-timeframes,
.tt-indicators {
  display: flex;
  gap: 4px;
}
.tt-timeframes button,
.tt-indicators button {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #7a8a9e;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  letter-spacing: 0.5px;
}
.tt-timeframes button:hover,
.tt-indicators button:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.tt-timeframes button.on { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
.tt-indicators button.on { background: rgba(71, 220, 255, 0.15); color: #47dcff; }

#ttChart {
  flex: 1;
  width: 100%;
  display: block;
  cursor: crosshair;
}

/* ---------- Order Book panel ---------- */
.tt-orderbook-panel {
  background: #0a0e15;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tt-ob-header {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #7a8a9e;
  background: #0f1720;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.tt-ob-asks,
.tt-ob-bids {
  flex: 1;
  overflow-y: auto;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  min-height: 0;
}
.tt-ob-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 4px 12px;
  cursor: pointer;
  position: relative;
  transition: background 0.1s;
  align-items: center;
  height: 22px;
}
.tt-ob-row:hover { background: rgba(255, 255, 255, 0.04); }
.tt-ob-row .tt-ob-price { font-weight: 700; }
.tt-ob-row.ask .tt-ob-price { color: #ef4444; }
.tt-ob-row.bid .tt-ob-price { color: #10b981; }
.tt-ob-row .tt-ob-amount { text-align: right; color: #c4ccd8; }
.tt-ob-row .tt-ob-total { text-align: right; color: #7a8a9e; }
.tt-ob-row .tt-ob-bar {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  opacity: 0.08;
  pointer-events: none;
}
.tt-ob-row.ask .tt-ob-bar { background: #ef4444; }
.tt-ob-row.bid .tt-ob-bar { background: #10b981; }

.tt-ob-spread {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #0f1720;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.tt-ob-spread-price {
  font-family: ui-monospace, monospace;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}
.tt-ob-spread-label {
  font-size: 10px;
  color: #7a8a9e;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- Form panel ---------- */
.tt-form-panel {
  background: #0a0e15;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tt-form-tabs {
  display: flex;
  background: #0f1720;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.tt-form-tabs button {
  flex: 1;
  padding: 14px;
  border: none;
  background: transparent;
  color: #7a8a9e;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  letter-spacing: 0.5px;
  position: relative;
}
.tt-form-tabs button:hover { color: #fff; }
.tt-form-tabs button.on[data-tab="buy"] { color: #10b981; }
.tt-form-tabs button.on[data-tab="sell"] { color: #ef4444; }
.tt-form-tabs button.on[data-tab="convert"] { color: #a78bfa; }
.tt-form-tabs button.on::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
}
.tt-form-tabs button.on[data-tab="buy"]::after { background: #10b981; }
.tt-form-tabs button.on[data-tab="sell"]::after { background: #ef4444; }
.tt-form-tabs button.on[data-tab="convert"]::after { background: #a78bfa; }

.tt-form {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 14px;
}
.tt-form.on { display: flex; }

.tt-order-type {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.02);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.tt-order-type button {
  flex: 1;
  padding: 7px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #7a8a9e;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tt-order-type button.on { background: rgba(255, 255, 255, 0.06); color: #fff; }

.tt-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tt-input-group label {
  font-size: 10px;
  color: #7a8a9e;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
.tt-input-group input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  outline: none;
  transition: all 0.15s;
  box-sizing: border-box;
}
.tt-input-group input:focus {
  border-color: rgba(71, 220, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(71, 220, 255, 0.1);
}
.tt-input-group input::placeholder { color: #4b5769; }
.tt-input-group input::-webkit-outer-spin-button,
.tt-input-group input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tt-input-group input[type=number] { -moz-appearance: textfield; }

.tt-quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.tt-quick button {
  padding: 7px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 7px;
  color: #8b95a5;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tt-quick button:hover {
  background: rgba(71, 220, 255, 0.08);
  border-color: rgba(71, 220, 255, 0.3);
  color: #47dcff;
}

.tt-limit-price {
  display: none;
  flex-direction: column;
  gap: 8px;
}
.tt-limit-price.on { display: flex; }
.tt-limit-price label {
  font-size: 10px;
  color: #7a8a9e;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
.tt-limit-price input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  outline: none;
  box-sizing: border-box;
}

.tt-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  font-size: 12px;
}
.tt-preview > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tt-preview span { color: #7a8a9e; }
.tt-preview b { color: #fff; font-family: ui-monospace, monospace; font-weight: 700; }

.tt-submit {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: inherit;
  letter-spacing: 0.3px;
  color: #fff;
}
.tt-submit:hover { transform: translateY(-1px); filter: brightness(1.1); }
.tt-submit:active { transform: translateY(0); }
.tt-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.tt-submit-buy { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: 0 8px 24px -8px rgba(16, 185, 129, 0.6); }
.tt-submit-sell { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: 0 8px 24px -8px rgba(239, 68, 68, 0.6); }
.tt-submit-convert { background: linear-gradient(135deg, #8b5cf6, #ec4899); box-shadow: 0 8px 24px -8px rgba(139, 92, 246, 0.6); }

/* ============================================================
   BOTTOM PANEL v3.0 — Pro Trading Table
   ============================================================ */

.tt-bottom {
  background: #080b12;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  height: 280px;
  flex-shrink: 0;
  overflow: hidden;
}

.tt-bottom-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  background: linear-gradient(180deg, #0f1720 0%, #0d131c 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  height: 48px;
  gap: 16px;
}

.tt-bottom-tabs {
  display: flex;
  gap: 4px;
  height: 100%;
}

.tt-bottom-tabs button {
  padding: 0 18px;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: color 0.15s;
  height: 100%;
}

.tt-bottom-tabs button:hover { color: #cbd5e1; }
.tt-bottom-tabs button.on { color: #fff; }

.tt-bottom-tabs button.on::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, #00e5ff, #8b5cf6);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.6);
}

.tt-tab-count {
  background: rgba(139, 92, 246, 0.18);
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
  font-family: ui-monospace, monospace;
}
.tt-tab-count[data-empty="1"] { display: none; }

.tt-bottom-filters {
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s;
}
.tt-bottom-filters.hidden { opacity: 0; pointer-events: none; }
.tt-filter-label {
  font-size: 10px;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 6px;
}
.tt-bottom-filters button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  transition: all 0.15s;
}
.tt-bottom-filters button:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
}
.tt-bottom-filters button.on {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  color: #c4b5fd;
}

.tt-bottom-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.tt-tab-content {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: none;
}
.tt-tab-content.on { display: block; }
.tt-tab-content::-webkit-scrollbar { width: 8px; }
.tt-tab-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.tt-tab-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.tt-table {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.tt-table-head {
  display: grid;
  grid-template-columns: 32px 70px 80px 1fr 1fr 1fr 100px 90px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky;
  top: 0;
  z-index: 2;
  gap: 12px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  font-family: ui-monospace, monospace;
}
.tt-table-head-rt {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}
.tt-table-head .tt-col-right { text-align: right; }

.tt-oh-list,
.tt-oo-list,
.tt-rt-list { display: flex; flex-direction: column; }

.tt-oh-row,
.tt-oo-row {
  display: grid;
  grid-template-columns: 32px 70px 80px 1fr 1fr 1fr 100px 90px;
  padding: 12px 20px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  gap: 12px;
  transition: background 0.15s;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  cursor: pointer;
}
.tt-oh-row:hover,
.tt-oo-row:hover {
  background: rgba(139, 92, 246, 0.04);
}
.tt-oh-row:nth-child(even),
.tt-oo-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}

.tt-oh-status-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  flex-shrink: 0;
}
.tt-oh-status-icon.filled {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1.5px solid rgba(16, 185, 129, 0.4);
}
.tt-oh-status-icon.open {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1.5px solid rgba(251, 191, 36, 0.4);
  animation: ohPulse 2s ease-in-out infinite;
}
@keyframes ohPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}
.tt-oh-status-icon.cancelled {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1.5px solid rgba(239, 68, 68, 0.4);
}

.tt-oh-type {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  text-align: center;
  letter-spacing: 0.5px;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.tt-oh-type.buy { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.tt-oh-type.sell { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.tt-oh-symbol { color: #fff; font-weight: 800; font-size: 13px; }
.tt-oh-amount,
.tt-oh-price,
.tt-oh-total {
  text-align: right;
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.tt-oh-amount { color: #cbd5e1; font-weight: 600; }
.tt-oh-price { color: #94a3b8; }
.tt-oh-total { color: #fff; font-weight: 700; }
.tt-oh-time {
  text-align: right;
  color: #64748b;
  font-size: 11px;
}

.tt-rt-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  padding: 8px 20px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  gap: 12px;
}
.tt-rt-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}
.tt-rt-row .tt-rt-price { font-weight: 700; }
.tt-rt-row.buy .tt-rt-price { color: #10b981; }
.tt-rt-row.sell .tt-rt-price { color: #ef4444; }
.tt-rt-row .tt-rt-amount,
.tt-rt-row .tt-rt-total,
.tt-rt-row .tt-rt-time {
  text-align: right;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.tt-oo-cancel {
  padding: 5px 12px;
  background: rgba(255, 84, 112, 0.1);
  border: 1px solid rgba(255, 84, 112, 0.3);
  color: #ff6b6b;
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.15s;
  width: 100%;
}
.tt-oo-cancel:hover {
  background: rgba(255, 84, 112, 0.2);
  border-color: rgba(255, 84, 112, 0.5);
}

.tt-empty {
  padding: 60px 20px;
  text-align: center;
  color: #4b5563;
  font-size: 13px;
}

/* ---------- Scrollbar ---------- */
.tt-ob-asks::-webkit-scrollbar,
.tt-ob-bids::-webkit-scrollbar,
.tt-form::-webkit-scrollbar { width: 6px; }
.tt-ob-asks::-webkit-scrollbar-thumb,
.tt-ob-bids::-webkit-scrollbar-thumb,
.tt-form::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .tt-body {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .tt-chart-panel { grid-column: span 2; grid-row: 1; }
  .tt-orderbook-panel { grid-column: 1; grid-row: 2; }
  .tt-form-panel { grid-column: 2; grid-row: 2; }
}

@media (max-width: 768px) {
  .tt-header { flex-wrap: wrap; height: auto; padding: 12px; }
  .tt-header-center { order: 3; width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 16px; }
  .tt-body { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .tt-chart-panel { grid-column: 1; grid-row: 1; min-height: 400px; }
  .tt-orderbook-panel { grid-column: 1; grid-row: 2; max-height: 300px; }
  .tt-form-panel { grid-column: 1; grid-row: 3; }
  .tt-bottom { height: 220px; }
  .tt-table-head,
  .tt-oh-row,
  .tt-oo-row {
    grid-template-columns: 26px 60px 65px 1fr 1fr 80px;
    font-size: 11px;
    padding: 8px 12px;
    gap: 8px;
  }
  .tt-oh-total { display: none; }
  .tt-oh-time { display: none; }
  .tt-bottom-tabs button { padding: 0 12px; font-size: 12px; }
  .tt-filter-label { display: none; }
}
