/* Futuristic Neon CSS Styles for FPV Drone Simulator */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Outfit:wght@300;400;600&display=swap');

:root {
  --bg-color: #05050d;
  --panel-bg: rgba(13, 15, 30, 0.75);
  --panel-border: rgba(0, 255, 170, 0.15);
  --accent-neon: #00ffaa;
  --accent-magenta: #ff00ff;
  --accent-cyan: #00ffff;
  --text-primary: #f0f3ff;
  --text-muted: #8c9bb3;
  --button-hover: rgba(0, 255, 170, 0.2);
  --font-display: 'Orbitron', monospace;
  --font-sans: 'Outfit', sans-serif;
  --shadow-neon: 0 0 15px rgba(0, 255, 170, 0.35);
  --shadow-magenta: 0 0 15px rgba(255, 0, 255, 0.35);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header Styling */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(8, 9, 20, 0.9);
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 2px;
  background: linear-gradient(90deg, var(--accent-neon), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo span {
  font-size: 0.8rem;
  font-weight: 400;
  border: 1px solid var(--accent-neon);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent-neon);
  -webkit-text-fill-color: initial;
}

.status-bar {
  display: flex;
  gap: 20px;
  font-family: var(--font-display);
  font-size: 0.85rem;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ff3366; /* red default */
}

.status-indicator.active {
  background-color: var(--accent-neon);
  box-shadow: var(--shadow-neon);
}

/* Main Layout */
main {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  position: relative; /* Positioning context for slide-over overlays */
}

/* Left Canvas Area */
.viewport-container {
  position: relative;
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  padding: 0;
  background: radial-gradient(circle at center, #0f1026 0%, #05050d 100%);
  overflow: hidden;
}

#sim-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background-color: #030308;
}

/* Floating Action Buttons Container */
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 20;
}

/* Floating Action Buttons */
.btn-toggle-menu, .btn-header-action {
  height: 40px;
  background: rgba(5, 5, 15, 0.855);
  border: 1px solid var(--panel-border);
  color: var(--accent-neon);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: all 0.2s ease;
}

.btn-toggle-menu {
  width: 40px;
  font-family: monospace;
  font-size: 1.2rem;
}

.btn-header-action {
  width: auto;
  padding: 0 14px;
  font-family: var(--font-sans), sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.btn-toggle-menu:hover, .btn-header-action:hover {
  background: var(--button-hover);
  border-color: var(--accent-neon);
  box-shadow: var(--shadow-neon);
}

.btn-header-action.active {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.4);
}



/* HUD Overlay overlay instructions */
.viewport-instructions {
  position: absolute;
  top: 24px;
  left: 24px;
  background: rgba(5, 5, 10, 0.7);
  border: 1px solid var(--panel-border);
  padding: 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.viewport-instructions span {
  color: var(--accent-neon);
}

/* Right Sidebar Dashboard Panel */
.dashboard-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 420px;
  height: 100%;
  z-index: 30;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(0); /* default: visible/expanded */
}

.tab-nav {
  display: flex;
  background: rgba(5, 6, 12, 0.9);
  border-bottom: 1px solid var(--panel-border);
}

.tab-btn {
  flex: 1;
  padding: 14px 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  border-bottom: 2px solid transparent;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(0, 255, 170, 0.05);
}

.tab-btn.active {
  color: var(--accent-neon);
  border-bottom-color: var(--accent-neon);
  background: rgba(0, 255, 170, 0.08);
  text-shadow: 0 0 8px rgba(0, 255, 170, 0.5);
}

.tab-content-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.tab-content.active {
  display: flex;
}

/* Section cards */
.panel-section {
  background: rgba(20, 24, 45, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-section h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 1px;
  color: var(--accent-cyan);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

/* Control elements */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.control-label span.value {
  color: var(--accent-neon);
  font-family: var(--font-display);
}

/* Custom sliders */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: #15182e;
  border-radius: 3px;
  outline: none;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-neon);
  cursor: pointer;
  box-shadow: var(--shadow-neon);
  transition: transform 0.1s ease;
}

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

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, rgba(0, 255, 170, 0.2) 0%, rgba(0, 255, 255, 0.2) 100%);
  border: 1px solid var(--accent-neon);
  color: var(--accent-neon);
  padding: 12px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 0 10px rgba(0, 255, 170, 0.1);
  text-align: center;
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(0, 255, 170, 0.4) 0%, rgba(0, 255, 255, 0.4) 100%);
  box-shadow: var(--shadow-neon);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  padding: 10px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-secondary.active {
  background: rgba(0, 255, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

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

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* Select option styling */
select {
  background-color: #121424;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

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

/* Calibration bars styling */
.cal-bar-container {
  display: grid;
  grid-template-columns: 80px 1fr 50px;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.75rem;
}

.cal-label {
  font-family: var(--font-display);
  color: var(--text-muted);
}

.cal-track {
  height: 12px;
  background-color: #121424;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cal-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-neon));
  border-radius: 6px;
  position: absolute;
  left: 0;
  width: 0%;
  transition: width 0.05s linear;
}

.cal-center-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-neon));
  border-radius: 6px;
  position: absolute;
  left: 50%;
  width: 0%;
  transition: width 0.05s linear, left 0.05s linear;
}

