/* ============================================================================
   🧠 HYPERLIQ BRAIN DASHBOARD - TERMINAL AESTHETIC
   ============================================================================
   Matrix-style terminal UI with cyber-security vibes
   ============================================================================ */

/* -------------------------------------------------------------------------- */
/*  BRAIN-SPECIFIC VARIABLES                                                  */
/* -------------------------------------------------------------------------- */

:root {
  /* Turkuaz / Cyan tema */
  --matrix-green: #00d4ff;
  --matrix-green-dim: rgba(0, 212, 255, 0.6);
  --matrix-green-glow: rgba(0, 212, 255, 0.15);
  --terminal-bg: #050508;
  --terminal-border: #0a1f2f;
  --cyber-blue: #00d4ff;
  --cyber-purple: #a855f7;
  --decision-long: #10b981;
  --decision-short: #ef4444;
  --decision-skip: #6b7280;
  --warning-orange: #f59e0b;
  --sigma-high: #ef4444;
  --sigma-medium: #f59e0b;
  --sigma-low: #10b981;
}

/* -------------------------------------------------------------------------- */
/*  BODY & LAYOUT                                                             */
/* -------------------------------------------------------------------------- */

.brain-body {
  background: linear-gradient(135deg, #030305 0%, #0a0a12 50%, #050510 100%);
  min-height: 100vh;
}

.brain-header {
  border-bottom-color: var(--matrix-green) !important;
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.1) !important;
}

