/**
 * Estilos específicos del Simulador de Inteligencia de Enjambre (Boids 3D y Hormigas)
 * Fijate Tools - Responsive, Tokens Corporativos y Accesibilidad Táctil
 */

:root {
  --tool-primary: #38bdf8;
  --tool-primary-hover: #0284c7;
  --tool-accent: #10b981;
  --tool-accent-hover: #059669;
  --tool-danger: #ef4444;
  --tool-bg-glass: rgba(15, 23, 42, 0.78);
  --tool-border-glass: rgba(255, 255, 255, 0.08);
  --tool-hud-text: #f8fafc;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --tool-bg-glass: rgba(255, 255, 255, 0.92);
  --tool-border-glass: rgba(0, 0, 0, 0.09);
  --tool-hud-text: #0f172a;
}

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

.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
}

@media (min-width: 1536px) {
  .tool-layout {
    max-width: 1520px;
    grid-template-columns: minmax(0, 1fr) 320px;
    align-items: start;
  }
}

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

/* Sidebar publicitario sticky para pantallas grandes */
.tool-ad-sidebar {
  display: none;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
    position: sticky;
    top: 5rem;
    width: 300px;
    margin: 0 auto;
  }
  .ad-sidebar-container {
    width: 300px;
    min-height: 600px;
    border-radius: 12px;
    overflow: hidden;
  }
}

/* Pestañas de modo de simulación */
.sim-mode-switcher {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--bg-card, rgba(20, 27, 45, 0.6));
  padding: 0.35rem;
  border-radius: 14px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.mode-tab-btn {
  flex: 1 1 0;
  min-height: 44px;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted, #94a3b8);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

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

.mode-tab-btn.active {
  background: var(--tool-primary);
  color: #04101f;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.mode-tab-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Lienzo y visor interactivo */
.sim-viewport-wrapper {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

.sim-container-3d,
.sim-container-2d {
  width: 100%;
  height: 520px;
  min-height: 420px;
  display: block;
}

@media (max-width: 768px) {
  .sim-container-3d,
  .sim-container-2d {
    height: 420px;
    min-height: 380px;
  }
}

.sim-viewport-wrapper.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  border-radius: 0;
  border: none;
  width: 100vw;
  height: 100vh;
}

.sim-viewport-wrapper.is-fullscreen .sim-container-3d,
.sim-viewport-wrapper.is-fullscreen .sim-container-2d {
  width: 100vw;
  height: 100vh;
}

/* Barra flotante de telemetría HUD */
.sim-telemetry-hud {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: var(--tool-bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--tool-border-glass);
  border-radius: 12px;
  padding: 0.5rem 0.85rem;
  display: flex;
  gap: 1.25rem;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.hud-item {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted, #94a3b8);
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
}

.hud-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--tool-hud-text);
}

@media (max-width: 600px) {
  .sim-telemetry-hud {
    top: 0.5rem;
    left: 0.5rem;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem;
  }
  .hud-value {
    font-size: 0.85rem;
  }
}

/* Barra flotante de control de reproducción */
.sim-floating-controls {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--tool-bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--tool-border-glass);
  border-radius: 30px;
  padding: 0.35rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.control-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-main, #f8fafc);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.08);
}

.control-icon-btn.btn-play-pause {
  background: var(--tool-primary);
  color: #04101f;
}

.control-icon-btn.btn-play-pause:hover {
  background: var(--tool-primary-hover);
}

.control-icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Paneles de controles bajo el visor */
.controls-dashboard {
  margin-top: 1.5rem;
  background: var(--bg-card, rgba(20, 27, 45, 0.6));
  border-radius: 16px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  padding: 1.5rem;
}

.presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.presets-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted, #94a3b8);
  margin-right: 0.25rem;
}

.preset-chip {
  min-height: 40px;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main, #f8fafc);
  font-size: 0.85rem;
  font-family: var(--font-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.preset-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--tool-primary);
}

.preset-chip.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--tool-primary);
  color: var(--tool-primary);
  font-weight: 600;
}

/* Grilla de controles */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.param-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.06));
  border-radius: 12px;
  padding: 1rem;
}

.param-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.param-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main, #f8fafc);
}

.param-value-badge {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--tool-primary);
  background: rgba(56, 189, 248, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
}

.param-slider {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  accent-color: var(--tool-primary);
}

.param-desc {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 0.4rem;
  line-height: 1.4;
}

/* Selectores canónicos anti-overflow */
.form-select-canonical {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 40px 0 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  background-color: var(--bg-card, #141b2d);
  color: var(--text-main, #f8fafc);
  font-family: var(--font-main);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.form-select-canonical option {
  background-color: #0b0f17;
  color: #f8fafc;
}

/* Herramientas de pintura para hormigas */
.brush-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tool-chip-btn {
  min-height: 42px;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main, #f8fafc);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.tool-chip-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tool-chip-btn.active {
  background: var(--tool-accent);
  color: #041a12;
  border-color: var(--tool-accent);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Sección didáctica SEO y acordeones */
.tool-seo-guide {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--bg-card, rgba(20, 27, 45, 0.6));
  border-radius: 16px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.tool-seo-guide h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  color: var(--text-main, #f8fafc);
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
}

.tool-seo-guide h2:first-of-type {
  margin-top: 0;
}

.tool-seo-guide h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--tool-primary);
  margin-top: 1.4rem;
  margin-bottom: 0.5rem;
}

.tool-seo-guide p, .tool-seo-guide li {
  line-height: 1.65;
  color: var(--text-muted, #94a3b8);
  font-size: 0.95rem;
}

.tool-seo-guide ul, .tool-seo-guide ol {
  padding-left: 1.4rem;
  margin-bottom: 1.2rem;
}

.rule-box {
  background: rgba(56, 189, 248, 0.06);
  border-left: 4px solid var(--tool-primary);
  padding: 1rem 1.25rem;
  border-radius: 0 10px 10px 0;
  margin: 1.2rem 0;
}

.rule-box h4 {
  margin: 0 0 0.35rem 0;
  color: var(--text-main, #f8fafc);
  font-family: var(--font-heading);
}

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

.faq-item {
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.faq-summary {
  padding: 1rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main, #f8fafc);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.faq-summary::after {
  content: '+';
  font-size: 1.4rem;
  color: var(--tool-primary);
  transition: transform 0.2s;
}

details[open] .faq-summary::after {
  transform: rotate(45deg);
}

.faq-content {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.6;
  font-size: 0.95rem;
}

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

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-card, #141b2d);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--text-main, #f8fafc);
  margin: 0 0 0.75rem;
}

.modal-body {
  color: var(--text-muted, #94a3b8);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

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

.btn-secondary {
  min-height: 40px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  background: transparent;
  color: var(--text-main, #f8fafc);
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.9rem;
}

.btn-primary {
  min-height: 40px;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  border: none;
  background: var(--tool-primary);
  color: #04101f;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
}