.cal-center-mark {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  background-color: rgba(255, 0, 255, 0.6);
  z-index: 2;
}

.cal-value {
  font-family: var(--font-display);
  text-align: right;
  color: var(--text-primary);
}

/* Calibration axis controls */
.axis-setup-row {
  display: grid;
  grid-template-columns: 80px 80px 1fr 60px;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

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

.axis-setup-row label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  color: var(--text-primary);
}

/* Invert Checkbox styling */
.checkbox-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-container input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  position: relative;
  background-color: #121424;
}

.checkbox-container input[type="checkbox"]:checked + .checkbox-custom {
  border-color: var(--accent-neon);
  background-color: rgba(0, 255, 170, 0.1);
}

.checkbox-container input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid var(--accent-neon);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Rates visualizer curve graph */
#rates-plot {
  width: 100%;
  height: 120px;
  background-color: #080914;
  border: 1px solid rgba(0, 255, 255, 0.1);
  border-radius: 8px;
  margin-top: 8px;
}

/* Real-time Telemetry Plotter */
#telemetry-plot {
  width: 100%;
  height: 150px;
  background-color: #080914;
  border: 1px solid rgba(255, 0, 255, 0.1);
  border-radius: 8px;
}

/* Raw inputs grid visualizer */
.raw-axes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 80px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.raw-axis-item {
  display: flex;
  justify-content: space-between;
}

.raw-axis-item span.val {
  color: var(--accent-cyan);
}

/* Modal styling */
.calibration-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 4, 10, 0.85);
  backdrop-filter: blur(10px);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.calibration-modal.show {
  display: flex;
}

.modal-content {
  background: #0f1122;
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent-cyan);
  letter-spacing: 1px;
}

.modal-body {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body span.step {
  color: var(--accent-neon);
  font-weight: bold;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Collapsible Panel Custom Behavior */
.dashboard-panel.collapsed {
  transform: translateX(100%);
  border-left-color: transparent;
}

/* Responsive styles for smaller screens, tablets, and phones */
@media (max-width: 850px) {
  header {
    padding: 8px 16px;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    position: relative; /* Positioning context for toggle button */
  }
  
  .status-bar {
    width: 100%;
    justify-content: space-between;
    font-size: 0.75rem;
    gap: 10px;
  }
  
  .dashboard-panel {
    position: absolute;
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 450px;
    z-index: 30;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0); /* default: expanded/slid up */
  }
  
  .dashboard-panel.collapsed {
    transform: translateY(100%);
    border-top-color: transparent;
    height: 450px;
  }
  
  .header-actions {
    position: absolute;
    top: 12px;
    right: 16px;
  }
  
  .btn-toggle-menu {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .btn-header-action {
    width: auto;
    padding: 0 10px;
    height: 36px;
    font-size: 0.7rem;
  }
}

/* Floating HUD Overlay at the bottom center of the canvas */
.hud-overlay-bottom {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}

.hud-overlay-bottom .status-bar,
.hud-overlay-bottom .header-actions {
  pointer-events: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.hud-overlay-bottom .status-bar {
  font-family: monospace;
  color: #00ffaa;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  font-size: 14px;
  font-weight: bold;
}

/* Override default static header actions margin/positions in this overlay */
.hud-overlay-bottom .header-actions {
  position: static;
  margin: 0;
  display: flex;
  gap: 8px;
}

/* Floating Menu Toggle button in top right of viewport, shifting left when dashboard opens */
.btn-toggle-menu#btn-toggle-menu {
  position: absolute;
  top: 16px;
  right: 24px;
  z-index: 40; /* Sit above the dashboard panel when opened */
  pointer-events: auto;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When the dashboard panel is open (not collapsed), shift the button left */
.dashboard-panel:not(.collapsed) ~ .btn-toggle-menu#btn-toggle-menu {
  right: 444px; /* 420px panel width + 24px offset */
}

/* On-Screen Virtual Controller (Joysticks) */
.virtual-joysticks-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 40px;
}

.joystick-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto; /* Allow touch/clicks inside the active zones */
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* Disable default scrolling/gestures */
  margin-bottom: 50px; /* Stay clear of bottom corner stats */
}

#joystick-left {
  align-self: flex-end;
}
#joystick-right {
  align-self: flex-end;
}

.joystick-ring {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(15, 17, 34, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(255, 255, 255, 0.05);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
}

.joystick-ring:active {
  cursor: grabbing;
}

.joystick-stick {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-cyan) 0%, #00b380 100%);
  box-shadow: 0 0 15px rgba(0, 255, 170, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 255, 170, 0.5);
  position: absolute;
  transition: transform 0.05s ease-out; /* Slight smoothing during drag updates, reset centers instantly */
}

.joystick-label {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  font-weight: bold;
}
