/* ==========================================================================
   Laboratorio de Anatomía Mecánica 3D - Estilos Oficiales
   Fijate Tools - https://fijate.com
   Cumplimiento de estándares canónicos, modo oscuro Midnight Slate,
   controles táctiles móviles (>=40px) y contención visual estricta.
   ========================================================================== */

:root {
  /* Tipografías corporativas */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta cromática tema oscuro (predeterminado) */
  --bg-app: #0b0f17;
  --bg-card: #131b2a;
  --bg-card-subtle: #1c2638;
  --bg-input: #0f172a;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #06b6d4;

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

  /* Acentos de ingeniería mecánica */
  --primary: #06b6d4;        /* Cian cinemático */
  --primary-hover: #0891b2;
  --primary-glow: rgba(6, 182, 212, 0.25);
  --accent-gold: #f59e0b;     /* Latón / bronce */
  --accent-steel: #94a3b8;    /* Acero mecanizado */
  --accent-red: #ef4444;      /* Fuego / corte térmico */
  --accent-green: #10b981;    /* Marcha adelante / embragado */

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #0891b2;

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

  --primary: #0891b2;
  --primary-hover: #0e7490;
  --primary-glow: rgba(8, 145, 178, 0.2);
  --accent-gold: #d97706;
  --accent-steel: #475569;
  --accent-red: #dc2626;
  --accent-green: #059669;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.12);
}

/* --- Contención visual y reset canónico --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Layout institucional */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex: 1 0 auto;
}

/* Títulos y tipografía */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

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

/* Banner superior publicitario AdSense */
.tools-ad-banner-section {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 1.5rem;
  overflow: hidden;
  border-radius: var(--radius-md);
}

/* --- Cabecera de la herramienta --- */
.tool-header-block {
  text-align: center;
  margin-bottom: 0.5rem;
}

.tool-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-glow);
  border: 1px solid var(--primary);
  border-radius: 9999px;
  margin-bottom: 0.75rem;
}

.tool-header-block h1 {
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  margin-bottom: 0.5rem;
}

.tool-lead-desc {
  max-width: 840px;
  margin: 0 auto;
  font-size: 1rem;
  color: var(--text-muted);
}

/* --- Selector de Pestañas Principales --- */
.mech-tabs-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.6rem;
  background: var(--bg-card);
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.mech-tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  min-height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.mech-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.mech-tab-btn.active {
  color: var(--primary);
  background: var(--bg-card-subtle);
  border-color: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* --- Submodos específicos --- */
.submode-selector {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.submode-selector-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.submode-btn {
  padding: 0.45rem 0.9rem;
  min-height: 38px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.submode-btn:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}

.submode-btn.active {
  background: var(--primary);
  color: #0b0f17;
  font-weight: 700;
  border-color: var(--primary);
}

/* --- Contenedor del Visor 3D y HUD --- */
.viewer-3d-wrapper {
  position: relative;
  width: 100%;
  height: 560px;
  background: #0b0f17;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

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

/* HUD Superior flotante sobre el Canvas 3D */
.viewer-hud-top {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none; /* Dejar pasar toques al 3D salvo en botones */
  z-index: 10;
}

.viewer-hud-top > * {
  pointer-events: auto;
}

.hud-pill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
}

.hud-actions {
  display: flex;
  gap: 0.4rem;
}

.btn-hud-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-hud-action:hover {
  background: var(--bg-card);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* HUD Inferior: Presets de cámara y atajos */
.viewer-hud-bottom {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.viewer-hud-bottom > * {
  pointer-events: auto;
}

.camera-presets-group {
  display: flex;
  gap: 0.35rem;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.btn-cam-preset {
  padding: 0.35rem 0.7rem;
  min-height: 32px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-cam-preset:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.hud-instructions-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* --- Panel de Telemetría (Cockpit) --- */
.telemetry-cockpit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.telemetry-status-banner {
  grid-column: 1 / -1;
  background: var(--bg-card);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.telemetry-status-banner .status-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.telemetry-status-banner p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-main);
}

/* --- Panel de Controles Interactivos --- */
.controls-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.control-panel-card {
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.control-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.control-badge-val {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--bg-card-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Sliders táctiles */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--bg-card-subtle);
  border-radius: 9999px;
  outline: none;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease;
}

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

/* Botones de acción principales */
.btn-group-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 1.2rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--accent-green) !important;
  color: #ffffff !important;
}

/* Toggle Switches */
.toggle-switch-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.switch-label-desc {
  display: flex;
  flex-direction: column;
}

.switch-label-desc strong {
  font-size: 0.9rem;
  color: var(--text-main);
}

.switch-label-desc span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

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

.slider-switch {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  transition: .3s;
  border-radius: 34px;
}

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

.switch input:checked + .slider-switch {
  background-color: var(--primary);
  border-color: var(--primary);
}

.switch input:checked + .slider-switch:before {
  transform: translateX(22px);
  background-color: #0b0f17;
}

/* --- Guía Didáctica y Acordeones FAQ --- */
.educational-guide-section {
  background: var(--bg-card);
  padding: 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.educational-guide-section h2 {
  font-size: 1.5rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

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

.guide-card h3 {
  font-size: 1.15rem;
  color: var(--primary);
}

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

/* Acordeón FAQ */
.faq-accordion-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

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

.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.faq-question:hover {
  background: rgba(255, 255, 255, 0.03);
}

.faq-item[open] .faq-question {
  border-bottom: 1px solid var(--border-color);
  color: var(--primary);
}

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

/* --- Modal accesible corporativo --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background: var(--bg-card);
  width: 100%;
  max-width: 580px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-window {
  transform: translateY(0);
}

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

.modal-header h3 {
  font-size: 1.2rem;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 1.5rem;
}

/* Sidebar publicitario desktop (>= 1536px) */
.tool-ad-sidebar {
  display: none;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
    position: fixed;
    top: 100px;
    right: 20px;
    width: 300px;
    z-index: 100;
  }
}

/* Responsividad táctil móvil */
@media (max-width: 768px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
    gap: 1.5rem;
  }

  .viewer-3d-wrapper {
    height: 420px;
  }

  .mech-tabs-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .hud-instructions-hint {
    display: none;
  }

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

  .btn-group-row {
    grid-template-columns: 1fr;
  }
}
