/**
 * Estilos canónicos para el Simulador de Dron 3D y Vuelo Libre FPV
 * Fijate Tools - fijate.com
 */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores temáticos y cabina */
  --bg-primary: #0e1117;
  --bg-card: #151a23;
  --bg-card-hover: #1c2230;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #00e5ff;
  
  --text-main: #f0f3f8;
  --text-muted: #9aa5b8;
  
  --accent-cyan: #00e5ff;
  --accent-green: #00ff88;
  --accent-amber: #ffaa00;
  --accent-red: #ff3b30;
  
  --hud-color: #00ff88;
  --hud-glow: rgba(0, 255, 136, 0.35);
}

/* Reset de contención */
body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  margin-top: 0;
  color: var(--text-main);
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* =========================================================================
   CONTENEDOR DEL VISOR 3D Y TELEMETRÍA OSD (HUD)
   ========================================================================= */
.drone-viewport-card {
  position: relative;
  width: 100%;
  background-color: #000000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-color);
  aspect-ratio: 16 / 9;
  min-height: 380px;
  max-height: 720px;
  display: flex;
  flex-direction: column;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

#canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Capa HUD / OSD FPV */
.osd-hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  box-sizing: border-box;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--hud-color);
  text-shadow: 0 0 4px var(--hud-glow), 0 1px 2px rgba(0, 0, 0, 0.9);
  user-select: none;
  z-index: 10;
}

/* Filas superior e inferior del HUD */
.osd-row-top,
.osd-row-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.osd-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: rgba(10, 14, 20, 0.65);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 255, 136, 0.2);
  backdrop-filter: blur(4px);
}

.osd-label {
  font-size: 0.68rem;
  color: #a8d5ba;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.osd-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
}

.osd-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-angle {
  background: rgba(0, 229, 255, 0.25);
  color: #00e5ff;
  border: 1px solid #00e5ff;
}

.badge-acro {
  background: rgba(255, 59, 48, 0.25);
  color: #ff3b30;
  border: 1px solid #ff3b30;
}

.badge-gps {
  background: rgba(0, 255, 136, 0.25);
  color: #00ff88;
  border: 1px solid #00ff88;
}

.osd-gamepad-badge {
  font-size: 0.7rem;
  color: #778899;
}

.osd-gamepad-badge.active {
  color: #00ff88;
  font-weight: 700;
}

/* Centro del HUD: Retícula y horizonte artificial */
.osd-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.osd-crosshair {
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(0, 255, 136, 0.6);
  border-radius: 50%;
  position: relative;
}

.osd-crosshair::before,
.osd-crosshair::after {
  content: '';
  position: absolute;
  background: rgba(0, 255, 136, 0.8);
}

.osd-crosshair::before {
  top: 50%;
  left: -8px;
  width: 40px;
  height: 1.5px;
  transform: translateY(-50%);
}

.osd-crosshair::after {
  left: 50%;
  top: -8px;
  height: 40px;
  width: 1.5px;
  transform: translateX(-50%);
}

/* Barra del horizonte artificial */
.osd-horizon-line {
  position: absolute;
  width: 110px;
  height: 2px;
  background: rgba(0, 255, 136, 0.75);
  box-shadow: 0 0 6px rgba(0, 255, 136, 0.8);
  transition: transform 0.05s linear;
}

/* Barra lateral vertical de acelerador */
.osd-throttle-gauge {
  position: absolute;
  left: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 120px;
  background: rgba(10, 14, 20, 0.7);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.osd-throttle-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, #00ff88, #00e5ff);
  transition: height 0.05s ease-out;
}

/* Aviso de impacto/choque */
.osd-crash-alert {
  display: none;
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 59, 48, 0.88);
  color: #ffffff;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: pulseCrash 0.8s infinite alternate;
}

.osd-crash-alert.active {
  display: block;
}

@keyframes pulseCrash {
  from { opacity: 0.7; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1.0; transform: translate(-50%, -50%) scale(1.04); }
}

/* =========================================================================
   JOYSTICKS TÁCTILES FLOTANTES PARA MÓVIL
   ========================================================================= */
.mobile-touch-container {
  display: none;
  position: absolute;
  bottom: 0.8rem;
  left: 0;
  width: 100%;
  justify-content: space-between;
  padding: 0 1.2rem;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 20;
}

.touch-stick-zone {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(15, 22, 33, 0.5);
  border: 2px dashed rgba(0, 229, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
}

.touch-stick-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #00e5ff 0%, #0088aa 100%);
  box-shadow: 0 2px 8px rgba(0, 229, 255, 0.5);
  pointer-events: none;
  will-change: transform;
}

/* =========================================================================
   PANEL DE CONTROL, BOTONERA Y AJUSTES
   ========================================================================= */
.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
}

.quick-actions-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 42px;
  height: 42px;
  padding: 0 1rem;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background-color: #212836;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

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

.btn-action:active {
  transform: translateY(1px);
}

.btn-action.btn-primary {
  background: linear-gradient(135deg, #00b4d8 0%, #0077b6 100%);
  color: #ffffff;
  border: none;
}

.btn-action.btn-primary:hover {
  filter: brightness(1.1);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Desplegables según regla canónica */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 0.85rem;
  background-color: #19202c;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  box-sizing: border-box;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

/* Deslizador de rango */
.range-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 42px;
}

.form-range {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.range-val {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent-cyan);
  min-width: 36px;
}

/* =========================================================================
   GUÍA DE CONTROLES Y TELEMETRÍA EDUCATIVA
   ========================================================================= */
.guide-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.info-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
}

.info-card h3 {
  font-size: 1.08rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.controls-table th,
.controls-table td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-align: left;
}

.controls-table th {
  color: var(--text-muted);
  font-weight: 600;
}

kbd {
  display: inline-block;
  background: #242c3b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #00e5ff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* =========================================================================
   MODAL ACCESIBLE (Sin alertas nativas)
   ========================================================================= */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background-color: #171d27;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  max-width: 540px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.btn-close-modal:hover {
  color: #ffffff;
}

.modal-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #c0cbda;
}

.modal-footer {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

/* =========================================================================
   RESPONSIVIDAD Y AJUSTES MÓVILES
   ========================================================================= */
@media (max-width: 768px) {
  .drone-viewport-card {
    aspect-ratio: 4 / 3;
    min-height: 320px;
  }

  .osd-hud-overlay {
    padding: 0.5rem;
    font-size: 0.72rem;
  }

  .osd-value {
    font-size: 0.88rem;
  }

  .quick-actions-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .mobile-touch-container {
    display: flex;
  }
}
