/**
 * Simulador de fluidos de neón y vórtices - Hoja de estilos canónica
 * Fijate Tools
 */

:root {
  --bg-body: #05070e;
  --bg-card: #0c101c;
  --bg-card-sub: #131929;
  --border-color: #1e2840;
  --border-hover: #38bdf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #06b6d4;
  --primary-hover: #0891b2;
  --accent-pink: #ec4899;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --canvas-bg: #000000;
}

[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-sub: #e2e8f0;
  --border-color: #cbd5e1;
  --border-hover: #0891b2;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #0891b2;
  --primary-hover: #0e7490;
  --accent-pink: #db2777;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --canvas-bg: #030712;
}

/* Reglas canónicas globales */
*, *::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;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Layout principal */
.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.5rem;
  align-items: flex-start;
}

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

/* Tarjeta principal */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Barra superior HUD */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.hud-label {
  color: var(--text-muted);
}

.hud-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text-main);
}

.hud-value.highlight {
  color: #38bdf8;
}

/* Lienzo de simulación WebGL */
.fluid-stage {
  position: relative;
  width: 100%;
  background: var(--canvas-bg);
  border: 2px solid var(--border-color);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.15);
  user-select: none;
  -webkit-user-select: none;
}

#fluid-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  touch-action: none;
  cursor: pointer;
}

/* Cuadrícula de ajustes y paletas */
.fluid-controls-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
}

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

/* Panel de paletas de color */
.palettes-panel {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.panel-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.palettes-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
}

.btn-palette {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 42px;
  padding: 0 0.75rem;
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 0;
}

.btn-palette:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-palette.active {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.12);
  font-weight: 600;
}

.palette-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}

.palette-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panel de parámetros físicos */
.settings-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

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

.slider-styled {
  width: 100%;
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.slider-styled::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

/* Switch toggle */
.toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.slider-toggle {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #334155;
  transition: 0.2s;
  border-radius: 24px;
}

.slider-toggle:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

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

input:checked + .slider-toggle:before {
  transform: translateX(20px);
}

/* Botones de acción rápida */
.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.btn-action-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action-outline:hover {
  border-color: var(--border-hover);
  background: rgba(56, 189, 248, 0.08);
}

.btn-action-outline.btn-danger-soft:hover {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

/* Cuadro de información */
.info-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.info-box h3 {
  color: var(--text-main);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

/* Modales nativos accesibles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1rem;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

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

.modal-title {
  font-size: 1.15rem;
  color: var(--text-main);
}

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

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.btn-modal {
  height: 40px;
  padding: 0 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-card-sub);
  color: var(--text-main);
  transition: all 0.2s ease;
}

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

.btn-modal.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.btn-modal.btn-danger:hover {
  background: var(--danger-hover);
}

/* Media Queries para móvil */
@media (max-width: 640px) {
  .main-wrapper.tool-layout {
    padding: 0 0.5rem;
    margin-top: 1rem;
  }

  .card-main {
    padding: 0.75rem;
    border-radius: 0.75rem;
  }

  .palettes-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
