/* =========================================================================
   AIRFOIL & FLOWFIELD VISUALIZER - STYLESHEET
   ========================================================================= */

:root {
  --bg-deep: #070B0E;
  --bg-panel: #0E141B;
  --bg-card: #131B24;
  --border-line: #1F2E3D;
  --border-focus: #38BDF8;
  
  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  --accent-cyan: #38BDF8;
  --accent-green: #34D399;
  --accent-red: #F87171;
  --accent-amber: #FBBF24;
  --accent-purple: #C084FC;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-title: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-hud: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* =========================================================================
   1. TOP NAVIGATION
   ========================================================================= */
.top-nav {
  height: 60px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--border-line);
  border-color: var(--accent-cyan);
  transform: translateX(-2px);
}

.nav-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.3px;
}

.badge-aero {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 4px;
}

/* Telemetry In Header */
.nav-center-telemetry {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg-card);
  padding: 6px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-line);
}

.telem-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
}

.telem-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.telem-val {
  font-size: 0.95rem;
  color: var(--text-main);
  font-weight: 700;
}

.telem-item.highlight .telem-val {
  color: var(--accent-cyan);
}

.badge-stall {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  color: #FFF;
  background: var(--accent-red);
  padding: 2px 8px;
  border-radius: 4px;
  animation: stallPulse 1s infinite alternate;
}

@keyframes stallPulse {
  from { opacity: 0.7; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1.05); }
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--border-line);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

/* =========================================
   2. MAIN WORKSPACE
   ========================================= */
.workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Simulation Viewport */
.canvas-viewport {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, #0F1722 0%, #070B0E 100%);
  overflow: hidden;
  cursor: crosshair;
}

#simCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* HUD Overlay */
.canvas-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}

.view-mode-bar {
  display: flex;
  gap: 8px;
  pointer-events: all;
  background: rgba(14, 20, 27, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-line);
  width: fit-content;
  box-shadow: var(--shadow-hud);
}

.mode-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-pill:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.mode-pill.active {
  background: var(--accent-cyan);
  color: #070B0E;
  font-weight: 700;
}

/* Colorbar */
.colorbar-card {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(14, 20, 27, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-line);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hud);
  pointer-events: all;
  width: 240px;
}

.cb-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cb-gradient {
  height: 10px;
  border-radius: 4px;
  margin-bottom: 4px;
  background: linear-gradient(to right, #0044FF, #00D4FF, #00FF88, #FFEE00, #FF3300);
}

.cb-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

/* Polar Graph Card */
.polar-card {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(14, 20, 27, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-line);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hud);
  pointer-events: all;
}

.polar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.polar-status {
  font-size: 0.65rem;
  color: var(--accent-green);
  font-weight: 600;
}

#polarCanvas {
  display: block;
  border-radius: 4px;
  background: #090E13;
}

/* Hint */
.canvas-hint {
  align-self: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  background: rgba(14, 20, 27, 0.7);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* =========================================
   3. CONTROLS SIDEBAR
   ========================================= */
.controls-panel {
  width: 380px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

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

.panel-scroll::-webkit-scrollbar {
  width: 6px;
}
.panel-scroll::-webkit-scrollbar-thumb {
  background: var(--border-line);
  border-radius: 4px;
}

.ctrl-group {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.group-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-title i {
  color: var(--accent-cyan);
}

/* Presets */
.presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-btn {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-btn:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent-cyan);
}

.preset-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
  color: #FFF;
}

/* NACA Input */
.naca-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-deep);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.naca-input-wrap input {
  width: 50px;
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  outline: none;
  text-transform: uppercase;
}

/* Sliders */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.slider-info .val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.85rem;
}

.slider-info .val.highlight {
  color: var(--accent-cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #1B2633;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Toggles */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.switch-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}

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

.slider-round {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #1B2633;
  transition: 0.3s;
  border-radius: 20px;
  border: 1px solid var(--border-line);
}

.slider-round:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider-round {
  background-color: rgba(56, 189, 248, 0.3);
  border-color: var(--accent-cyan);
}

input:checked + .slider-round:before {
  transform: translateX(18px);
  background-color: var(--accent-cyan);
}

/* Checkbox Grid */
.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.chk-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.chk-label input[type="checkbox"] {
  accent-color: var(--accent-cyan);
  width: 14px;
  height: 14px;
}

/* Breakdown Grid */
.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bd-cell {
  background: var(--bg-deep);
  border: 1px solid var(--border-line);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bd-lbl {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}

.bd-val {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

/* =========================================
   4. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 1024px) {
  .controls-panel {
    width: 320px;
  }
  .nav-title {
    font-size: 1rem;
  }
  .badge-aero {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-container {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  .workspace {
    flex-direction: column;
    height: auto;
  }
  .canvas-viewport {
    height: 60vh;
    min-height: 400px;
  }
  .controls-panel {
    width: 100%;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border-line);
  }
  .nav-center-telemetry {
    display: none;
  }
}
