/*
 * Trading Tab — Terminal Pro aesthetic
 * Bloomberg-inspired: monospace data, horizontal ticker, compact daemon strip
 */

/* ── Font: IBM Plex Mono for all trading numbers ── */
#section-trading .metric-value,
#section-trading .trade-num,
#section-trading .trade-time,
#section-trading tfoot td,
#section-trading thead th,
#section-trading .trading-mono {
  font-family: 'IBM Plex Mono', 'Fira Code', 'Cascadia Code', var(--font-family-mono);
}

/* ── Section: subtle terminal grid overlay ── */
#section-trading {
  position: relative;
}

/* ── Market ticker band ── */
#trading-market-status {
  display: flex !important;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
  /* Fade edges */
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--space-4), #000 calc(100% - var(--space-4)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--space-4), #000 calc(100% - var(--space-4)), transparent 100%);
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

#trading-market-status .metric-card {
  flex-shrink: 0;
  min-width: 120px;
  max-width: 150px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

/* Glassy highlight on hover for market cards */
#trading-market-status .metric-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}

#trading-market-status .metric-card:hover {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 1px var(--color-brand), var(--shadow-md);
}

#trading-market-status .metric-icon {
  width: var(--space-6);
  height: var(--space-6);
  font-size: var(--font-size-xs);
  margin-bottom: var(--space-1);
}

#trading-market-status .metric-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#trading-market-status .metric-value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
}

#trading-market-status .metric-detail,
#trading-market-status .metric-subtitle {
  font-size: 10px;
  white-space: nowrap;
}

/* ── Market clock card — highlighted ── */
#market-clock-card {
  min-width: 140px !important;
  max-width: 160px !important;
  border-color: var(--color-brand) !important;
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0, 108, 165, 0.08) 100%) !important;
}

#market-clock-card .metric-value {
  font-size: var(--font-size-base) !important;
  font-family: 'IBM Plex Mono', var(--font-family-mono) !important;
  letter-spacing: -0.02em;
}

/* ── Daemon status — compact horizontal strip ── */
.trading-daemon-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.trading-daemon-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

#trading-daemon-status {
  display: flex !important;
  flex-wrap: wrap;
  gap: var(--space-2);
}

#trading-daemon-status .metric-card {
  flex: 0 0 auto;
  min-width: 100px;
  max-width: 130px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

#trading-daemon-status .metric-icon {
  width: var(--space-6);
  height: var(--space-6);
  font-size: var(--font-size-xs);
  margin-bottom: var(--space-1);
}

#trading-daemon-status .metric-label {
  font-size: 10px;
}

#trading-daemon-status .metric-value {
  font-size: var(--font-size-sm);
}

/* ── Last-run summary cards — compact ── */
#trading-summary-metrics .metric-card {
  padding: var(--space-3);
  border-radius: var(--radius-md);
}

#trading-summary-metrics .metric-icon {
  width: var(--space-7);
  height: var(--space-7);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-1-half);
}

#trading-summary-metrics .metric-label {
  font-size: 10px;
}

#trading-summary-metrics .metric-value {
  font-size: var(--font-size-lg);
}

/* ── Trading section subtitles ── */
#section-trading .section-subtitle {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: var(--space-1);
  border-left: 2px solid var(--color-brand);
}

/* ── Trade tables — terminal style ── */
#trading-trades-table table,
#trading-positions-table table,
#trading-etf-table table,
#trade-history-table table {
  font-size: var(--font-size-xs);
}

#trading-trades-table thead th,
#trading-positions-table thead th,
#trading-etf-table thead th,
#trade-history-table thead th,
#strategy-history-table thead th {
  font-family: 'IBM Plex Mono', var(--font-family-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: var(--space-2) var(--space-3);
}

#trading-trades-table td,
#trading-positions-table td,
#trading-etf-table td,
#trade-history-table td {
  padding: var(--space-2) var(--space-3);
  vertical-align: middle;
}

/* BUY = green pill, SELL = red pill */
#trading-trades-table .text-success,
#trading-etf-table .text-success {
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.03em;
}

#trading-trades-table .text-danger,
#trading-etf-table .text-danger {
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.03em;
}

/* ── Strategy gains chart — card header ── */
#section-trading .card-header {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Live badge pulse ── */
.badge.bg-success {
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Equity curve chart: taller ── */
#section-trading .chart-wrap canvas#chart-equity-curve {
  min-height: 200px;
}

/* ── Crypto panel: horizontal scroll on small ── */
#trading-crypto-status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

#trading-crypto-status .metric-card {
  min-width: 130px;
  flex: 1 1 130px;
}

/* ── Gain/loss values: monospace ── */
#trading-strategies-content .text-success,
#trading-strategies-content .text-danger,
#trading-strategies-content .text-muted,
#trading-positions-table .text-success,
#trading-positions-table .text-danger {
  font-family: 'IBM Plex Mono', var(--font-family-mono);
  font-size: var(--font-size-xs);
}

/* ── Strategy table: compact ── */
#trading-strategies-content table {
  font-size: var(--font-size-xs);
}

#trading-strategies-content thead th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-hover);
}

/* ── Market clock: open state glow ── */
#market-clock-card.market-open {
  border-color: var(--color-success) !important;
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(47, 133, 90, 0.08) 100%) !important;
}

#market-clock-card.market-open .metric-value {
  color: var(--color-success);
}

/* ── Scrollbar styling ── */
#trading-market-status::-webkit-scrollbar {
  height: 3px;
}

#trading-market-status::-webkit-scrollbar-track {
  background: transparent;
}

#trading-market-status::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 2px;
}

/* ── Section-strategy-history: match trading style ── */
#section-strategy-history .card-header,
#section-trade-history .card-header {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Source badge: trading-specific ── */
#section-trading .source-badge {
  font-family: 'IBM Plex Mono', var(--font-family-mono);
  font-size: 10px;
}

/* ── Daemon log modal ── */
.daemon-log-pre {
  font-family: 'IBM Plex Mono', var(--font-family-mono);
  font-size: var(--font-size-xs);
  line-height: 1.6;
  background: #0a0a0f;
  color: #a8ff78;
  padding: var(--space-4);
  margin: 0;
  max-height: 60vh;
  overflow-y: auto;
}

/* ── Light mode overrides ── */
[data-theme="light"] .daemon-log-pre {
  background: #1a1a2e;
  color: #78e08f;
}

[data-theme="light"] #trading-market-status .metric-card:hover {
  box-shadow: 0 0 0 1px var(--color-brand), var(--shadow-sm);
}
