/* backtest.css — Backtest Lab page-specific layout and components.
   Does NOT own nav, footer, CSS variables, loading, or toasts (shared.css). */

/* LAYOUT */
.lab { display: grid; grid-template-columns: 220px 340px 1fr; min-height: calc(100vh - 57px); }

/* HISTORY SIDEBAR */
.history-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden; transition: width 0.25s ease;
  width: 220px; min-width: 0;
}
.history-sidebar.collapsed {
  width: 40px; min-width: 40px;
}
.history-sidebar.collapsed .history-list,
.history-sidebar.collapsed .history-title { display: none; }
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 14px 12px; border-bottom: 1px solid var(--border);
}
.history-title {
  font-family: var(--font-heading); font-weight: 700; font-size: 0.82rem;
  letter-spacing: -0.01em;
}
.history-toggle {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 0.75rem; padding: 4px; line-height: 1;
}
.history-toggle:hover { color: var(--text); }
.history-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.history-empty {
  color: var(--text-dim); font-size: 0.78rem; text-align: center;
  padding: 32px 12px;
}
.history-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.history-item:hover { background: var(--surface2); }
.h-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.h-pair { font-family: var(--font-heading); font-weight: 600; font-size: 0.78rem; }
.h-date { font-size: 0.68rem; color: var(--text-dim); }
.h-bottom { display: flex; justify-content: space-between; align-items: center; }
.h-strat { font-size: 0.7rem; color: var(--text-dim); }
.h-ret { font-family: var(--font-heading); font-weight: 700; font-size: 0.75rem; }
.h-pos { color: var(--high); }
.h-neg { color: var(--low); }

/* LEFT PANEL */
.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px; overflow-y: auto;
}
.panel-title {
  font-family: var(--font-heading); font-weight: 700; font-size: 1rem;
  margin-bottom: 24px; letter-spacing: -0.01em;
}
.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: 0.75rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
}
.field select, .field input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; font-size: 0.88rem;
  font-family: var(--font-body); outline: none; transition: border-color 0.2s;
}
.field select:focus, .field input:focus { border-color: var(--accent); }
.field select option { background: var(--surface2); color: var(--text); }

.params-section {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.params-title {
  font-size: 0.72rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 12px;
}
.param-row { display: flex; gap: 10px; margin-bottom: 10px; }
.param-row .field { flex: 1; margin-bottom: 0; }

.btn-run {
  width: 100%; padding: 14px; margin-top: 24px;
  background: var(--gradient); color: #fff; border: none; border-radius: 10px;
  font-family: var(--font-heading); font-weight: 700; font-size: 0.95rem;
  letter-spacing: 0.01em; cursor: pointer; transition: opacity 0.2s;
  box-shadow: 0 4px 24px var(--accent-glow);
}
.btn-run:hover { opacity: 0.9; }
.btn-run:disabled { opacity: 0.4; cursor: not-allowed; }

/* RIGHT RESULTS */
.results { padding: 24px 32px; overflow-y: auto; }
.results-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-dim); text-align: center; gap: 16px;
}
.results-empty svg { opacity: 0.3; }
.results-empty p { font-size: 0.95rem; max-width: 320px; line-height: 1.6; }

/* METRICS */
.metrics {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 24px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px; text-align: center;
}
.metric-value {
  font-family: var(--font-heading); font-weight: 800; font-size: 1.5rem;
  letter-spacing: -0.03em; line-height: 1.2;
}
.metric-label {
  font-size: 0.7rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em; margin-top: 6px;
}
.metric-pos { color: var(--high); }
.metric-neg { color: var(--low); }

/* CHART */
.chart-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 20px; margin-bottom: 20px;
}
.chart-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.chart-title { font-family: var(--font-heading); font-weight: 600; font-size: 0.88rem; }
.chart-canvas-wrap { position: relative; height: 320px; }

/* DISCLAIMER */
.disclaimer {
  background: rgba(255,209,102,0.08); border: 1px solid rgba(255,209,102,0.2);
  border-radius: 10px; padding: 14px 18px; margin-top: 20px;
  font-size: 0.8rem; color: var(--mid); line-height: 1.6;
}
.disclaimer strong { font-weight: 600; }

/* TRADES TABLE */
.trades-section { margin-top: 20px; }
.trades-title {
  font-family: var(--font-heading); font-weight: 600; font-size: 0.88rem;
  margin-bottom: 12px;
}
.trades-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.trades-table th {
  text-align: left; padding: 10px 12px;
  font-size: 0.7rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.trades-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.trades-table tr:hover { background: var(--surface2); }
.pnl-pos { color: var(--high); }
.pnl-neg { color: var(--low); }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .lab { grid-template-columns: 1fr; }
  .history-sidebar { display: none; }
  .panel { border-right: none; border-bottom: 1px solid var(--border); }
  .metrics { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .results { padding: 16px; }
  .panel { padding: 16px; }
}
