/* ============================================
   FenceX - Reaction Trainer Console
   High-tech mission-control dashboard
   ============================================ */

.training-page {
  --fx-blue: var(--color-accent, #3b82f6);
  --con-bg: rgba(8, 15, 27, 0.82);
  --con-border: rgba(104, 154, 255, 0.14);
  --con-border-hi: rgba(126, 169, 255, 0.3);
  --con-text: var(--color-text-primary, #eaf2ff);
  --con-muted: var(--color-text-muted, rgba(234, 242, 255, 0.55));
  --con-surface: rgba(255, 255, 255, 0.03);
  --con-mono: 'JetBrains Mono', 'SF Mono', monospace;
}

:root[data-theme='light'] .training-page {
  --con-bg: rgba(255, 255, 255, 0.92);
  --con-border: rgba(30, 58, 110, 0.1);
  --con-border-hi: rgba(30, 58, 110, 0.22);
  --con-text: var(--color-text-primary, #0f172a);
  --con-muted: var(--color-text-muted, rgba(15, 23, 42, 0.55));
  --con-surface: rgba(15, 23, 42, 0.03);
}

body.training-page {
  background:
    radial-gradient(1000px 520px at 10% -10%, rgba(42, 117, 255, 0.14), transparent 62%),
    linear-gradient(180deg, #040910 0%, #070d16 48%, #050a12 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

body.training-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(70, 132, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 132, 255, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
}

:root[data-theme='light'] body.training-page {
  background:
    radial-gradient(980px 520px at 10% -15%, rgba(60, 123, 255, 0.08), transparent 62%),
    linear-gradient(180deg, #f7f9fd 0%, #edf2fa 52%, #e8eef8 100%);
}

:root[data-theme='light'] body.training-page::before {
  background:
    linear-gradient(rgba(63, 110, 202, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63, 110, 202, 0.06) 1px, transparent 1px);
  opacity: 0.10;
}

/* ═══ Console Shell ═══ */
.fx-console {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ═══ Top Bar ═══ */
.fx-console-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  background: var(--con-bg);
  border: 1px solid var(--con-border);
  border-radius: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.fx-topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.fx-topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--con-border);
  background: var(--con-surface);
  font-size: 0.78rem;
  font-weight: 600;
}

.fx-topbar-badge.is-online {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.fx-topbar-badge.is-online .fx-topbar-badge-label {
  color: #22c55e;
}

.fx-topbar-badge-label {
  color: var(--con-text);
}

.fx-topbar-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--con-mono);
  font-size: 0.7rem;
  color: var(--con-muted);
}

.fx-topbar-sep {
  opacity: 0.3;
}

.fx-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ═══ Hero Header ═══ */
.fx-console-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 0 8px;
  flex-wrap: wrap;
}

.fx-console-heading {
  margin: 4px 0 0;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--con-text);
}

.fx-console-accent {
  background: linear-gradient(135deg, #3b82f6 0%, #a78bfa 60%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.fx-console-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ═══ Main Console Grid ═══ */
.fx-console-grid {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 16px;
  align-items: start;
}

/* Zone Panel */
.fx-console-zone-panel {
  background: var(--con-bg);
  border: 1px solid var(--con-border);
  border-radius: 18px;
  padding: 22px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  position: relative;
  overflow: hidden;
}

.fx-console-zone-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(165deg, rgba(59, 130, 246, 0.06), transparent 40%);
  pointer-events: none;
}

.fx-console-zone-panel:hover {
  border-color: var(--con-border-hi);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

:root[data-theme='light'] .fx-console-zone-panel:hover {
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.fx-console-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.fx-panel-label {
  font-family: var(--con-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--con-muted);
}

.fx-panel-indicator {
  font-family: var(--con-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--con-muted);
}

.fx-panel-indicator.is-go { color: #93c5fd; }
.fx-panel-indicator.is-nogo { color: #fca5a5; }

.fx-console-zone-panel .fx-zone-grid {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto 14px;
  gap: 14px;
}

.fx-console-zone-panel .fx-zone-tile {
  min-height: 130px;
  border-radius: 16px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border-color: var(--con-border);
  position: relative;
  overflow: hidden;
  flex-direction: column;
  gap: 0;
  padding: 8px 8px 12px;
}

.fx-console-zone-panel .fx-zone-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at center, rgba(59, 130, 246, 0.04), transparent 70%);
  pointer-events: none;
}

:root[data-theme='light'] .fx-console-zone-panel .fx-zone-tile {
  background: linear-gradient(150deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.01));
}

.fx-console-zone-panel .fx-zone-label {
  font-size: clamp(2rem, 4.5vw, 3rem);
  position: relative;
  z-index: 1;
}

.fx-console-zone-panel .fx-last-rep-strip {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
}

/* ═══ Stats Sidebar ═══ */
.fx-console-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fx-stat-block {
  background: var(--con-bg);
  border: 1px solid var(--con-border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 200ms ease;
}

.fx-stat-block:hover {
  border-color: var(--con-border-hi);
}

.fx-stat-block .fx-stat-label {
  font-family: var(--con-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--con-muted);
}

.fx-stat-block .fx-stat-value {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--con-text);
}

.fx-stat-primary {
  border-color: rgba(59, 130, 246, 0.25);
  background:
    linear-gradient(150deg, rgba(59, 130, 246, 0.08), transparent 50%),
    var(--con-bg);
}

.fx-stat-primary .fx-stat-value {
  color: #93c5fd;
}

:root[data-theme='light'] .fx-stat-primary .fx-stat-value {
  color: #2563eb;
}

.fx-stat-session {
  border-style: dashed;
}

/* ═══ Best Scores Strip ═══ */
.fx-console-scores {
  display: flex;
  gap: 12px;
}

.fx-score-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: var(--con-bg);
  border: 1px solid var(--con-border);
  border-radius: 10px;
  transition: border-color 200ms ease;
}

.fx-score-chip:hover {
  border-color: var(--con-border-hi);
}

.fx-score-speed {
  font-family: var(--con-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--con-muted);
}

.fx-score-chip strong {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--con-text);
}

/* ═══ Collapsible Panels ═══ */
.fx-console-panel {
  background: var(--con-bg);
  border: 1px solid var(--con-border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.fx-console-panel:hover {
  border-color: rgba(126, 169, 255, 0.22);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

:root[data-theme='light'] .fx-console-panel:hover {
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.fx-console-panel-toggle {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--con-text);
  transition: background 0.15s ease;
}

.fx-console-panel-toggle::-webkit-details-marker { display: none; }

.fx-console-panel-toggle:hover {
  background: var(--con-surface);
}

.fx-console-panel-toggle svg {
  color: var(--con-muted);
  flex-shrink: 0;
  opacity: 0.7;
}

.fx-console-panel[open] .fx-console-panel-toggle {
  border-bottom: 1px solid var(--con-border);
}

.fx-console-panel-body {
  padding: 18px 20px 22px;
}

.fx-toggle-count {
  margin-left: auto;
  font-family: var(--con-mono);
  font-size: 0.7rem;
  color: var(--con-muted);
}

/* Log Toolbar */
.fx-log-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--con-border);
}

.fx-filter-input {
  margin-left: auto;
  max-width: 180px;
}

/* ═══ Config Panel ═══ */
.fx-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.fx-config-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--con-border);
  background: var(--con-surface);
}

.fx-config-title {
  margin: 0 0 2px;
  font-family: var(--con-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--con-muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--con-border);
}

.fx-config-readouts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fx-readout {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(104, 154, 255, 0.08);
  transition: border-color 150ms ease, background 150ms ease;
}

.fx-readout:hover {
  border-color: var(--con-border);
  background: rgba(255, 255, 255, 0.04);
}

:root[data-theme='light'] .fx-readout {
  background: rgba(15, 23, 42, 0.02);
  border-color: rgba(30, 58, 110, 0.06);
}

:root[data-theme='light'] .fx-readout:hover {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(30, 58, 110, 0.12);
}

.fx-readout span {
  font-size: 0.75rem;
  color: var(--con-muted);
}

.fx-readout strong {
  font-family: var(--con-mono);
  font-size: 0.82rem;
  color: var(--con-text);
}

/* ═══ Shared Components ═══ */
.fx-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff7676;
  box-shadow: 0 0 6px rgba(255, 118, 118, 0.5);
  flex-shrink: 0;
}

