/**
 * Hoja de estilos de Dibujante de Epiciclos de Fourier y Osciloscopio Lissajous 3D
 * Fijate Tools - Estándares corporativos y estética de laboratorio cibernético
 */

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

  /* Paleta cromática modo oscuro (Midnight Slate) */
  --bg-primary: #0b0f17;
  --bg-surface: #121824;
  --bg-card: #182030;
  --bg-card-hover: #1e283c;
  --border-color: #243046;
  --border-focus: #00e5ff;

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

  --accent-fourier: #00e5ff;
  --accent-fourier-glow: rgba(0, 229, 255, 0.35);
  --accent-crt: #00ff88;
  --accent-crt-glow: rgba(0, 255, 136, 0.35);
  --accent-amber: #ffb700;
  --accent-purple: #b388ff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(0, 229, 255, 0.18);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;

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

  --accent-fourier: #0284c7;
  --accent-fourier-glow: rgba(2, 132, 199, 0.25);
  --accent-crt: #059669;
  --accent-crt-glow: rgba(5, 150, 105, 0.25);
  --accent-amber: #d97706;
  --accent-purple: #7c3aed;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.12);
}

/* ==========================================================================
   RESET Y CONTENCIÓN ESTRUCTURAL
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  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,
.tool-heading {
  font-family: var(--font-heading);
  color: var(--text-main);
  margin-top: 0;
}

.mono, code, .stat-val, .formula-box {
  font-family: var(--font-mono);
}

/* ==========================================================================
   LAYOUT PRINCIPAL CON ANUNCIOS ADSENSE
   ========================================================================== */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
}

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

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* ==========================================================================
   TARJETA PRINCIPAL DEL ESTUDIO MATEMÁTICO
   ========================================================================== */
.card-main {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .card-main {
    padding: 1rem;
  }
}

/* Encabezado de la herramienta */
.tool-hero {
  margin-bottom: 1.5rem;
}

.tool-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.tool-title-row h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 229, 255, 0.12);
  color: var(--accent-fourier);
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tool-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0.5rem 0 1.25rem 0;
}

/* ==========================================================================
   NAVEGACIÓN POR PESTAÑAS (TABS)
   ========================================================================== */
.nav-tabs-wrapper {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

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

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

.nav-tab-btn.active {
  background: var(--bg-surface);
  color: var(--accent-fourier);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ==========================================================================
   LIENZO DE DIBUJO Y VISUALIZADOR
   ========================================================================== */
.canvas-display-box {
  position: relative;
  width: 100%;
  background: #06090e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), var(--shadow-glow);
  aspect-ratio: 16 / 10;
  min-height: 340px;
  touch-action: none;
}

.canvas-element {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.canvas-overlay-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 15, 23, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 6px;
}

.canvas-actions-floating {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
}

.btn-canvas-action {
  background: rgba(18, 24, 36, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  min-height: 34px;
}

.btn-canvas-action:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-fourier);
}

/* ==========================================================================
   MINI GRÁFICO DE ESPECTRO FOURIER
   ========================================================================== */
.spectrum-box {
  margin-top: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
}

.spectrum-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

.spectrum-canvas {
  width: 100%;
  height: 55px;
  display: block;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}

/* ==========================================================================
   TARJETAS KPI TELEMETRÍA
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0;
}

@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

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

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

.kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.kpi-highlight-fourier {
  color: var(--accent-fourier);
}

.kpi-highlight-crt {
  color: var(--accent-crt);
}

/* ==========================================================================
   FILA DE PRESETS
   ========================================================================== */
.presets-section {
  margin: 1.25rem 0;
}

.presets-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.presets-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.preset-chip-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.preset-chip-btn.active {
  background: rgba(0, 229, 255, 0.12);
  color: var(--accent-fourier);
  border-color: var(--accent-fourier);
  font-weight: 600;
}

/* ==========================================================================
   PANELES DE CONTROL Y FORMULARIOS
   ========================================================================== */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (max-width: 768px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }
}

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

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

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

.control-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 500;
}

.control-item-header label {
  color: var(--text-main);
}

.control-item-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-fourier);
  font-size: 0.85rem;
}

/* Sliders táctiles */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
  margin: 8px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-fourier);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-fourier-glow);
  border: 2px solid #ffffff;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-fourier);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-fourier-glow);
  border: 2px solid #ffffff;
}

/* Selects anti-overflow */
select.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  padding: 0 40px 0 12px;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.88rem;
  outline: none;
  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 12px center;
  appearance: none;
}

select.form-select:focus {
  border-color: var(--accent-fourier);
}

/* Checkboxes y switches */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 28px;
}

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

/* ==========================================================================
   BOTONES PRINCIPALES DE ACCIÓN (100% MÓVIL, MIN 40PX)
   ========================================================================== */
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-primary-action,
.btn-secondary-action,
.btn-audio-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 42px;
  border: 1px solid transparent;
}

.btn-primary-action {
  background: var(--accent-fourier);
  color: #0b0f17;
  box-shadow: 0 2px 10px var(--accent-fourier-glow);
}

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

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

.btn-secondary-action:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-active-drawing {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #ef4444 !important;
  animation: pulseDrawing 1.5s infinite;
}

@keyframes pulseDrawing {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.btn-audio-action {
  background: rgba(0, 255, 136, 0.12);
  color: var(--accent-crt);
  border-color: rgba(0, 255, 136, 0.3);
  width: 100%;
}

.btn-audio-action:hover {
  background: rgba(0, 255, 136, 0.2);
  border-color: var(--accent-crt);
}

.btn-audio-action.audio-active {
  background: var(--accent-crt);
  color: #0b0f17;
  font-weight: 700;
  box-shadow: 0 0 16px var(--accent-crt-glow);
}

@media (max-width: 640px) {
  .actions-bar .btn-primary-action,
  .actions-bar .btn-secondary-action {
    width: 100%;
  }
}

/* ==========================================================================
   GUÍA EDUCATIVA Y ACORDEONES FAQ
   ========================================================================== */
.educational-guide {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 2rem;
}

.guide-heading {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.guide-text {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.formula-card {
  background: var(--bg-card);
  border-left: 4px solid var(--accent-fourier);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.25rem 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-main);
  overflow-x: auto;
}

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

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

.faq-item[open] {
  border-color: var(--accent-fourier);
}

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

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

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

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

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

.faq-answer p {
  margin: 0;
}

/* ==========================================================================
   TOAST Y MODAL CORPORATIVO
   ========================================================================== */
.app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #182030;
  color: #f1f5f9;
  border: 1px solid var(--accent-fourier);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.app-toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10000;
}

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

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

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

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

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

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

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