/* 
  style.css - 4D Geospace Explorer
  Scientific Data Visualization Suite for Earth's Magnetosphere & Magnetosheath Jets
  Science Data Bank (ScienceDB DOI: 10.57760/sciencedb.space.03597)
*/

:root {
  --bg-primary: #050811;
  --bg-secondary: #0c1220;
  --bg-glass: rgba(12, 18, 32, 0.85);
  --bg-glass-card: rgba(18, 27, 48, 0.75);
  --border-glass: rgba(0, 229, 255, 0.18);
  --border-glass-hover: rgba(0, 229, 255, 0.45);
  
  --color-text-main: #f0f4fc;
  --color-text-muted: #8e9cb2;
  --color-text-dim: #5c6b84;
  
  --accent-cyan: #00e5ff;
  --accent-blue: #2979ff;
  --accent-red: #ff3344;
  --accent-amber: #ffb300;
  --accent-green: #00e676;
  --accent-purple: #d500f9;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Fira Code", monospace;
  
  --shadow-neon-cyan: 0 0 15px rgba(0, 229, 255, 0.35);
  --shadow-neon-red: 0 0 15px rgba(255, 51, 68, 0.35);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--color-text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Top Header */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  padding: 0 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  background: linear-gradient(135deg, #00e5ff 0%, #2979ff 100%);
  color: #050811;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-subtitle {
  font-size: 11px;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dataset-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid var(--border-glass);
  color: var(--accent-cyan);
  text-decoration: none;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.dataset-badge:hover {
  background: rgba(0, 229, 255, 0.18);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-neon-cyan);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--color-text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-glass-hover);
  color: var(--accent-cyan);
}

/* Main Visual Layout */
#main-view {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* 3D WebGL Canvas Viewport */
#viewport-container {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at 50% 50%, #081022 0%, #03060c 100%);
  overflow: hidden;
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 3D HUD Overlays */
.viewport-hud {
  position: absolute;
  pointer-events: none;
}

#sun-vector-indicator {
  top: 16px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 179, 0, 0.3);
  color: var(--accent-amber);
  font-family: var(--font-mono);
  font-size: 11px;
}

#sun-vector-indicator .pulse-sun {
  width: 8px;
  height: 8px;
  background: var(--accent-amber);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-amber);
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 1; }
}

#spacecraft-target-reticle {
  bottom: 20px;
  left: 20px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-title {
  color: var(--accent-cyan);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

/* Left Control Panel */
#left-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  bottom: 100px;
  width: 280px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
}

.panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-scroll::-webkit-scrollbar {
  width: 5px;
}
.panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

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

/* Toggle Switch Group */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-main);
  cursor: pointer;
}

.color-bullet {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* Custom Checkbox / Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-toggle {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .25s;
  border-radius: 18px;
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s;
  border-radius: 50%;
}

input:checked + .slider-toggle {
  background-color: var(--accent-cyan);
}

input:checked + .slider-toggle:before {
  transform: translateX(16px);
  background-color: #050811;
}

/* Camera Buttons Grid */
.camera-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.btn-cam {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-main);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
}

.btn-cam:hover, .btn-cam.active {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Select Inputs */
.select-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--color-text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.select-input:focus {
  border-color: var(--accent-cyan);
}

/* Right Analytics Panel */
#right-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 100px;
  width: 360px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
}

/* Metric Cards Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric-card {
  background: var(--bg-glass-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-title {
  font-size: 10px;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.metric-unit {
  font-size: 10px;
  color: var(--color-text-dim);
}

/* Polar Canvas Box */
.polar-canvas-box {
  background: #03060c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

#polar-canvas {
  width: 100%;
  max-width: 240px;
  height: 240px;
  cursor: crosshair;
}

.polar-probe-readout {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-cyan);
  text-align: center;
  margin-top: 6px;
  min-height: 16px;
}

/* Telemetry Chart Boxes */
.telemetry-box {
  background: var(--bg-glass-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.canvas-chart {
  width: 100%;
  height: 85px;
}

/* Bottom 4D Time Controller Bar */
#timeline-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 1120px);
  background: var(--bg-glass);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 10px 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.timeline-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-ctrl {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--color-text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.btn-ctrl:hover {
  background: var(--accent-cyan);
  color: #050811;
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-neon-cyan);
}

.btn-ctrl.btn-primary {
  background: linear-gradient(135deg, #00e5ff 0%, #2979ff 100%);
  color: #050811;
  border: none;
  width: 36px;
  height: 36px;
  font-size: 15px;
}

.time-display {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cyan);
  min-width: 110px;
  text-align: center;
}

.time-slider-container {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}

.time-slider {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}

.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-cyan);
}

/* Stage Jump Chips */
.stages-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-x: auto;
}

.stage-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.stage-chip:hover, .stage-chip.active {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.stage-chip.highlight-impact {
  border-color: rgba(255, 51, 68, 0.5);
  color: var(--accent-red);
}

.stage-chip.highlight-impact:hover, .stage-chip.highlight-impact.active {
  background: rgba(255, 51, 68, 0.2);
  border-color: var(--accent-red);
  box-shadow: var(--shadow-neon-red);
}

/* Modal Styling */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(3, 6, 12, 0.85);
  backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  width: min(90vw, 720px);
  max-height: 85vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  line-height: 1.6;
  font-size: 13px;
  color: var(--color-text-main);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body h4 {
  color: var(--accent-cyan);
  font-size: 14px;
  margin-top: 6px;
}

.modal-body code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Responsive collapse on smaller screens */
@media (max-width: 1200px) {
  #left-panel { width: 240px; }
  #right-panel { width: 300px; }
}

@media (max-width: 900px) {
  #left-panel, #right-panel {
    display: none;
  }
}
