/**
 * Fijate Tools - Laboratorio de Cimática y Placas de Chladni 3D
 * Hoja de estilos con variables de diseño corporativas, contención móvil
 * y estética Midnight Slate para física de ondas en WebGL.
 */

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

  /* Colores temáticos Midnight Slate (Modo Oscuro por defecto) */
  --bg-main: #070a10;
  --bg-card: #0d131f;
  --bg-card-subtle: #121a2b;
  --bg-input: #151e30;
  --border-color: #1e293b;
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Acentos de resonancia acústica */
  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.22);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.22);
  --accent-green: #10b981;
  --danger: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px -5px var(--accent-gold-glow);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

/* Reset y contención global obligatoria */
*, *::before, *::after {
  box-sizing: border-box;
}

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

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title,
.card-header-title {
  font-family: var(--font-heading);
  margin-top: 0;
}

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

/* Layout institucional */
.main-wrapper.tool-layout {
  width: 100%;
  max-width: 1240px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

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

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

/* Tarjeta principal contenedora */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Cabecera interior del laboratorio */
.lab-header-banner {
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(6, 182, 212, 0.06) 100%);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.lab-title-area h2 {
  font-size: 1.35rem;
  margin: 0 0 0.25rem 0;
  color: var(--text-main);
}

.lab-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.lab-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Contenedor del visor WebGL 3D */
.viewport-outer-container {
  position: relative;
  width: 100%;
  background: #020408;
  border-bottom: 1px solid var(--border-color);
}

#chladni-viewport {
  width: 100%;
  height: 520px;
  display: block;
  cursor: grab;
  touch-action: none;
}

#chladni-viewport:active {
  cursor: grabbing;
}

@media (max-width: 768px) {
  #chladni-viewport {
    height: 380px;
  }
}

/* HUD flotante superpuesto en el visor */
.hud-overlay-top {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

.hud-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: rgba(13, 19, 31, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hud-badge-gold {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.hud-badge-cyan {
  border-color: rgba(6, 182, 212, 0.4);
  color: #38bdf8;
}

.hud-badge-mic {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.mic-level-meter {
  display: inline-block;
  width: 40px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  overflow: hidden;
  vertical-align: middle;
}

.mic-level-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: #10b981;
  transition: width 0.05s linear;
}

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

/* Botones flotantes de acceso rápido sobre el visor */
.hud-view-controls {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10;
}

.btn-hud-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: rgba(13, 19, 31, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.btn-hud-icon:hover {
  background: var(--bg-card-subtle);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transform: scale(1.05);
}

.btn-hud-icon.active {
  background: var(--accent-gold);
  color: #000000;
  border-color: var(--accent-gold);
}

/* Panel de control inferior */
.control-dashboard-section {
  padding: 1.5rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

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

.control-card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.control-card-badge {
  font-size: 0.75rem;
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.12);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Grupos de botones de opción (Tabs Cuadrada / Circular) */
.shape-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.btn-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 42px;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-choice:hover {
  border-color: var(--border-focus);
}

.btn-choice.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(6, 182, 212, 0.15) 100%);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 600;
}

/* Controles de slider y entradas numéricas */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.control-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
  transition: transform 0.1s ease;
}

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

.control-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}

/* Wrapper de input flexbox con sufijo */
.input-with-suffix {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 0.75rem;
  height: 42px;
}

.input-with-suffix:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.15);
}

.input-with-suffix input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
}

.input-suffix {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  margin-left: 0.5rem;
  user-select: none;
}

/* Desplegables select canónicos anti-overflow */
.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  padding: 0 40px 0 0.85rem;
  background-color: var(--bg-input);
  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 14px center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.custom-select:focus {
  border-color: var(--border-focus);
}

.custom-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
  padding: 0.5rem;
}

/* Botones de acción principales */
.btn-action-primary,
.btn-action-secondary {
  width: 100%;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.5rem 1rem;
}

.btn-action-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #000000;
  border: none;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.3);
}

.btn-action-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

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

.btn-action-secondary:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-active-tone {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%) !important;
  color: #000000 !important;
  border: none !important;
}

.btn-active-mic {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #000000 !important;
  border: none !important;
}

/* Galería de presets interactivos */
.presets-section {
  padding: 0 1.5rem 1.75rem;
}

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

.section-header-compact h3 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--text-main);
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.preset-card-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: all 0.2s ease;
  color: var(--text-main);
}

.preset-card-btn:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  background: rgba(245, 158, 11, 0.04);
}

.preset-card-btn.active {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.1);
  box-shadow: 0 0 12px var(--accent-gold-glow);
}

.preset-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.preset-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.preset-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.preset-freq {
  font-size: 0.8rem;
  color: var(--accent-cyan);
}

/* Guía didáctica y acordeones FAQ */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-card);
}

.seo-guide-section h2 {
  font-size: 1.45rem;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.seo-guide-section p {
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

.formula-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.15rem;
  margin: 1.25rem 0;
  font-size: 0.95rem;
  color: #fbbf24;
  overflow-x: auto;
}

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

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

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

.faq-question svg {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.faq-item[open] .faq-question svg {
  transform: rotate(180deg);
  color: var(--accent-gold);
}

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

/* Modal corporativo accesible */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10000;
}

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

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

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

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

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