/* ==========================================================================
   Simulador de acústica y posicionamiento de altavoces / Home Studio
   Estilos canónicos para fijate.com/tools/simulador-acustica-posicion-altavoces/
   ========================================================================== */

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

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  --text-main: #0f172a;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b2a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --border-color: #1e293b;
  --border-focus: #60a5fa;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-text: #ffffff;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  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;
}

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

.tool-layout {
  max-width: 1240px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

.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%;
}

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

/* ================= BARRA SUPERIOR ================= */
.acoustics-top-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.system-select-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 260px;
}

.bar-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 40px;
  padding: 0 2.25rem 0 0.85rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  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='%2364748b' 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 0.75rem center;
  background-size: 16px;
}

.select-compact {
  max-width: 320px;
}

.visual-modes-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-group-toggle {
  display: flex;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.btn-view-mode {
  padding: 0.4rem 0.75rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 34px;
}

.btn-view-mode:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.btn-view-mode.active {
  background: var(--primary);
  color: var(--primary-text);
  box-shadow: var(--shadow-sm);
}

.quick-export-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 1rem;
  height: 40px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}

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

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

.btn-secondary:hover {
  background: var(--bg-surface-hover);
}

/* ================= TIRA DE DIMENSIONES DE SALA ================= */
.room-dimension-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  background: var(--bg-surface);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.dim-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dim-input-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
}

.unit-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding-right: 0.75rem;
  height: 38px;
}

.form-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
}

.unit-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ================= GRID DE PLANO ACÚSTICO ================= */
.acoustics-stage-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}

.canvas-plan-wrapper {
  position: relative;
  background: #0d131f;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  touch-action: none;
  user-select: none;
}

#acoustic-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 840 / 580;
  display: block;
}

.plan-interactive-hint {
  position: absolute;
  bottom: 8px;
  left: 10px;
  right: 10px;
  text-align: center;
  font-size: 0.75rem;
  color: #64748b;
  pointer-events: none;
}

/* ================= PANEL LATERAL MÉTRICAS ================= */
.acoustics-side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.side-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.side-card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.75rem 0;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.metric-list-rows {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.metric-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.metric-val {
  font-size: 0.92rem;
  color: #10b981;
}

.mirror-hint-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.mirror-spots-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.spot-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 3px solid #f59e0b;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
}

.spot-badge {
  font-weight: 700;
  color: var(--text-main);
}

.modes-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mode-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.mode-freq {
  font-size: 0.95rem;
  color: #38bdf8;
}

.sub-crawl-advice {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
}

/* ================= PREGUNTAS FRECUENTES ================= */
.tool-faq-section {
  margin-top: 2.5rem;
  margin-bottom: 2rem;
}

.faq-section-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-main);
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

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

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

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

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

.faq-item[open] .faq-chevron {
  transform: rotate(180deg);
}

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

.faq-answer p {
  margin: 0;
}

/* ================= MODAL ================= */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.app-modal-backdrop.active {
  display: flex;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.app-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.app-modal-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

.app-modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

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

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

/* ================= RESPONSIVO MOBILE ================= */
@media (max-width: 900px) {
  .acoustics-stage-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
  }

  .card-main {
    padding: 0.85rem;
  }

  .acoustics-top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .system-select-group {
    flex-direction: column;
    align-items: stretch;
  }

  .select-compact {
    max-width: 100%;
  }

  .btn-group-toggle {
    width: 100%;
  }

  .btn-view-mode {
    flex: 1 1 0%;
    justify-content: center;
  }

  .quick-export-actions {
    width: 100%;
    flex-direction: column;
  }

  .btn-primary, .btn-secondary {
    width: 100%;
    min-height: 44px;
  }
}
