/**
 * Simulador 3D de Aparcamiento en Línea y Batería (Escuela de Maniobras)
 * Hoja de estilos canónica, HUD de autoescuela, telemetría y controles táctiles
 * (css/style.css)
 * fijate.com
 */

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

  /* Paleta cromática modo oscuro (por defecto) */
  --bg-primary: #0b0f17;
  --bg-surface: #131b2a;
  --bg-surface-elevated: #1a253a;
  --bg-glass: rgba(19, 27, 42, 0.82);
  --border-subtle: #24344d;
  --border-focus: #38bdf8;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #0ea5e9;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #ef4444;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.45), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

/* Modo claro institucional */
[data-theme="light"], body.theme-light {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-subtle: #cbd5e1;
  --border-focus: #0284c7;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
}

/* Base de layout */
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

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

/* Tipografías y encabezados */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  margin-top: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-mono {
  font-family: var(--font-mono);
}

/* Tarjeta principal del Simulador 3D */
.simulator-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Barra superior de configuración rápida */
.sim-toolbar {
  padding: 1rem 1.25rem;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.sim-toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.sim-field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Desplegables conformes a la regla táctil */
.sim-select {
  appearance: none;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.55rem 2.5rem 0.55rem 0.85rem;
  font-size: 0.9rem;
  font-family: var(--font-main);
  font-weight: 500;
  width: 100%;
  max-width: 260px;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 40px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.sim-select:focus {
  outline: none;
  border-color: var(--border-focus);
}

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

.btn-action-sm:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-focus);
}

.btn-action-sm.btn-primary {
  background: var(--accent-cyan);
  color: #0b0f17;
  border-color: var(--accent-cyan);
}

.btn-action-sm.btn-primary:hover {
  background: #38bdf8;
}

/* Área del visor 3D */
.sim-viewport-area {
  position: relative;
  width: 100%;
  height: 540px;
  background: #0f172a;
  overflow: hidden;
}

@media (max-width: 768px) {
  .sim-viewport-area {
    height: 440px;
  }
}

#sim-3d-canvas-container {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

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

/* HUD Superior: Tutor de Autoescuela */
.hud-tutor-overlay {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  max-width: 620px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 10;
}

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

.tutor-step-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #38bdf8;
  margin: 0;
}

.tutor-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: rgba(14, 165, 233, 0.2);
  color: #38bdf8;
}

.tutor-badge.ready {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
}

.tutor-badge.success {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
}

.tutor-instruction {
  font-size: 0.88rem;
  color: #f1f5f9;
  margin: 0 0 0.3rem;
  line-height: 1.4;
}

.tutor-hint {
  font-size: 0.78rem;
  color: #94a3b8;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* HUD Retrovisores Virtuales en Pantalla */
.hud-mirrors-box {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
}

@media (max-width: 900px) {
  .hud-mirrors-box {
    display: none; /* Ocultar en pantallas estrechas para no solapar el tutor */
  }
}

.mirror-card {
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 140px;
}

.mirror-title {
  color: var(--text-muted);
  font-weight: 600;
}

.mirror-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
}

.mirror-badge.active-ok {
  color: #34d399;
}

/* Modos de cámara flotantes */
.hud-camera-selector {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: flex;
  gap: 0.4rem;
  z-index: 10;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.btn-cam-mode {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cam-mode:hover {
  color: var(--text-main);
}

.btn-cam-mode.active {
  background: var(--accent-cyan);
  color: #0b0f17;
}

/* Telemetría inferior */
.sim-telemetry-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

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

.telemetry-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.telemetry-val.highlight-45 {
  color: #38bdf8;
  animation: pulse-glow 1s infinite alternate;
}

.telemetry-val.danger {
  color: var(--accent-rose);
}

.telemetry-val.warning {
  color: var(--accent-amber);
}

@keyframes pulse-glow {
  from { text-shadow: 0 0 4px rgba(56, 189, 248, 0.4); }
  to { text-shadow: 0 0 12px rgba(56, 189, 248, 0.9); }
}

/* Controles de conducción interactivos (Móvil y Escritorio) */
.sim-controls-panel {
  padding: 1.25rem;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  align-items: center;
}

/* Palanca de cambios (P - R - N - D) */
.gearbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gear-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.gear-buttons {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-surface);
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.btn-gear {
  width: 44px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-gear.active {
  background: var(--accent-cyan);
  color: #0b0f17;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.4);
}

/* Botones táctiles de volante y pedales */
.touch-controls-cluster {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

@media (min-width: 768px) {
  .touch-controls-cluster {
    width: auto;
  }
}

.steering-touch-group, .pedals-touch-group {
  display: flex;
  gap: 0.5rem;
  flex: 1 1 0%;
  min-width: 0;
}

.btn-touch-control {
  flex: 1 1 0%;
  height: 46px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-main);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: all 0.1s ease;
}

.btn-touch-control:active {
  background: var(--border-focus);
  color: #0b0f17;
}

.btn-touch-gas {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.btn-touch-gas:active {
  background: #10b981;
  color: #ffffff;
}

.btn-touch-brake {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-touch-brake:active {
  background: #ef4444;
  color: #ffffff;
}

/* Sección de Explicación y Guía Teórica de Autoescuela */
.school-guide-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.guide-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.guide-step-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.guide-step-num {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.guide-step-card h3 {
  font-size: 1.05rem;
  margin: 0;
}

.guide-step-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.guide-step-tip {
  font-size: 0.82rem;
  background: rgba(14, 165, 233, 0.1);
  border-left: 3px solid var(--accent-cyan);
  padding: 0.45rem 0.65rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #38bdf8;
}

/* Modales accesibles de reporte y examen DGT */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 23, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

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

.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

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

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

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

.dgt-badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
}

.dgt-badge.fail {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.dgt-badge.pass_warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
}

.dgt-badge.pass_perfect {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.dgt-stats-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.dgt-reasons-list {
  padding-left: 1.2rem;
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Acordeón FAQ Canónico */
.faq-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.25rem;
}

.faq-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface-elevated);
}

.faq-summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-summary::-webkit-details-marker {
  display: none;
}

.faq-summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--accent-cyan);
}

.faq-item[open] .faq-summary::after {
  content: '−';
}

.faq-content {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}
