/* ============================================================
   ForexArena — Trading Dashboard Styles
   ============================================================ */

.trading-body {
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.trading-topbar {
  height: 52px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 100;
}
.topbar-left, .topbar-right {
  display: flex; align-items: center; gap: 0.75rem;
}
.topbar-center {
  display: flex; align-items: center; justify-content: center;
  flex: 1;
}
.topbar-divider {
  width: 1px; height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* Pair selector */
.pair-selector {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 0.35rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s;
}
.pair-selector:hover { border-color: var(--accent); }
.pair-current {
  font-size: 0.9rem; font-weight: 800;
  font-family: var(--font-mono);
}
.pair-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  min-width: 160px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: none;
  overflow: hidden;
}
.pair-selector.open .pair-dropdown { display: block; }
.pair-option {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem; font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}
.pair-option:last-child { border-bottom: none; }
.pair-option:hover { background: var(--bg-elevated); color: var(--accent); }
.pair-option.active { color: var(--accent); background: var(--accent-subtle); }
.pair-option-price { font-size: 0.75rem; color: var(--text-muted); }

/* Price display */
.topbar-price {
  display: flex; align-items: baseline; gap: 0.5rem;
}
.tp-price {
  font-size: 1.1rem; font-weight: 800;
  font-family: var(--font-mono);
}
.tp-change {
  font-size: 0.75rem; font-weight: 700;
  font-family: var(--font-mono);
}
.tp-change.up   { color: var(--green); }
.tp-change.down { color: var(--red); }

/* OHLC */
.topbar-ohlc {
  display: flex; gap: 0.75rem;
  font-size: 0.72rem; font-family: var(--font-mono);
}
.topbar-ohlc span { display: flex; gap: 4px; }
.ohlc-label { color: var(--text-muted); font-weight: 700; }

/* Timeframe buttons */
.tf-buttons {
  display: flex; gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
}
.tf-btn {
  padding: 0.3rem 0.65rem;
  background: none; border: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem; font-weight: 700;
  color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font-display);
}
.tf-btn:hover { color: var(--text-primary); }
.tf-btn.active {
  background: var(--bg-surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Competition selector */
.comp-selector {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
}

/* Equity display */
.topbar-equity {
  display: flex; gap: 1rem;
}
.te-item { display: flex; flex-direction: column; gap: 1px; }
.te-label {
  font-size: 0.62rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.te-val {
  font-size: 0.82rem; font-weight: 800;
  font-family: var(--font-mono);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.trading-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.trading-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ============================================================
   CHART AREA
   ============================================================ */
.chart-area {
  flex: 1;
  position: relative;
  background: var(--bg-void);
  overflow: hidden;
  min-height: 0;
}
#mainChart {
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
}
.chart-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
}
.chart-crosshair-info {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; gap: 1rem;
  background: rgba(17,17,17,0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  font-size: 0.72rem; font-family: var(--font-mono);
  color: var(--text-secondary);
  backdrop-filter: blur(4px);
}
.chart-crosshair-info b { color: var(--text-primary); }

/* ============================================================
   BOTTOM PANEL
   ============================================================ */
.bottom-panel {
  height: 220px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.bottom-tabs {
  display: flex; align-items: center;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
  height: 40px;
  gap: 0.25rem;
}
.bottom-tabs .tab-btn {
  padding: 0.3rem 0.9rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 0.4rem;
}
.tab-count {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0 6px;
  font-size: 0.65rem; font-weight: 800;
  font-family: var(--font-mono);
  min-width: 18px; text-align: center;
}
.bottom-tabs-right {
  margin-left: auto;
  display: flex; gap: 1.5rem;
  font-size: 0.75rem; color: var(--text-muted);
}
.bp-stat b { color: var(--text-primary); font-family: var(--font-mono); }
.bottom-tab-content {
  display: none; flex: 1; overflow-y: auto;
}
.bottom-tab-content.active { display: block; }

/* ============================================================
   ORDER PANEL (right sidebar)
   ============================================================ */
.order-panel {
  width: 300px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Bid/Ask display */
.bid-ask-display {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}
.ba-side {
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}
.ba-side:hover { background: var(--bg-elevated); }
.ba-side.sell { border-right: 1px solid var(--border); }
.ba-side.sell.active { background: var(--red-dim); }
.ba-side.buy.active  { background: var(--green-dim); }
.ba-label {
  font-size: 0.65rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 4px;
}
.ba-side.sell .ba-label { color: var(--red); }
.ba-side.buy  .ba-label { color: var(--green); }
.ba-price {
  font-size: 1.2rem; font-weight: 800;
  font-family: var(--font-mono);
  transition: color 0.2s;
}
.ba-side.sell .ba-price { color: var(--red); }
.ba-side.buy  .ba-price { color: var(--green); }
.ba-spread { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }

/* Order type tabs */
.order-type-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.ot-btn {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem; font-weight: 800;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
  font-family: var(--font-display);
}
.ot-btn:hover { color: var(--text-primary); }
#otBuy.active  { background: var(--green-dim); color: var(--green); border-color: rgba(34,197,94,0.4); }
#otSell.active { background: var(--red-dim);   color: var(--red);   border-color: rgba(239,68,68,0.4); }

/* Order form */
.order-form { padding: 0.75rem; border-bottom: 1px solid var(--border); }

/* Lot input */
.lot-input-wrap {
  display: flex; align-items: center; gap: 0;
}
.lot-input-wrap .form-input {
  border-radius: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
}
.lot-btn {
  width: 36px; height: 38px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.1rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s;
  flex-shrink: 0;
  font-family: var(--font-display);
}
.lot-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.lot-btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.lot-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.lot-presets {
  display: flex; gap: 4px; margin-top: 6px;
}
.lot-presets button {
  flex: 1; padding: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.7rem; font-weight: 700;
  color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font-mono);
}
.lot-presets button:hover { border-color: var(--accent); color: var(--accent); }

/* Risk calculator */
.risk-calc {
  background: var(--bg-void);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  margin: 0.75rem 0;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.rc-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.75rem;
}
.rc-label { color: var(--text-muted); font-weight: 600; }
.rc-val   { font-family: var(--font-mono); font-weight: 700; color: var(--text-primary); }

/* Execute button */
.execute-btn {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.9rem; font-weight: 800;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-display);
}
.execute-btn.buy {
  background: var(--green);
  color: #fff;
  box-shadow: 0 0 20px rgba(34,197,94,0.3);
}
.execute-btn.buy:hover {
  background: #16a34a;
  box-shadow: 0 0 30px rgba(34,197,94,0.5);
  transform: translateY(-1px);
}
.execute-btn.sell {
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 20px rgba(239,68,68,0.3);
}
.execute-btn.sell:hover {
  background: #dc2626;
  box-shadow: 0 0 30px rgba(239,68,68,0.5);
  transform: translateY(-1px);
}
.execute-price {
  font-size: 0.8rem; opacity: 0.85;
  font-family: var(--font-mono);
}

/* Drawdown meter */
.dd-meter {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.dd-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}
.dd-label {
  font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.dd-val {
  font-size: 0.82rem; font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.dd-limit {
  font-size: 0.68rem; color: var(--text-muted);
  margin-top: 0.35rem; text-align: right;
}

/* Mini leaderboard */
.mini-leaderboard {
  padding: 0.75rem;
  flex: 1;
}
.ml-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.ml-title {
  font-size: 0.75rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.ml-link {
  font-size: 0.72rem; font-weight: 700;
  color: var(--accent); transition: opacity 0.2s;
}
.ml-link:hover { opacity: 0.8; }
.ml-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
.ml-row:last-child { border-bottom: none; }
.ml-row-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-row-pnl  { font-family: var(--font-mono); font-weight: 700; font-size: 0.75rem; }
.ml-row-you  { background: var(--accent-subtle); border-radius: var(--radius-sm); padding: 0 4px; }

/* ============================================================
   POSITION ROWS
   ============================================================ */
.pos-buy  { color: var(--green); font-weight: 800; }
.pos-sell { color: var(--red);   font-weight: 800; }
.close-pos-btn {
  padding: 0.25rem 0.6rem;
  background: var(--red-dim);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: var(--red); font-size: 0.72rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font-display);
}
.close-pos-btn:hover { background: var(--red); color: #fff; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .topbar-ohlc { display: none; }
  .topbar-equity .te-item:nth-child(3),
  .topbar-equity .te-item:nth-child(4) { display: none; }
}
@media (max-width: 900px) {
  .order-panel { width: 260px; }
  .topbar-center { display: none; }
}
@media (max-width: 700px) {
  .trading-layout { flex-direction: column; }
  .order-panel {
    width: 100%; height: 320px;
    border-left: none; border-top: 1px solid var(--border);
    flex-direction: row; overflow-x: auto;
  }
  .bottom-panel { height: 180px; }
}