/**
 * Estilos de la Calculadora de distancia y altura de televisor
 * fijate.com - Salón perfecto
 */

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

  /* Colores tema claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-card: #e2e8f0;
  --border-focus: #0284c7;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --accent-amber: #d97706;
  --accent-green: #10b981;
  --accent-red: #ef4444;

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

[data-theme="dark"],
body.dark {
  --bg-page: #0b0f17;
  --bg-card: #131c2e;
  --bg-card-subtle: #1e293b;
  --border-card: #2a374d;
  --border-focus: #38bdf8;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-light: rgba(56, 189, 248, 0.12);
  --accent-amber: #f59e0b;
  --accent-green: #34d399;
  --accent-red: #f87171;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

/* Reset y estructura general */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

.mono,
.kpi-value,
.cota-val,
code {
  font-family: var(--font-mono);
}

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

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

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

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

/* Cabecera del calculador */
.tool-header-block {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-card);
}

.tool-header-text h2 {
  font-size: 1.65rem;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.tool-header-text p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 780px;
}

.btn-print-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.btn-print-action:hover {
  background: var(--primary);
  color: #ffffff;
}

/* Panel de control de parámetros */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.control-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Presets de pulgadas (55", 65", 75", 85") */
.preset-pills-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-inch-preset {
  flex: 1 1 0%;
  min-width: 52px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.btn-inch-preset.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

/* Wrappers de slider e input numérico */
.slider-input-combo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.slider-input-combo input[type="range"] {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  accent-color: var(--primary);
  cursor: pointer;
  height: 6px;
}

.num-input-suffix {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 0 0.5rem;
  height: 40px;
  min-width: 86px;
}

.num-input-suffix input[type="number"] {
  width: 48px;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  text-align: right;
  -moz-appearance: textfield;
}

.num-input-suffix input[type="number"]::-webkit-outer-spin-button,
.num-input-suffix input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-suffix {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

/* Desplegables <select> conforme a regla 10 */
select.select-custom {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 2.25rem 0 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-card);
  background-color: var(--bg-card);
  color: var(--text-primary);
  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;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' 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.select-custom:focus {
  border-color: var(--border-focus);
}

/* Radio tabs para tipo de fijación */
.radio-tabs-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.25rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
}

.radio-tab-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 36px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-tab-label input[type="radio"] {
  display: none;
}

.radio-tab-label:has(input:checked) {
  background: var(--primary);
  color: #ffffff;
}

/* Resumen de KPIs en tarjetas analíticas */
.kpi-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

.kpi-card.kpi-cervical::before {
  background: var(--accent-amber);
}

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

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 0.35rem;
  width: fit-content;
}

.kpi-badge.status-ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.kpi-badge.status-warn {
  background: rgba(217, 119, 6, 0.15);
  color: var(--accent-amber);
}

.kpi-badge.status-alert {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
}

/* Simulador gráfico interactivo */
.simulator-stage-box {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.simulator-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-card);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sim-view-tabs {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-card);
  padding: 0.2rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
}

.btn-sim-tab {
  height: 34px;
  padding: 0 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-sim-tab.active {
  background: var(--primary);
  color: #ffffff;
}

.sim-actions {
  display: flex;
  gap: 0.4rem;
}

.btn-sim-tool {
  height: 34px;
  padding: 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.btn-sim-tool:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-sim-tool.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Canvas del salón */
.canvas-container {
  position: relative;
  width: 100%;
  height: 480px;
  background: var(--bg-page);
  overflow: hidden;
}

#roomCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* Impide scroll de página durante arrastre táctil */
}

.simulator-footer-hint {
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg-card-subtle);
  border-top: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sim-hint-badges {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
}

.hint-dot-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

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

.dot-blue { background: #0284c7; }
.dot-amber { background: #d97706; }
.dot-green { background: #10b981; }

/* Sección de diagnósticos inteligentes */
.diagnostics-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.diag-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

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

.diag-title {
  font-size: 1.05rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.diag-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
}

.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge-amber { background: rgba(217, 119, 6, 0.15); color: var(--accent-amber); }
.badge-red { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.badge-blue { background: rgba(2, 132, 199, 0.15); color: var(--primary); }
.badge-slate { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

.diag-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Tabla comparativa de pulgadas estándar */
.table-responsive-box {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.tv-guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.tv-guide-table th {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-card);
}

.tv-guide-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-card);
  color: var(--text-secondary);
}

.tv-guide-table tr:last-child td {
  border-bottom: none;
}

.tv-guide-table tr:hover td {
  background: var(--primary-light);
}

/* Guía SEO y acordeón FAQ (Lección 412 y 418) */
.seo-guide-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.seo-guide-section h3 {
  font-size: 1.35rem;
  color: var(--text-primary);
}

.seo-guide-section p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

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

.faq-accordion-item {
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  overflow: hidden;
}

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

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

.faq-accordion-summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  transition: transform 0.2s ease;
}

details[open] .faq-accordion-summary::after {
  content: '−';
}

.faq-accordion-content {
  padding: 0 1.25rem 1rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Ficha imprimible técnica (oculta en pantalla, visible en @media print) */
.printable-technical-sheet {
  display: none;
}

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

  .app-header,
  .fijate-footer,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .controls-grid,
  .simulator-toolbar,
  .btn-print-action,
  .amazon-affiliate-showcase,
  .related-tools-section {
    display: none !important;
  }

  .main-wrapper.tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card-main {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }

  .canvas-container {
    height: 380px !important;
  }

  .printable-technical-sheet {
    display: block !important;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #000000;
  }

  .printable-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1rem;
  }

  .printable-title {
    font-size: 1.5rem;
    font-weight: bold;
  }

  .printable-meta {
    font-size: 0.85rem;
    color: #444444;
  }
}

/* Responsividad en móvil */
@media (max-width: 768px) {
  .main-wrapper.tool-layout {
    margin: 1rem auto 2.5rem;
    padding: 0 0.75rem;
  }

  .card-main {
    padding: 1.15rem;
    gap: 1.25rem;
  }

  .controls-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .canvas-container {
    height: 380px;
  }

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

  .tool-header-block {
    flex-direction: column;
  }

  .btn-print-action {
    width: 100%;
    justify-content: center;
  }

  .sim-view-tabs {
    width: 100%;
  }

  .btn-sim-tab {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .kpi-metrics-grid {
    grid-template-columns: 1fr;
  }

  .canvas-container {
    height: 340px;
  }
}
