/* ==========================================================================
   History Simulator & Betting Strategy Backtester Styles
   Rule 2 Compliant: Strictly Under 1,000 Lines
   ========================================================================== */

/* 0. Global: Remove ugly browser up/down number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.hsim-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  animation: hsimFadeIn 0.3s ease-out;
}

@keyframes hsimFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 1. Configuration & Scope Header Card */
.hsim-config-card {
  background: linear-gradient(145deg, #131b2e 0%, #0c111d 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.hsim-config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 1rem;
}

.hsim-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.hsim-title-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(126, 34, 206, 0.15));
  border: 1px solid rgba(168, 85, 247, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.25);
}

.hsim-main-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin: 0;
  letter-spacing: -0.3px;
}

.hsim-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Bankroll Stepper Widget */
.hsim-bankroll-pill {
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 30px;
  padding: 0.35rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.hsim-stepper {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
}

.hsim-stepper-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #c084fc;
  font-size: 1.1rem;
  font-weight: 800;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

.hsim-stepper-btn:hover {
  background: rgba(168, 85, 247, 0.35);
  color: #fff;
}

.hsim-stepper-input {
  background: transparent;
  border: none;
  color: #fbbf24;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 800;
  width: 85px;
  text-align: center;
  outline: none;
  padding: 0 4px;
}

/* Scope Filters Row */
.hsim-scope-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.hsim-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.hsim-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hsim-select,
.hsim-input {
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: all 0.2s;
  width: 100%;
}

.hsim-select:focus,
.hsim-input:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25);
}

.hsim-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.hsim-pill-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hsim-pill-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.hsim-pill-btn.active {
  background: rgba(168, 85, 247, 0.25);
  border-color: #c084fc;
  color: #e9d5ff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

/* Datetime Range Picker (Exact with Minutes) */
.hsim-datetime-range-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: rgba(9, 13, 22, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.hsim-dt-col {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hsim-dt-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
}

.hsim-dt-input {
  background: #0d1322;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
  outline: none;
  transition: border-color 0.2s;
}

.hsim-dt-input:focus {
  border-color: #a855f7;
}

.hsim-dt-sep {
  color: #64748b;
  font-weight: 800;
  font-size: 1rem;
  margin-top: 14px;
}

/* Multi-Dealer Picker (Up to 5 Dealers) */
.hsim-dealers-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.hsim-dealers-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 140px;
  overflow-y: auto;
  padding: 0.4rem;
  background: rgba(9, 13, 22, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.hsim-dealer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.hsim-dealer-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.hsim-dealer-pill.selected {
  background: rgba(168, 85, 247, 0.25);
  border-color: #c084fc;
  color: #f3e8ff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.35);
}

.hsim-dealer-pill.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hsim-dealers-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #94a3b8;
}

/* 2. Betting Board Card */
.hsim-board-card {
  background: linear-gradient(145deg, #131b2e 0%, #0c111d 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  position: relative;
}

.hsim-board-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.hsim-bet-summary-pill {
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 0.45rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.hsim-bet-summary-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  font-weight: 800;
  color: #38bdf8;
}

/* Board Action Buttons (Double, Half, Clear) */
.hsim-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.hsim-btn-action {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.hsim-btn-action:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.hsim-btn-action.clear:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: #f43f5e;
  color: #fda4af;
}

/* 3. Strategy Progression Settings */
.hsim-strategy-card {
  background: linear-gradient(145deg, #131b2e 0%, #0c111d 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.hsim-card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 1.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hsim-strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.hsim-strategy-box {
  background: rgba(9, 13, 22, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.hsim-strat-title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #c084fc;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.hsim-radio-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hsim-radio-lbl {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: #e2e8f0;
  cursor: pointer;
}

/* Big Calculate / Run Backtest CTA */
.hsim-run-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0.5rem 0;
}

.hsim-run-btn {
  background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
  border: 1px solid #c084fc;
  border-radius: 30px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 0.9rem 2.5rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 10px 28px rgba(168, 85, 247, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.hsim-run-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 34px rgba(168, 85, 247, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: brightness(1.1);
}

.hsim-run-btn:active {
  transform: translateY(1px) scale(0.98);
}

.hsim-run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.6);
}

/* 4. Results Section: Summary KPI Cards */
.hsim-results-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: hsimFadeIn 0.35s ease-out;
}

.hsim-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
}

.hsim-kpi-card {
  background: linear-gradient(145deg, #131b2e 0%, #0c111d 100%);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}

.hsim-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
}

.hsim-kpi-card.profit::before {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.hsim-kpi-card.loss::before {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.hsim-kpi-card.accent::before {
  background: linear-gradient(90deg, #a855f7, #c084fc);
}

.hsim-kpi-lbl {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hsim-kpi-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  margin-top: 0.35rem;
  letter-spacing: -0.5px;
}

.hsim-kpi-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  margin-top: 0.25rem;
}

/* 5. Graphs Section */
.hsim-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 1024px) {
  .hsim-charts-grid {
    grid-template-columns: 1fr;
  }
}

.hsim-chart-card {
  background: linear-gradient(145deg, #131b2e 0%, #0c111d 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

.hsim-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.hsim-chart-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hsim-chart-body {
  width: 100%;
  height: 380px;
  min-height: 380px;
}

/* 6. Detailed Round-by-Round Bets Table */
.hsim-table-card {
  background: linear-gradient(145deg, #131b2e 0%, #0c111d 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.hsim-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hsim-table-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hsim-rounds-table {
  width: 100%;
  border-collapse: collapse;
}

.hsim-rounds-table th {
  padding: 0.65rem 0.85rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}

.hsim-rounds-table td {
  padding: 0.75rem 0.85rem;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

.hsim-rounds-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.hsim-table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hsim-page-btns {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hsim-page-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hsim-page-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.hsim-page-btn.active {
  background: #a855f7;
  border-color: #c084fc;
  color: #fff;
}

.hsim-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Loading & Empty states */
.hsim-loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  color: #94a3b8;
}

.hsim-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(168, 85, 247, 0.2);
  border-top-color: #c084fc;
  border-radius: 50%;
  animation: hsimSpin 0.8s linear infinite;
}

@keyframes hsimSpin {
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .hsim-config-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
