/* Backtest strategy panel — conditions editor + parameters */

/* Right panel tabs */
.bt-right-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.bt-ptab {
  flex: 1;
  padding: 10px 0;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.bt-ptab:hover { color: var(--text); }
.bt-ptab.active { color: var(--text); border-bottom-color: var(--blue); }

/* Panel body */
.bt-right-body {
  overflow-y: auto;
  min-height: 0;
}

.bt-panel-content {
  display: none;
  padding: 12px 14px;
}

.bt-panel-content.active { display: block; }

/* Sections */
.bt-section {
  margin-bottom: 14px;
}

.bt-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* Condition rows */
.bt-conditions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bt-cond-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.bt-cond-indicator,
.bt-cond-operator {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 6px;
  font-size: 12px;
  outline: none;
}

.bt-cond-indicator { width: 80px; }
.bt-cond-operator { width: 70px; }

.bt-cond-value {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 6px;
  font-size: 12px;
  width: 60px;
  outline: none;
  font-family: var(--mono);
}

.bt-cond-remove {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.bt-cond-remove:hover { color: var(--red); }

.bt-add-cond {
  background: transparent;
  color: var(--blue);
  border: 1px dashed var(--line);
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  margin-top: 6px;
  width: 100%;
  transition: border-color 0.15s;
}

.bt-add-cond:hover { border-color: var(--blue); }

/* Parameters */
.bt-params {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.bt-param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
}

.bt-param-row label {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.bt-param-input {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--mono);
  outline: none;
  width: 100px;
  text-align: right;
}

.bt-param-input:focus { border-color: var(--blue); }

.bt-input-unit {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bt-unit {
  font-size: 11px;
  color: var(--muted);
  min-width: 30px;
}

select.bt-param-input {
  text-align: left;
  cursor: pointer;
}

/* Run button */
.bt-run-btn {
  width: 100%;
  padding: 10px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 14px;
  transition: opacity 0.15s;
}

.bt-run-btn:hover { opacity: 0.85; }
.bt-run-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* P5.6a: Engine host for strategy-panel standalone buttons. Takes margin-top
 * matching legacy button placement. Host height is set by Engine via
 * renderElements (maxBottom). margin-top on specific hosts via :nth-of-type
 * would be fragile — relies on Engine module's own top-offset in layout. */
.bt-strategy-btn-host {
  position: relative;
  margin-top: 6px;
}
.bt-strategy-btn-host#btRunBtnHost { margin-top: 14px; }

/* ═══ MVP1 Full-Auto style backtest panel ═══════════════════════════ */

.btfa-section {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.btfa-section:last-of-type { border-bottom: none; }

.btfa-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.btfa-run-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--blue, #4e8cff);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  transition: filter 0.15s;
}
.btfa-run-btn:hover:not(:disabled) { filter: brightness(1.12); }
.btfa-run-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Run row holds the run button + stop button; stop takes over width while running. */
.btfa-run-row { display: flex; gap: 6px; }
.btfa-run-row .btfa-run-btn { flex: 1; }
.btfa-stop-btn {
  flex: 0 0 72px;
  padding: 12px 0;
  background: var(--danger, #ef4444);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.btfa-stop-btn:hover { filter: brightness(1.1); }

/* Sticky footer pinning run button + aux grid to the bottom of the
   scrollable strategy panel. */
.btfa-footer {
  position: sticky;
  bottom: 0;
  margin: 16px -14px -12px;
  padding: 10px 14px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  z-index: 2;
}
.btfa-footer .btfa-run-btn { margin-top: 0; }

/* Aux actions below run button — 2-column card grid */
.btfa-aux-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-top: 8px;
}
.btfa-aux-btn {
  padding: 10px 6px;
  background: var(--panel-2);
  color: var(--text);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: filter 0.15s;
}
.btfa-aux-btn:hover { filter: brightness(1.15); }

/* Section title inside stats tab */
.btfa-stat-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 10px 4px 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--line);
}
.btfa-stat-section-title:first-child { margin-top: 0; }

/* Stats list in report panel */
.btfa-stats-list {
  display: flex;
  flex-direction: column;
  padding: 8px;
}
.btfa-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.btfa-stat-row:last-child { border-bottom: none; }
.btfa-stat-row .k { color: var(--muted); }
.btfa-stat-row .v { color: var(--text); font-family: var(--mono); font-weight: 600; }

/* Trades table */
.btfa-trades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-family: var(--mono);
}
.btfa-trades-table th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  padding: 6px 5px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}
.btfa-trades-table th.r { text-align: right; }
.btfa-trades-table td {
  padding: 4px 5px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.btfa-trades-table td.r { text-align: right; }
.btfa-trades-table td.dim { color: var(--muted); }
.btfa-trades-table td.pos { color: var(--green, #4ecb73); }
.btfa-trades-table td.neg { color: var(--red, #ff5a5a); }
.btfa-trades-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Trades view toggle (連續 / 以局) */
.bt-view-toggle {
  display: flex; margin-bottom: 8px;
}
.bt-view-toggle .fa-seg-btn { flex: 1; }

/* Sequence-view: clickable rows + expansion */
.bt-seq-row { cursor: pointer; }
.bt-seq-row.expanded td { background: rgba(78,203,115,0.06); }
.bt-seq-row.expanded td:first-child::before {
  content: "▼ "; color: var(--muted); font-size: 10px;
}
.bt-seq-row:not(.expanded) td:first-child::before {
  content: "▶ "; color: var(--muted); font-size: 10px;
}
.bt-seq-expand-cell {
  padding: 0 !important;
  background: rgba(0, 0, 0, 0.2);
}
.bt-seq-sub-table {
  margin: 0 !important;
  font-size: 10px !important;
}
.bt-seq-sub-table th {
  background: rgba(0, 0, 0, 0.3) !important;
  font-size: 10px !important;
}

/* Multi-coin chip picker */
.bt-cp-chips {
  display: flex; flex-wrap: wrap; gap: 4px; min-height: 28px;
  padding: 4px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel-2);
}
.bt-cp-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 8px; font-size: 11px; font-weight: 600;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 3px;
  font-family: var(--mono);
}
.bt-cp-chip-x {
  background: transparent; color: var(--muted); border: 0;
  font-size: 14px; cursor: pointer; padding: 0 4px; line-height: 1;
}
.bt-cp-chip-x:hover { color: var(--danger, #ef4444); }
.bt-cp-empty { color: var(--muted); font-size: 11px; padding: 4px; }
.bt-cp-add {
  display: flex; gap: 4px; margin-top: 4px;
}
.bt-cp-add .bt-cp-select { flex: 1; }
.bt-cp-add-btn { padding: 4px 10px; }

/* Rolling multi-period summary table */
.bt-rolling-table tbody tr { cursor: pointer; }
.bt-rolling-row.active td {
  background: rgba(78, 203, 115, 0.08);
  box-shadow: inset 2px 0 0 var(--green, #4ecb73);
}
.bt-rolling-row.active:hover td { background: rgba(78, 203, 115, 0.12); }
#btRollingEquityContainer { min-height: 240px; }