.brain-header .brand-logo {
  background: linear-gradient(135deg, var(--matrix-green), #0099cc) !important;
  box-shadow: 0 0 25px rgba(0, 212, 255, 0.4);
}

.brain-header .brand-copy h1 {
  background: linear-gradient(135deg, var(--matrix-green), #60e0ff) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brain-logo {
  font-size: 20px !important;
}

/* Status Pills */
.status-pill strong {
  color: var(--matrix-green);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.status-pill.offline strong {
  color: var(--decision-short);
}

.confidence-pill strong {
  background: linear-gradient(135deg, var(--cyber-blue), var(--cyber-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* -------------------------------------------------------------------------- */
/*  BRAIN DASHBOARD GRID                                                      */
/* -------------------------------------------------------------------------- */

.brain-dashboard {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 16px;
  margin-top: 18px;
  min-height: calc(100vh - 140px);
}

.brain-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brain-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* -------------------------------------------------------------------------- */
/*  PHASE INDICATORS                                                          */
/* -------------------------------------------------------------------------- */

.phase-panel {
  background: linear-gradient(
    180deg,
    rgba(0, 212, 255, 0.03) 0%,
    var(--bg-panel) 100%
  );
}

.phase-list {
  padding: 12px;
}

.phase-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: rgba(20, 20, 30, 0.5);
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.phase-item:last-child {
  margin-bottom: 0;
}

.phase-item.active {
  background: rgba(0, 212, 255, 0.08);
  border-color: var(--matrix-green);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.1);
}

.phase-item.completed {
  border-color: var(--decision-long);
}

.phase-item.completed .phase-status {
  color: var(--decision-long);
}

.phase-item.processing {
  border-color: var(--cyber-blue);
  animation: phase-pulse 1.5s ease-in-out infinite;
}

.phase-item.processing .phase-status {
  color: var(--cyber-blue);
  animation: blink 0.8s ease-in-out infinite;
}

@keyframes phase-pulse {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(0, 212, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.phase-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.15);
  border: 1px solid var(--matrix-green-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--matrix-green);
}

.phase-item.completed .phase-num {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--decision-long);
  color: var(--decision-long);
}

.phase-info {
  flex: 1;
}

.phase-info strong {
  display: block;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.phase-info small {
  font-size: 10px;
  color: var(--text-muted);
}

.phase-status {
  font-size: 10px;
  color: var(--text-muted);
}

/* -------------------------------------------------------------------------- */
/*  SIGMA ANOMALY HEATMAP                                                     */
/* -------------------------------------------------------------------------- */

.sigma-panel {
  background: linear-gradient(
    180deg,
    rgba(239, 68, 68, 0.02) 0%,
    var(--bg-panel) 100%
  );
}

.sigma-grid {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sigma-item {
  display: grid;
  grid-template-columns: 70px 60px 1fr;
  align-items: center;
  gap: 8px;
}

.sigma-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sigma-value {
  font-size: 12px;
  font-weight: 700;
  font-family: "Courier New", monospace;
  text-align: right;
  color: var(--sigma-low);
}

.sigma-value.medium {
  color: var(--sigma-medium);
}

.sigma-value.high {
  color: var(--sigma-high);
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.sigma-bar {
  height: 6px;
  background: rgba(30, 30, 45, 0.8);
  border-radius: 3px;
  overflow: hidden;
}

.sigma-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: var(--sigma-low);
  transition: width 0.5s ease, background 0.3s ease;
}

.sigma-fill.medium {
  background: var(--sigma-medium);
}

.sigma-fill.high {
  background: var(--sigma-high);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.warning-chip {
  background: rgba(16, 185, 129, 0.15) !important;
  color: var(--decision-long) !important;
  border: 1px solid var(--decision-long) !important;
  font-size: 9px !important;
  padding: 2px 8px !important;
}

.warning-chip.alert {
  background: rgba(239, 68, 68, 0.15) !important;
  color: var(--sigma-high) !important;
  border-color: var(--sigma-high) !important;
  animation: alert-pulse 1s ease-in-out infinite;
}

@keyframes alert-pulse {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.3);
  }
  50% {
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
  }
}

/* -------------------------------------------------------------------------- */
/*  MEMORY STATS                                                              */
/* -------------------------------------------------------------------------- */

.memory-stats-panel {
  background: linear-gradient(
    180deg,
    rgba(168, 85, 247, 0.03) 0%,
    var(--bg-panel) 100%
  );
}

.memory-stats {
  padding: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row span {
  font-size: 11px;
  color: var(--text-secondary);
}

.stat-row strong {
  font-size: 13px;
  color: var(--cyber-purple);
  font-family: "Courier New", monospace;
}

/* -------------------------------------------------------------------------- */
/*  TERMINAL WINDOW                                                           */
/* -------------------------------------------------------------------------- */

.terminal-panel {
  flex: 1;
  min-height: 400px;
  background: linear-gradient(
    180deg,
    rgba(0, 212, 255, 0.02) 0%,
    var(--bg-panel) 100%
  );
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.pulse-dot.active {
  background: var(--matrix-green);
  box-shadow: 0 0 10px var(--matrix-green);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.2);
  }
}

#inference-status {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

#inference-status.active {
  color: var(--matrix-green);
}

.terminal-window {
  background: var(--terminal-bg);
  color: var(--matrix-green);
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 16px 20px;
  height: calc(100% - 50px);
  min-height: 350px;
  overflow-y: auto;
  border: 1px solid var(--terminal-border);
  border-radius: 0 0 12px 12px;
  box-shadow: inset 0 0 30px rgba(0, 212, 255, 0.03);
}

.terminal-window::-webkit-scrollbar {
  width: 6px;
}

.terminal-window::-webkit-scrollbar-track {
  background: var(--terminal-bg);
}

.terminal-window::-webkit-scrollbar-thumb {
  background: var(--matrix-green-dim);
  border-radius: 3px;
}

.term-line {
  margin-bottom: 6px;
  padding-left: 12px;
  border-left: 2px solid transparent;
  animation: typing 0.1s steps(40, end);
  word-wrap: break-word;
}

@keyframes typing {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.term-line.system {
  color: var(--cyber-blue);
  border-left-color: var(--cyber-blue);
}

.term-line.warning {
  color: var(--warning-orange);
  border-left-color: var(--warning-orange);
}

.term-line.error {
  color: var(--decision-short);
  border-left-color: var(--decision-short);
}

.term-line.success {
  color: var(--decision-long);
  border-left-color: var(--decision-long);
}

.term-line.muted {
  color: var(--text-muted);
  font-style: italic;
}

.term-line.decision {
  color: var(--matrix-green);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
  margin: 8px 0;
  background: rgba(0, 212, 255, 0.08);
  border-left: 3px solid var(--matrix-green);
  border-radius: 4px;
}

.term-line.decision.long {
  color: var(--decision-long);
  background: rgba(16, 185, 129, 0.1);
  border-left-color: var(--decision-long);
}

.term-line.decision.short {
  color: var(--decision-short);
  background: rgba(239, 68, 68, 0.1);
  border-left-color: var(--decision-short);
}

.term-line.decision.skip {
  color: var(--decision-skip);
  background: rgba(107, 114, 128, 0.1);
  border-left-color: var(--decision-skip);
}

.term-timestamp {
  color: var(--text-muted);
  font-size: 10px;
  margin-right: 8px;
}

/* -------------------------------------------------------------------------- */
/*  DECISION HISTORY                                                          */
/* -------------------------------------------------------------------------- */

.history-panel {
  max-height: 300px;
}

.history-filters {
  display: flex;
  gap: 6px;
}

.filter-btn {
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: rgba(30, 30, 45, 0.6);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: rgba(50, 50, 70, 0.6);
}

.filter-btn.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--cyber-blue);
  color: var(--cyber-blue);
}

.decision-list {
  padding: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.decision-item {
  display: grid;
  grid-template-columns: 80px 70px 60px 1fr 80px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: rgba(20, 20, 30, 0.5);
  border-radius: 6px;
  border-left: 3px solid var(--border);
  font-size: 11px;
  transition: all 0.2s ease;
}

.decision-item:hover {
  background: rgba(30, 40, 60, 0.5);
}

.decision-item.long {
  border-left-color: var(--decision-long);
}

.decision-item.short {
  border-left-color: var(--decision-short);
}

.decision-item.skip {
  border-left-color: var(--decision-skip);
}

.decision-time {
  color: var(--text-muted);
  font-family: "Courier New", monospace;
  font-size: 10px;
}

.decision-type {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.decision-type.long {
  color: var(--decision-long);
}
.decision-type.short {
  color: var(--decision-short);
}
.decision-type.skip {
  color: var(--decision-skip);
}

.decision-conf {
  font-family: "Courier New", monospace;
  color: var(--cyber-blue);
}

.decision-driver {
  color: var(--text-secondary);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.decision-status {
  text-align: right;
  font-size: 9px;
  text-transform: uppercase;
}

.decision-status.approved {
  color: var(--decision-long);
}

.decision-status.rejected {
  color: var(--decision-short);
}

/* -------------------------------------------------------------------------- */
/*  VERDICT PANEL                                                             */
/* -------------------------------------------------------------------------- */

.verdict-panel {
  background: linear-gradient(
    180deg,
    rgba(0, 212, 255, 0.03) 0%,
    var(--bg-panel) 100%
  );
}

.verdict-display {
  padding: 20px 16px;
  text-align: center;
}

.verdict-value {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 16px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-shadow: 0 0 20px rgba(100, 100, 120, 0.3);
  transition: all 0.3s ease;
}

.verdict-value.long {
  color: var(--decision-long);
  text-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
}

.verdict-value.short {
  color: var(--decision-short);
  text-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
}

.verdict-value.skip {
  color: var(--decision-skip);
}

.verdict-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.verdict-meta span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.verdict-meta strong {
  font-size: 18px;
  font-family: "Courier New", monospace;
  color: var(--cyber-blue);
}

.confidence-bar {
  height: 8px;
  background: rgba(30, 30, 45, 0.8);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.confidence-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyber-blue), var(--cyber-purple));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.verdict-driver {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.driver-label {
  font-size: 10px;
  color: var(--text-muted);
}

.driver-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--cyber-purple);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* -------------------------------------------------------------------------- */
/*  CONTEXT PANEL                                                             */
/* -------------------------------------------------------------------------- */

.context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.context-item {
  background: rgba(20, 20, 30, 0.5);
  padding: 10px;
  border-radius: 6px;
  text-align: center;
}

.context-item span {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.context-item strong {
  font-size: 12px;
  color: var(--text-primary);
}

.context-item strong.bullish {
  color: var(--decision-long);
}
.context-item strong.bearish {
  color: var(--decision-short);
}
.context-item strong.high {
  color: var(--warning-orange);
}
.context-item strong.extreme {
  color: var(--decision-short);
}

/* -------------------------------------------------------------------------- */
/*  SIMILAR CASES (RAG)                                                       */
/* -------------------------------------------------------------------------- */

.similar-panel .chip {
  font-size: 9px !important;
}

.similar-list {
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.similar-card {
  background: rgba(20, 25, 35, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.similar-card:hover {
  border-color: var(--cyber-purple);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.1);
}

.similar-card:last-child {
  margin-bottom: 0;
}

.similar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.similar-id {
  font-size: 10px;
  font-family: "Courier New", monospace;
  color: var(--text-muted);
}

.similar-score {
  font-size: 11px;
  font-weight: 600;
  color: var(--cyber-purple);
}

.similar-outcome {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.similar-outcome.win {
  background: rgba(16, 185, 129, 0.15);
  color: var(--decision-long);
}

.similar-outcome.loss {
  background: rgba(239, 68, 68, 0.15);
  color: var(--decision-short);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 20px;
  font-style: italic;
}

/* -------------------------------------------------------------------------- */
/*  NEWS CONTEXT                                                              */
/* -------------------------------------------------------------------------- */

.news-context {
  padding: 12px;
}

.news-context-item {
  background: rgba(20, 25, 35, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.news-headline {
  font-size: 11px;
  color: var(--text-primary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.news-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.news-age {
  font-size: 10px;
  color: var(--text-muted);
}

.news-impact {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning-orange);
}

.news-impact.high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--decision-short);
}

/* -------------------------------------------------------------------------- */
/*  RISK PANEL                                                                */
/* -------------------------------------------------------------------------- */

.risk-panel {
  background: linear-gradient(
    180deg,
    rgba(16, 185, 129, 0.02) 0%,
    var(--bg-panel) 100%
  );
}

.risk-display {
  padding: 16px;
  text-align: center;
}

.risk-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
}

.risk-icon {
  font-size: 24px;
}

.risk-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.risk-status.approved .risk-text {
  color: var(--decision-long);
}

.risk-status.rejected .risk-text {
  color: var(--decision-short);
}

.risk-status.killswitch .risk-text {
  color: var(--decision-short);
  animation: killswitch-flash 0.5s ease-in-out infinite;
}

@keyframes killswitch-flash {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.risk-reason {
  font-size: 11px;
  color: var(--text-secondary);
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* -------------------------------------------------------------------------- */
/*  FOOTER                                                                    */
/* -------------------------------------------------------------------------- */

.brain-footer {
  margin-top: 20px;
  padding: 16px 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

.brain-footer p {
  font-size: 11px;
  color: var(--text-muted);
}

.brain-footer a {
  color: var(--matrix-green);
  text-decoration: none;
  margin-left: 8px;
}

.brain-footer a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------------------- */
/*  LOADING STATE                                                             */
/* -------------------------------------------------------------------------- */

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 30px;
  font-size: 12px;
}

.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--matrix-green);
  border-radius: 50%;
  margin-left: 10px;
  animation: spin 1s linear infinite;
}

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

/* -------------------------------------------------------------------------- */
/*  RESPONSIVE                                                                */
/* -------------------------------------------------------------------------- */

@media (max-width: 1400px) {
  .brain-dashboard {
    grid-template-columns: 240px 1fr 280px;
  }
}

@media (max-width: 1200px) {
  .brain-dashboard {
    grid-template-columns: 1fr;
  }

  .brain-sidebar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }

  .terminal-window {
    min-height: 300px;
  }
}

@media (max-width: 768px) {
  .brain-dashboard {
    gap: 12px;
  }

  .decision-item {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .verdict-value {
    font-size: 28px;
  }
}
