/* ==========================================================================
   CYBERPULSE QUANT TERMINAL - AUTONOMOUS TRADING ENGINE STYLES (2026 PRO)
   ========================================================================== */

/* --- AUTO-TRADING CONTROL CLUSTER (HEADER / TOP HUD) --- */
.autotrade-control-cluster {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface-card-sub);
  border: 1px solid var(--border-default);
  padding: 4px 8px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.autotrade-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--surface-inset);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  transition: all var(--duration-normal) var(--ease-out);
}

.autotrade-status-pill.active {
  background: oklch(0.74 0.19 150 / 0.16);
  color: var(--color-success);
  border-color: oklch(0.74 0.19 150 / 0.4);
  box-shadow: 0 0 12px oklch(0.74 0.19 150 / 0.25);
}

.autotrade-status-pill.paused {
  background: oklch(0.78 0.17 75 / 0.14);
  color: var(--color-warning);
  border-color: oklch(0.78 0.17 75 / 0.35);
}

.status-dot-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

.autotrade-status-pill.active .status-dot-pulse {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse-emerald-glow 1.6s infinite ease-in-out;
}

.autotrade-status-pill.paused .status-dot-pulse {
  background: var(--color-warning);
  box-shadow: 0 0 6px var(--color-warning);
}

/* Master Auto-Trading Toggle Button */
.btn-autotrade {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid var(--color-brand);
  background: linear-gradient(135deg, oklch(0.20 0.05 220) 0%, oklch(0.14 0.03 220) 100%);
  color: var(--color-brand);
  cursor: pointer;
  box-shadow: 0 0 10px var(--color-brand-glow);
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-autotrade:hover {
  filter: brightness(1.15);
  box-shadow: 0 0 18px var(--color-brand-glow);
  transform: translateY(-1px);
}

.btn-autotrade.active {
  background: linear-gradient(135deg, oklch(0.74 0.19 150) 0%, oklch(0.60 0.18 150) 100%);
  color: #021a08;
  border-color: oklch(0.74 0.19 150);
  box-shadow: 0 0 20px oklch(0.74 0.19 150 / 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: pulse-active-glow 2.2s infinite ease-in-out;
}

.btn-autotrade.active:hover {
  filter: brightness(1.12);
  box-shadow: 0 0 26px oklch(0.74 0.19 150 / 0.65);
}

/* Sub-actions (Reset & Capital) */
.btn-hud-action {
  padding: 6px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--surface-inset);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-hud-action:hover {
  background: var(--surface-card-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* --- AUTO-TRADING PERFORMANCE HUD (4 METRIC TILES) --- */
.autotrade-performance-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

@media (max-width: 960px) {
  .autotrade-performance-hud {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  .autotrade-performance-hud {
    grid-template-columns: 1fr;
  }
}

.perf-tile {
  background: var(--surface-card-sub);
  border: 1px solid var(--border-default);
  border-top: 1px solid var(--border-specular);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.perf-tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.perf-tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.perf-tile-label {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.perf-tile-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.perf-tile-val {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.perf-tile-sub {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Value Highlights */
.perf-tile.accent-profit .perf-tile-val { color: var(--color-success); }
.perf-tile.accent-loss .perf-tile-val { color: var(--color-danger); }
.perf-tile.accent-fees .perf-tile-val { color: var(--color-brand); }
.perf-tile.accent-winrate .perf-tile-val { color: var(--color-accent); }

/* --- DETAILED TRADE HISTORY TABLE --- */
.trade-history-section {
  margin-top: var(--space-4);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.trade-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.trade-history-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.trade-history-title {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.trade-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.trade-history-table th {
  background: var(--surface-inset);
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-default);
}

.trade-history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.trade-history-table tbody tr {
  transition: background var(--duration-fast);
}

.trade-history-table tbody tr:hover {
  background: var(--surface-card-hover);
}

/* Action Badges */
.badge-action {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  display: inline-block;
  text-align: center;
}

.badge-action.buy {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}

.badge-action.sell {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* Fee Breakdown Tag */
.fee-breakdown-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fee-total {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.fee-detail {
  font-size: 0.625rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Subagent Reasoning Badge & Box */
.reason-badge-box {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 380px;
}

.subagent-tag {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: oklch(0.65 0.22 290 / 0.18);
  color: var(--color-accent);
  border: 1px solid oklch(0.65 0.22 290 / 0.35);
  white-space: nowrap;
}

.reason-text {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  line-height: 1.3;
  word-break: break-word;
}

/* Preset Chips */
.preset-capital-group .size-chip-group {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* --- KEYFRAME ANIMATIONS --- */
@keyframes pulse-emerald-glow {
  0%, 100% {
    box-shadow: 0 0 6px var(--color-success);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 14px var(--color-success);
    opacity: 0.75;
  }
}

@keyframes pulse-active-glow {
  0%, 100% {
    box-shadow: 0 0 16px oklch(0.74 0.19 150 / 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 28px oklch(0.74 0.19 150 / 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }
}
