/* ==========================================================================
   Fijate Tools - Calculadora para frigoristas e instaladores HVAC
   Estilos corporativos canónicos • Midnight Slate & Modo Claro/Oscuro
   ========================================================================== */

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

  /* Paleta Midnight Slate (Oscuro por defecto) */
  --bg-dark: #0b0f17;
  --card-bg: #131b28;
  --card-bg-elevated: #1a2436;
  --card-subtle: #172131;
  --border-color: #243247;
  --border-focus: #38bdf8;
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Acentos termodinámicos */
  --accent-cyan: #38bdf8;
  --accent-blue: #2563eb;
  --accent-ice: #06b6d4;
  --accent-hot: #ef4444;
  --accent-warm: #f97316;
  --accent-amber: #f59e0b;
  --accent-success: #10b981;
  --accent-purple: #8b5cf6;

  /* Estados y sombras */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

[data-theme="light"] {
  --bg-dark: #f8fafc;
  --card-bg: #ffffff;
  --card-bg-elevated: #f1f5f9;
  --card-subtle: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #0284c7;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.08);
}

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

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

/* Tipografías canónicas */
h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title,
.tab-btn,
.panel-title,
.faq-section-title {
  font-family: var(--font-heading);
}

.mono,
.stat-val,
.pressure-val,
.temp-val,
code {
  font-family: var(--font-mono);
}

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

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

/* Tarjeta principal */
.card-main {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .card-main {
    padding: 1rem;
    border-radius: var(--radius-lg);
  }
}

/* Barra de pestañas superiores */
.tool-tabs-bar {
  display: flex;
  gap: 0.5rem;
  background: var(--card-subtle);
  padding: 0.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tool-tabs-bar::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1 1 0%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(56, 189, 248, 0.08);
}

.tab-btn.is-active {
  background: var(--card-bg);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .tab-btn.is-active {
  background: #ffffff;
  color: var(--border-focus);
}

/* Paneles de pestaña */
.tab-panel {
  display: none;
}
.tab-panel.is-active {
  display: block;
}

/* Cabecera del panel */
.panel-header-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.panel-header-left h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.panel-quick-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.preset-chip {
  min-height: 36px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--card-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

/* Formularios responsivos canónicos */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 820px) {
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

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

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

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

/* Controles táctiles >= 40px */
.form-control,
.form-select {
  width: 100%;
  max-width: 100%;
  min-height: 42px;
  background: var(--card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

/* Select con SVG y elipsis anti-desborde */
.form-select {
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  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='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-select option {
  background: var(--card-bg);
  color: var(--text-main);
}

/* Input en flexbox con unidad */
.input-with-suffix {
  display: flex;
  align-items: center;
  background: var(--card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.input-with-suffix:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.input-with-suffix input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  min-height: 40px;
  background: transparent;
  border: none;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  color: var(--text-main);
  font-family: var(--font-mono);
}
.input-with-suffix input:focus {
  outline: none;
}

.input-suffix {
  padding: 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(148, 163, 184, 0.08);
  min-height: 40px;
  display: flex;
  align-items: center;
  user-select: none;
  white-space: nowrap;
}

/* Grupos de botones toggle */
.btn-group-toggle {
  display: flex;
  background: var(--card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.btn-toggle-option {
  flex: 1 1 0%;
  min-height: 38px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-toggle-option.is-active {
  background: var(--card-bg);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-sm);
}

/* Tarjetas de resultados métricos */
.results-kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

@media (max-width: 900px) {
  .results-kpis-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 480px) {
  .results-kpis-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

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

.kpi-card.kpi-hot::before {
  background: var(--accent-hot);
}
.kpi-card.kpi-ice::before {
  background: var(--accent-ice);
}
.kpi-card.kpi-warm::before {
  background: var(--accent-warm);
}
.kpi-card.kpi-success::before {
  background: var(--accent-success);
}

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

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
  line-height: 1.1;
}

.kpi-unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
}

/* Tarjeta pericial de diagnóstico */
.diagnostic-banner {
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
  position: relative;
}

.diagnostic-banner.diag-success {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

.diagnostic-banner.diag-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
}

.diagnostic-banner.diag-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
}

.diagnostic-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.diagnostic-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.diag-success .diagnostic-badge {
  background: var(--accent-success);
  color: #ffffff;
}

.diag-warning .diagnostic-badge {
  background: var(--accent-amber);
  color: #000000;
}

.diag-danger .diagnostic-badge {
  background: var(--accent-hot);
  color: #ffffff;
}

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

.diagnostic-desc {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 0.85rem;
}

.diagnostic-actions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-color);
}

.diagnostic-actions-list li {
  font-size: 0.85rem;
  color: var(--text-main);
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.diagnostic-actions-list li::before {
  content: '→';
  color: var(--accent-cyan);
  font-weight: bold;
}

/* Esquema SVG interactivo de ciclo frigorífico */
.hvac-cycle-diagram-box {
  background: var(--card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.hvac-diagram-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cycle-svg-wrap {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
}

.cycle-svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Manómetros y medidores analógicos en UI */
.gauges-comparison-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}

@media (max-width: 768px) {
  .gauges-comparison-grid {
    grid-template-columns: 1fr;
  }
}

.gauge-card {
  background: var(--card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

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

.gauge-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
}

.gauge-badge.badge-low {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.gauge-badge.badge-high {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-hot);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Barras visuales de Sobrecalentamiento y Subenfriamiento */
.thermo-bar-box {
  margin-top: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
}

.thermo-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.thermo-bar-track {
  height: 10px;
  background: var(--card-subtle);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.thermo-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease, background-color 0.3s ease;
}

/* Tabla dinámica multisplit */
.multisplit-table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

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

.multisplit-table th {
  background: var(--card-subtle);
  padding: 0.65rem 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}

.multisplit-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

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

/* Botones de acción */
.btn-primary-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent-cyan);
  color: #0b0f17;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  background: #7dd3fc;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.btn-secondary-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary-action:hover {
  background: var(--card-bg-elevated);
  border-color: var(--text-secondary);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Modales canónicos accesibles (sin window.alert) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-dialog {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  position: relative;
}

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

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

.btn-modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-modal-close:hover {
  color: var(--text-main);
  background: var(--card-subtle);
}

.modal-body {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Toast de confirmación */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--card-bg-elevated);
  border: 1px solid var(--accent-cyan);
  color: var(--text-main);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 1100;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.25s ease;
}

.toast-notice.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Sección SEO y Guía Canónica */
.seo-guide-section {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.seo-guide-section h2 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.seo-guide-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 1.5rem 0 0.75rem;
}

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

.seo-table-container {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

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

.seo-data-table th {
  background: var(--card-subtle);
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}

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

.seo-data-table tr:hover td {
  background: rgba(56, 189, 248, 0.03);
}

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

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

.faq-trigger {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.faq-trigger svg {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-item.is-open .faq-trigger svg {
  transform: rotate(180deg);
}

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

.faq-item.is-open .faq-content {
  display: block;
}

/* Hoja A4 de impresión de parte de intervención */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .tool-ad-sidebar,
  .tools-ad-banner-section,
  .tool-tabs-bar,
  .actions-row,
  .fijate-footer,
  .seo-guide-section,
  .preset-chip,
  .btn-primary-action,
  .btn-secondary-action {
    display: none !important;
  }
  .main-wrapper.tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .card-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .tab-panel {
    display: none !important;
  }
  #panel-report {
    display: block !important;
  }
  .print-report-card {
    border: 1px solid #000 !important;
    padding: 20px !important;
  }
}
