/**
 * Fijate Tools - Caleidoscopio interactivo y generador de mandalas
 * Estilos canónicos, tema claro/oscuro corporativo y UI Glassmorphism
 */

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

  /* Colores corporativos tema claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-glass: rgba(255, 255, 255, 0.85);
  --border-color: #e2e8f0;
  --border-focus: #6366f1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.35);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  --bg-page: #090d16;
  --bg-card: #111827;
  --bg-card-glass: rgba(17, 24, 39, 0.82);
  --border-color: #1f293d;
  --border-focus: #818cf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.2);
  --accent: #22d3ee;
  --accent-glow: rgba(34, 211, 238, 0.3);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.tool-title {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
}

.mono,
.val-badge,
code {
  font-family: var(--font-mono);
}

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

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

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

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

/* Barra superior del visor */
.viewer-top-bar {
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.source-tabs-group {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-page);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.source-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.2s ease;
  min-height: 40px;
}

.source-tab-btn:hover {
  color: var(--text-main);
}

.source-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.top-actions-group {
  display: flex;
  gap: 0.5rem;
}

.btn-icon-action {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon-action:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-icon-action.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Escenario interactivo WebGL */
.kaleidoscope-stage-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 420px;
  max-height: 680px;
  background: #000000;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.kaleidoscope-stage-wrapper:active {
  cursor: grabbing;
}

.kaleidoscope-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Indicador de arrastrar y soltar imagen */
.kaleidoscope-stage-wrapper.drag-over::after {
  content: 'Suelta la imagen para cargarla';
  position: absolute;
  inset: 0;
  background: rgba(79, 70, 229, 0.75);
  backdrop-filter: blur(6px);
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* HUD superpuesto en modo Zen */
.stage-hud-overlay {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 0.8rem;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 5;
}

.stage-hud-overlay .hint-icon {
  opacity: 0.75;
}

.zen-idle .viewer-top-bar,
.zen-idle .stage-hud-overlay,
.zen-idle .controls-panel-container {
  opacity: 0;
  pointer-events: none;
}

/* Panel de controles y presets */
.controls-panel-container {
  padding: 1.5rem;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  transition: opacity 0.3s ease;
}

/* Galería de Presets */
.preset-section-title {
  font-size: 0.875rem;
  text-transform: none;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

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

.preset-pill {
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  min-height: 40px;
}

.preset-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.preset-pill.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.preset-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Cuadrícula de Sliders */
.sliders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

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

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

.control-label {
  font-weight: 500;
  color: var(--text-main);
}

.val-badge {
  font-size: 0.8rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

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

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform 0.15s ease;
}

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

/* Desplegables reglamentarios */
.select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 40px 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  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='%236366f1' 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;
}

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

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

/* Barra inferior de exportación */
.export-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.export-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex: 1 1 auto;
}

.btn-primary-action {
  background: var(--primary);
  color: #ffffff;
  border: none;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 42px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-primary-action:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary-action {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 42px;
  transition: all 0.2s ease;
}

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

/* Barra de progreso de grabación */
.record-progress-box {
  display: none;
  width: 100%;
  margin-top: 0.5rem;
}

.record-progress-track {
  width: 100%;
  height: 6px;
  background: var(--border-color);
  border-radius: 999px;
  overflow: hidden;
}

.record-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
}

/* Sección explicativa técnica / Guía óptica */
.guide-content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.guide-content-card h2 {
  font-size: 1.35rem;
  color: var(--text-main);
}

.guide-content-card h3 {
  font-size: 1.1rem;
  color: var(--text-main);
  margin-top: 0.5rem;
}

.guide-content-card p,
.guide-content-card li {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.guide-content-card ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.formula-box {
  background: var(--bg-page);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.85rem 1.15rem;
  font-size: 0.9rem;
  color: var(--text-main);
}

/* Modal accesible de aviso */
.notice-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
}

.notice-modal-backdrop.active {
  display: flex;
}

.notice-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.notice-modal-card h3 {
  font-size: 1.2rem;
}

.notice-modal-card p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Spinner inline */
.spinner-inline {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsividad móvil */
@media (max-width: 768px) {
  .viewer-top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .source-tabs-group {
    width: 100%;
    justify-content: space-between;
  }

  .source-tab-btn {
    flex: 1 1 0%;
    justify-content: center;
    font-size: 0.8rem;
    padding: 0.45rem 0.35rem;
  }

  .sliders-grid {
    grid-template-columns: 1fr;
  }

  .export-actions-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary-action,
  .btn-secondary-action {
    width: 100%;
  }

  .kaleidoscope-stage-wrapper {
    min-height: 340px;
    aspect-ratio: 1 / 1;
  }
}
