/* Estilos para el simulador de túnel de viento 2D y aerodinámica */

:root {
  --bg-primary: #0a0f1d;
  --bg-card: rgba(15, 23, 42, 0.78);
  --bg-card-border: rgba(56, 189, 248, 0.18);
  --bg-canvas: #060a12;
  --bg-control: rgba(15, 23, 42, 0.65);
  --bg-control-card: rgba(30, 41, 59, 0.45);
  --border-control: rgba(56, 189, 248, 0.25);
  --border-subtle: rgba(148, 163, 184, 0.14);
  --bg-hud: rgba(15, 23, 42, 0.88);
  --bg-modal: #0f172a;
  --bg-slider-track: #334155;
  --bg-formula: rgba(15, 23, 42, 0.75);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-cyan: #38bdf8;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-border: rgba(2, 132, 199, 0.22);
  --bg-canvas: #0b1120;
  --bg-control: #ffffff;
  --bg-control-card: #f1f5f9;
  --border-control: rgba(2, 132, 199, 0.35);
  --border-subtle: rgba(203, 213, 225, 0.9);
  --bg-hud: rgba(248, 250, 252, 0.94);
  --bg-modal: #ffffff;
  --bg-slider-track: #cbd5e1;
  --bg-formula: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --accent-cyan: #0284c7;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout de la herramienta con ancho canónico */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

/* Tarjeta principal contenedora */
.wind-tunnel-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25);
}

/* Cabecera interna y controles rápidos */
.tunnel-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.tunnel-intro h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.25rem 0;
  color: var(--text-main);
}

.tunnel-intro p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.tunnel-quick-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Botones genéricos de acción */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-control);
  background: var(--bg-control);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border-color: #38bdf8;
  color: #ffffff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.4);
}

/* Área central de simulación: Canvas y visor HUD */
.tunnel-view-container {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7);
  background: var(--bg-canvas);
}

.tunnel-canvas-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

#wind-tunnel-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}

/* Barra de telemetría superior HUD */
.telemetry-hud-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  background: var(--bg-hud);
  border-bottom: 1px solid var(--border-control);
  padding: 0.75rem 1rem;
}

.telemetry-item {
  display: flex;
  flex-direction: column;
}

.telemetry-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: none;
  color: var(--text-muted);
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.telemetry-badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  align-self: flex-start;
  margin-top: 0.25rem;
}

.badge-info {
  background: rgba(56, 189, 248, 0.15);
  color: #0284c7;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

[data-theme="dark"] .badge-info {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

[data-theme="dark"] .badge-success {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .badge-warning {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: rgba(244, 63, 94, 0.18);
  color: #e11d48;
  border: 1px solid rgba(244, 63, 94, 0.4);
  animation: pulse-danger 1.5s infinite;
}

[data-theme="dark"] .badge-danger {
  color: #fb7185;
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Panel de controles y opciones */
.tunnel-controls-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.control-group-card {
  background: var(--bg-control-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.control-group-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.85rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

/* Desplegables conformes a reglas de viewport */
.control-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  min-height: 40px;
  background: var(--bg-control);
  border: 1px solid var(--border-control);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
}

.control-select option {
  background: var(--bg-modal);
  color: var(--text-main);
}

/* Sliders interactivos */
.slider-container {
  margin-bottom: 0.85rem;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.slider-val-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan);
}

.range-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-slider-track);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
  transition: transform 0.1s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Botoneras de visualización */
.vis-mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.btn-vis-mode {
  min-height: 40px;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-control);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-vis-mode:hover {
  border-color: var(--accent-cyan);
  color: var(--text-main);
}

.btn-vis-mode.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Casillas de verificación */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.65rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-cyan);
}

/* Panel de herramientas de modelado y dibujo */
.brush-tools-panel {
  margin-top: 0.65rem;
}

.brush-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.btn-brush {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 44px;
  padding: 0.35rem 0.2rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-control);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-brush svg {
  flex-shrink: 0;
  stroke: currentColor;
}

.btn-brush:hover {
  border-color: var(--accent-cyan);
  color: var(--text-main);
}

.btn-brush.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.btn-brush.btn-brush-clear:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* Chips de selección rápida de grosor */
.brush-size-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.btn-size-chip {
  min-height: 36px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-control);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  padding: 0 0.3rem;
}

.btn-size-chip:hover {
  border-color: var(--accent-cyan);
  color: var(--text-main);
}

.btn-size-chip.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 700;
}

/* Sección explicativa de física y FAQ */
.tunnel-explanation-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.tunnel-explanation-section h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-main);
  margin: 0 0 0.75rem 0;
}

.tunnel-explanation-section p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.formula-box {
  background: var(--bg-formula);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 1rem 0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--accent-cyan);
  overflow-x: auto;
}

/* Modal canónico de teoría */
.tunnel-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
}

.tunnel-modal-overlay.active {
  display: flex;
}

.tunnel-modal-card {
  background: var(--bg-modal);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin: 0;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.modal-body h4 {
  color: var(--text-main);
  font-family: var(--font-heading);
  margin: 1.25rem 0 0.5rem 0;
}

/* Responsividad para móviles */
@media (max-width: 768px) {
  .wind-tunnel-card {
    padding: 1rem;
  }

  .tunnel-top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .tunnel-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
  }

  .tunnel-quick-actions .btn-action {
    width: 100%;
    min-height: 40px;
  }

  .telemetry-hud-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .tunnel-controls-panel {
    grid-template-columns: 1fr;
  }
}
