/* ==========================================================================
   Calculadora de Ahorro Energético por Ventanas y Aislamiento (Transmitancia U)
   Fijate Tools - Estándar Canónico 2026
   ========================================================================== */

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

  /* Paleta Midnight Slate Técnica */
  --bg-primary: #0b0f17;
  --bg-secondary: #0f172a;
  --bg-card: #111827;
  --bg-card-subtle: #1e293b;
  --bg-card-hover: #1f2937;
  --bg-input: #0f172a;
  --border-color: #334155;
  --border-subtle: #1e293b;

  --text-main: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --primary-color: #0284c7;
  --primary-light: rgba(2, 132, 199, 0.15);
  --primary-hover: #0369a1;
  --primary-focus: rgba(2, 132, 199, 0.35);

  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);
  --accent-red: #ef4444;
  --accent-red-bg: rgba(239, 68, 68, 0.12);
  --accent-cyan: #06b6d4;

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

[data-theme="light"],
body.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;

  --text-main: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --primary-color: #0284c7;
  --primary-light: rgba(2, 132, 199, 0.08);
  --primary-hover: #0369a1;
  --primary-focus: rgba(2, 132, 199, 0.2);

  --accent-green-bg: rgba(16, 185, 129, 0.08);
  --accent-amber-bg: rgba(245, 158, 11, 0.08);
  --accent-red-bg: rgba(239, 68, 68, 0.08);

  --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.12);
}

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  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-header-title,
.hero-title,
.metric-title {
  font-family: var(--font-heading);
}

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

/* Layout y contenedor principal */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1 0 auto;
}

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

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

/* Workspace de dos columnas */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* Tarjetas y secciones */
.card-main {
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

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

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.panel-icon-box {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--primary-light);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.panel-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background-color: var(--bg-card-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Formularios y grupos de campos */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
}

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

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

/* Selectores protegidos de desborde */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  height: 42px;
  padding: 0 40px 0 0.85rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  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='%2394a3b8' 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 14px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

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

/* Inputs de texto y numéricos con sufijo en flexbox */
.input-with-suffix {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 42px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-with-suffix:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-focus);
}

.input-with-suffix input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  height: 100%;
}

.input-with-suffix input:focus {
  outline: none;
}

.input-suffix {
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  background-color: var(--bg-card-subtle);
  border-left: 1px solid var(--border-color);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Cuadrículas compactas para opciones cortas */
.options-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.options-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .options-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Tarjeta de opción seleccionable */
.radio-pill-group {
  display: flex;
  gap: 0.5rem;
  background-color: var(--bg-card-subtle);
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.radio-pill-btn {
  flex: 1 1 0%;
  min-width: 0;
  height: 38px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.radio-pill-btn.active {
  background-color: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

/* Checkboxes estilizados */
.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.checkbox-card:hover {
  border-color: var(--primary-color);
}

.checkbox-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.checkbox-label-text {
  display: flex;
  flex-direction: column;
}

.checkbox-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

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

/* Fila de comparación de ventanas A vs B */
.window-compare-box {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.window-compare-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.tag-old {
  background-color: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.tag-new {
  background-color: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Tarjetas de resultados clave (KPIs) */
.kpi-deck {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

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

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

.kpi-card.highlight {
  background: linear-gradient(145deg, rgba(2, 132, 199, 0.12) 0%, rgba(16, 185, 129, 0.1) 100%);
  border-color: var(--primary-color);
}

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

.kpi-main-val {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-main-val.euro-val {
  color: var(--accent-green);
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Indicador semafórico de conformidad CTE DB-HE */
.cte-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
}

.cte-status-badge.cumple {
  background-color: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cte-status-badge.alerta {
  background-color: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Canvas interactivo de flujo térmico */
.canvas-container {
  width: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

#canvas-termo {
  width: 100%;
  height: 220px;
  display: block;
  border-radius: var(--radius-sm);
  background-color: #050811;
}

/* Tabla de desglose de balance energético */
.balance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.balance-table th,
.balance-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.balance-table th {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--bg-card-subtle);
}

.balance-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
}

.balance-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Botones de acción */
.btn-action-primary {
  width: 100%;
  height: 44px;
  background-color: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

.btn-action-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.4);
}

.btn-action-secondary {
  width: 100%;
  height: 42px;
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-action-secondary:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Acordeón FAQ y contenido SEO */
.faq-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

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

.faq-item:hover {
  border-color: var(--border-color);
}

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

.faq-icon {
  transition: transform 0.25s ease;
  flex-shrink: 0;
  color: var(--primary-color);
}

.faq-item.active .faq-icon {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 1.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.faq-item.active .faq-answer {
  max-height: 600px;
  padding: 0 1.25rem 1.15rem;
}

/* Modales canónicos */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

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

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

.modal-close-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background-color: var(--bg-card-subtle);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

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

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Hoja oficial de impresión A4 (.print-sheet) */
.print-sheet {
  display: none;
}

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

  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .fijate-footer,
  .card-main,
  .faq-section,
  .btn-action-primary,
  .btn-action-secondary {
    display: none !important;
  }

  .print-sheet {
    display: block !important;
    width: 100%;
    max-width: 210mm;
    margin: 0 auto;
    padding: 15mm;
    font-family: Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.4;
    color: #111827;
  }

  .print-sheet h1 {
    font-size: 18pt;
    margin-bottom: 4pt;
    border-bottom: 2pt solid #0284c7;
    padding-bottom: 6pt;
  }

  .print-sheet h2 {
    font-size: 13pt;
    margin-top: 12pt;
    margin-bottom: 6pt;
    color: #0284c7;
  }

  .print-sheet table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8pt;
    margin-bottom: 12pt;
  }

  .print-sheet th,
  .print-sheet td {
    border: 1px solid #cbd5e1;
    padding: 6pt 8pt;
    font-size: 10pt;
  }

  .print-sheet th {
    background-color: #f1f5f9;
  }
}
