/* ==========================================================================
   Calculadora de modos propios de sala y acústica de recintos
   Estándares canónicos fijate.com - Modo oscuro/claro y responsive móvil
   ========================================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema oscuro */
  --bg-main: #0a0e1a;
  --bg-card: #121829;
  --bg-card-hover: #1a223a;
  --bg-input: #0e1422;
  --bg-subtle: #1c253d;

  --border-color: #232f4e;
  --border-focus: #ec4899;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --primary: #d946ef;
  --primary-hover: #c026d3;
  --primary-light: rgba(217, 70, 239, 0.12);

  --accent-pink: #ec4899;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-subtle: #e2e8f0;

  --border-color: #cbd5e1;
  --border-focus: #d946ef;

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

  --primary: #c026d3;
  --primary-hover: #a21caf;
  --primary-light: rgba(192, 38, 211, 0.08);

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.06);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
}

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

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

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

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

/* Header introductorio */
.tool-intro-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.tool-intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.tool-intro-title {
  font-size: 1.6rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.tool-intro-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Presets */
.presets-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.btn-preset {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-preset:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

/* Grid principal */
.modes-grid-container {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 900px) {
  .modes-grid-container {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

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

.card-box-title {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Formularios */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
}

.form-label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.form-control {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-with-affix {
  display: flex;
  align-items: center;
  position: relative;
}

.input-with-affix .form-control {
  padding-right: 45px;
  font-family: var(--font-mono);
}

.input-affix-unit {
  position: absolute;
  right: 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
}

/* HUD Métricas */
.modes-hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.hud-tile {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.hud-tile-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.hud-tile-val {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
}

.hud-tile-val.val-pink { color: var(--accent-pink); }
.hud-tile-val.val-purple { color: var(--accent-purple); }

.hud-tile-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Visor acústico de sala y mapas */
.viewer-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.active-mode-subtext {
  display: block;
  font-size: 0.78rem;
  color: var(--primary);
  font-family: var(--font-mono);
  margin-top: 0.2rem;
  font-weight: 600;
}

.view-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.btn-view-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

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

.btn-view-tab.is-active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Canvas de Sala */
.canvas-wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}

.room-canvas-wrapper {
  height: 340px;
  min-height: 340px;
  max-height: 340px;
  width: 100%;
  max-width: 100%;
}

.canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  display: block;
  box-sizing: border-box;
}

/* Leyenda continua termo-acústica */
.pressure-legend-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.legend-gradient-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.legend-gradient-bar {
  height: 10px;
  width: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, 
    #0f172a 0%, 
    #0284c7 25%, 
    #6366f1 50%, 
    #d946ef 75%, 
    #ef4444 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.legend-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.legend-indicators {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
  font-size: 0.75rem;
}

.legend-badge-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-main);
  font-weight: 500;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-sweetspot {
  background-color: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.dot-monitors {
  background-color: #06b6d4;
  box-shadow: 0 0 6px #06b6d4;
}

/* Gráfico de Bonello */
.bonello-section {
  border-top: 1px solid var(--border-color);
  padding-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bonello-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.bonello-title {
  font-size: 0.85rem;
  font-weight: 700;
  display: block;
  color: var(--text-main);
}

.bonello-subtitle {
  font-size: 0.73rem;
  color: var(--text-muted);
  display: block;
}

.bonello-status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.bonello-status-pill.is-alert {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.3);
}

.bonello-canvas-wrapper {
  height: 190px;
  min-height: 190px;
  max-height: 190px;
  width: 100%;
  max-width: 100%;
}

/* Widget de Generador Senoidal */
.tone-generator-box {
  background: linear-gradient(135deg, rgba(217, 70, 239, 0.08), rgba(99, 102, 241, 0.06));
  border: 1px solid rgba(217, 70, 239, 0.25);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tone-generator-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tone-display {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.btn-toggle-tone {
  height: 44px;
  min-height: 44px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}

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

.btn-toggle-tone.is-playing {
  background-color: var(--accent-red);
}

/* Filtros y Tabla */
.filters-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-filter {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

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

.modes-table-container {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.modes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.modes-table th,
.modes-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
}

.modes-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modes-table tr {
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s;
}

.modes-table tr:hover {
  background: var(--bg-card-hover);
}

.modes-table tr.row-selected-mode {
  background: var(--primary-light);
}

.mode-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.tag-axial { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.tag-tangential { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.tag-oblique { background: rgba(99, 102, 241, 0.15); color: #818cf8; }

.btn-table-play {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-table-play:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Impresión */
#print-sheet {
  display: none;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .fijate-footer,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .tool-intro-card,
  .modes-grid-container,
  .presets-bar,
  .tone-generator-box,
  .filters-row,
  .seo-guide-section {
    display: none !important;
  }

  #print-sheet {
    display: block !important;
    padding: 2cm 1.5cm;
    font-size: 10pt;
  }

  .print-header {
    border-bottom: 2px solid #000;
    padding-bottom: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
  }

  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
  }

  .print-table th,
  .print-table td {
    border: 1px solid #ccc;
    padding: 6px 10px;
  }

  .print-table th {
    background: #f5f5f5;
  }
}
