/* ============================================
   Live Trading View
   ============================================ */

/* ---- Symbol Search ---- */
.live-search-wrap {
  position: relative;
  width: 140px;
  flex-shrink: 0;
}
.live-search-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  outline: none;
  transition: border-color 0.15s;
}
.live-search-input:focus {
  border-color: var(--gold);
}
.live-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 220px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.live-search-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
}
.live-search-item:hover,
.live-search-item.active {
  background: var(--bg-hover);
}
.live-search-item .symbol-name {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.live-search-item .symbol-full {
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ---- Timeframe Select ---- */
.live-tf-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
}

/* ---- Price Display ---- */
.live-price-display {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-left: auto;
}

/* ---- Connection Status ---- */
.live-conn-status {
  display: flex;
  align-items: center;
  margin-left: 8px;
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.conn-dot.connected {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.conn-dot.disconnected {
  background: var(--red);
}

/* ---- Live Account Bar (below chart, matching training .account-bar) ---- */
.live-account-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: 4px 10px 0;
  font-size: 13px;
  flex-wrap: wrap;
}
.live-account-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.live-account-item .account-label {
  color: var(--text-secondary);
  font-size: 12px;
}
.live-account-item .account-value {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
  font-size: 14px;
}
.live-wallet-item {
  margin-left: auto;
}
.live-wallet-addr {
  font-size: 12px !important;
  color: var(--text-tertiary) !important;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Chart Area (matching training chart) ---- */
.live-candles {
  position: relative;
}
.live-chart {
  width: calc(100% - 20px);
  height: 600px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

/* ---- Toolbar (match #toolbar from header.css) ---- */
#liveToolbar {
  display: flex;
  padding: 0 8px;
  justify-content: center;
  align-items: center;
  flex: 1;
  height: 100%;
  gap: 4px;
}
/* Match #showHistoryGraphics special styling */
.tool-item#liveShowHistory { margin-right: 8px; opacity: 0.85; }
.tool-item#liveShowHistory:hover { opacity: 1; }
#liveEye.show { display: inline-block; }
#liveEye.hide { display: none; }
#liveEyeClose.show { display: inline-block; }
#liveEyeClose.hide { display: none; }

/* ---- Drawing tool active state ---- */
.live-draw-active {
  background: var(--bg-hover) !important;
  opacity: 1 !important;
}

/* ---- Trading Controls (4 buttons like training) ---- */
.live-controls {
  margin: 8px 10px;
}
.live-controls .settings-item select,
.live-controls .live-type-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
}
.live-controls .live-size-input {
  width: 80px;
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  outline: none;
}
.live-controls .live-size-input:focus {
  border-color: var(--gold);
}

/* ---- Orderbook + Positions Split Section ---- */
.live-split-section {
  display: flex;
  gap: 12px;
  margin: 8px 10px;
  min-height: 200px;
}
.live-split-col {
  flex: 1;
  min-width: 0;
}
.live-split-col h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 8px;
}

/* ---- Orderbook ---- */
.live-orderbook-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}
.live-ob-row {
  display: flex;
  align-items: center;
  padding: 2px 10px;
  position: relative;
  line-height: 22px;
}
.live-ob-px {
  width: 50%;
  z-index: 1;
}
.live-ob-sz {
  width: 50%;
  text-align: right;
  z-index: 1;
  color: var(--text-tertiary);
}
.live-ob-bar {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  opacity: 0.15;
  z-index: 0;
}
.live-ob-ask .live-ob-px { color: var(--red); }
.live-ob-ask .live-ob-bar { background: var(--red); }
.live-ob-bid .live-ob-px { color: var(--green); }
.live-ob-bid .live-ob-bar { background: var(--green); }
.live-orderbook-spread {
  display: flex;
  justify-content: space-between;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}
.live-ob-spread-pct {
  color: var(--text-tertiary);
  font-weight: 400;
}

/* ---- Live Tables ---- */
.live-section {
  margin: 16px 10px;
}
.live-section h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 8px;
}
.live-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.live-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}
.live-table td {
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(43,49,57,0.5);
}
.live-table .live-pnl {
  font-weight: 700;
}
.live-pnl.positive { color: var(--green); }
.live-pnl.negative { color: var(--red); }
.live-table .live-side-long { color: var(--green); font-weight: 700; }
.live-table .live-side-short { color: var(--red); font-weight: 700; }

.live-btn-close,
.live-btn-cancel {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.live-btn-close:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-bg);
}
.live-btn-cancel:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-dim);
}

.live-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ---- Order Confirm Modal ---- */
.live-order-confirm .live-confirm-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}
.live-order-confirm .live-confirm-row span:first-child {
  color: var(--text-secondary);
}
.live-order-confirm .live-confirm-total {
  border-top: 2px solid var(--border-color);
  border-bottom: none;
  font-weight: 700;
  margin-top: 8px;
  padding-top: 12px;
}

/* ---- Responsive Live ---- */
@media (max-width: 768px) {
  .live-split-section {
    flex-direction: column;
  }
  .live-chart {
    height: 450px;
  }
  .live-account-bar {
    gap: 12px;
    padding: 8px 12px;
    font-size: 12px;
  }
  .live-search-wrap {
    width: 100px;
  }
}
@media (max-width: 480px) {
  .live-account-bar {
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
  }
  .live-wallet-item {
    margin-left: 0;
  }
  .live-chart {
    height: 350px;
  }
}