.fx-status-dot.connected {
  background: #00ffb1;
  box-shadow: 0 0 6px rgba(0, 255, 177, 0.5);
}

.fx-divider { opacity: 0.3; }

.fx-muted {
  color: var(--con-muted);
  font-size: 0.9rem;
}

.fx-badge {
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(90, 141, 255, 0.15);
  color: var(--fx-blue);
  font-size: 0.72rem;
  font-weight: 600;
}

.fx-badge-warning {
  background: rgba(255, 182, 72, 0.2);
  color: #ffb648;
}

.fx-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--color-accent, #2a75ff);
  margin: 0;
}

/* Footer styles in main.css */

/* ═══ Legacy (hidden) ═══ */
.fx-legacy-hidden {
  display: none !important;
}

.fx-hardware-panel-inner,
.fx-hw-card,
.fx-status-list,
.fx-status-chip,
.fx-session-controls,
.fx-export-row,
.fx-panel-close {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fx-status-list { list-style: none; padding: 0; margin: 0; }
.fx-status-list li { display: flex; justify-content: space-between; font-size: 0.85rem; }
.fx-status-chip { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; }
.fx-status-chip.offline { background: rgba(255, 69, 69, 0.15); color: #ff7676; }
.fx-status-chip.online { background: rgba(0, 200, 130, 0.15); color: #00ffb1; }

/* Session cards (for history) */
.fx-session-card { background: var(--con-surface); border: 1px solid var(--con-border); border-radius: 12px; padding: 16px 20px; cursor: pointer; transition: all 0.2s ease; }
.fx-session-card:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.15); }
.fx-session-card-header, .fx-session-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fx-session-date { font-weight: 600; color: var(--con-text); font-size: 0.95rem; }
.fx-session-duration { font-size: 0.85rem; color: var(--con-muted); }
.fx-session-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.fx-session-stat, .fx-stat { display: flex; flex-direction: column; gap: 2px; text-align: center; }
.fx-session-stat-label, .fx-stat-label { font-size: 0.75rem; color: var(--con-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.fx-session-stat-value { font-size: 1rem; font-weight: 600; color: var(--con-text); }
.fx-session-stat-value.good, .fx-stat-value.fx-stat-good { color: #00ffb1; }
.fx-session-stat-value.warn, .fx-stat-value.fx-stat-ok { color: #ffb74d; }
.fx-session-stat-value.bad, .fx-stat-value.fx-stat-warn { color: #ff7676; }
.fx-session-tempo { margin-top: 8px; font-size: 0.75rem; color: var(--con-muted); font-family: monospace; }
.fx-session-coach { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--con-border); display: flex; flex-direction: column; gap: 6px; }
.fx-coach-tip { font-size: 0.85rem; color: var(--fx-blue); display: flex; align-items: flex-start; gap: 6px; }
.fx-coach-tip::before { content: "→"; font-weight: 600; flex-shrink: 0; }
.fx-coach-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--con-border); }
.fx-coach-title { font-size: 0.8rem; font-weight: 600; color: var(--fx-blue); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; }
.fx-coach-drills { display: flex; flex-direction: column; gap: 6px; }
.fx-coach-drill { display: flex; align-items: flex-start; gap: 8px; font-size: 0.9rem; color: var(--con-text); }
.fx-coach-drill::before { content: "→"; color: var(--fx-blue); font-weight: 600; }
.fx-session-empty { text-align: center; padding: 32px 20px; color: var(--con-muted); }

/* ═══ Responsive ═══ */
@media (max-width: 900px) {
  .fx-console-grid {
    grid-template-columns: 1fr;
  }

  .fx-console-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .fx-config-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

@media (max-width: 640px) {
  .fx-console {
    padding: 0 14px 60px;
    gap: 12px;
  }

  .fx-console-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
  }

  .fx-topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .fx-console-hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 0 4px;
  }

  .fx-console-heading {
    font-size: 1.8rem;
  }

  .fx-console-hero-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .fx-console-hero-actions .fx-btn-lg {
    flex: 1;
  }

  .fx-console-zone-panel .fx-zone-tile {
    min-height: 96px;
  }

  .fx-console-zone-panel .fx-zone-label {
    font-size: 2rem;
  }

  .fx-console-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .fx-stat-block .fx-stat-value {
    font-size: 1.2rem;
  }

  .fx-console-scores {
    flex-direction: column;
    gap: 8px;
  }

  .fx-log-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .fx-filter-input {
    margin-left: 0;
    max-width: none;
    width: 100%;
  }

  .fx-session-stats {
    grid-template-columns: repeat(2, 1fr);
  }

}

@media (max-width: 480px) {
  .fx-console-stats {
    grid-template-columns: 1fr;
  }

  .fx-topbar-meta {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-console-zone-panel,
  .fx-stat-block,
  .fx-score-chip,
  .fx-console-panel {
    transition: none !important;
  }
}
