/**
 * GLOSS & GROWTH — CALCULADORA DE INVERSIÓN EN APARATOLOGÍA
 * Hoja de estilos corporativa editorial.
 * 
 * Paleta oficial:
 * - Borgoña: #8C2536
 * - Carbón: #352925
 * - Crema suave: #FCFAF5
 * - Borde suave: #E8E2D9
 */

:root {
  --ap-burgundy: #8C2536;
  --ap-burgundy-dark: #6E1B29;
  --ap-burgundy-light: #FBF1F2;
  --ap-cream: #FCFAF5;
  --ap-cream-border: #E8E2D9;
  --ap-charcoal: #352925;
  --ap-muted: #6B5E59;
  --ap-border: #E2E8F0;
  --ap-bg: #FFFFFF;
  --ap-card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.ap-hero {
  padding: 40px 0 28px;
  background: var(--ap-cream);
  border-bottom: 1px solid var(--ap-cream-border);
}

.ap-hero .eyebrow {
  color: var(--ap-burgundy);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.ap-hero h1 {
  font-family: var(--font-serif, "Zodiak", Georgia, serif);
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  color: var(--ap-charcoal);
  margin-bottom: 12px;
}

.ap-hero h1 em {
  font-style: italic;
  color: var(--ap-burgundy);
}

.ap-hero p.lead {
  font-size: 16px;
  line-height: 1.55;
  color: var(--ap-muted);
  max-width: 820px;
  margin: 0;
}

/* Modality Tabs */
.ap-modality-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  max-width: 100%;
}

.ap-tab-btn {
  background: #FFFFFF;
  border: 1px solid var(--ap-border);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-charcoal);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.ap-tab-btn:hover {
  border-color: var(--ap-burgundy);
  color: var(--ap-burgundy);
}

.ap-tab-btn.active {
  background: var(--ap-burgundy);
  border-color: var(--ap-burgundy);
  color: #FFFFFF;
}

/* Layout Grid */
.ap-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 32px;
  margin-top: 24px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 980px) {
  .ap-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .ap-form-col,
  .ap-results-col {
    min-width: 0;
    max-width: 100%;
  }
}

.ap-card {
  background: #FFFFFF;
  border: 1px solid var(--ap-cream-border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--ap-card-shadow);
}

.ap-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ap-charcoal);
  margin-top: 0;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ap-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.ap-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ap-field.col-span-2 {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .ap-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .ap-card {
    padding: 18px 14px;
    box-sizing: border-box;
    max-width: 100%;
    min-width: 0;
  }
  .ap-field {
    min-width: 0;
    max-width: 100%;
  }
  .ap-field.col-span-2 {
    grid-column: span 1;
  }
}

.ap-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-charcoal);
}

.ap-hint {
  font-size: 11px;
  color: var(--ap-muted);
}

.ap-input, .ap-select {
  padding: 10px 12px;
  border: 1px solid var(--ap-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ap-charcoal);
  background: #FFFFFF;
  width: 100%;
  box-sizing: border-box;
}

.ap-input:focus, .ap-select:focus {
  outline: none;
  border-color: var(--ap-burgundy);
  box-shadow: 0 0 0 3px var(--ap-burgundy-light);
}

/* KPI Grid */
.ap-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 440px) {
  .ap-kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ap-kpi-box {
  background: var(--ap-cream);
  border: 1px solid var(--ap-cream-border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ap-kpi-box.highlight {
  background: var(--ap-burgundy-light);
  border-color: rgba(140, 37, 54, 0.2);
}

.ap-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ap-burgundy);
  margin-bottom: 6px;
}

.ap-kpi-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--ap-charcoal);
}

.ap-kpi-box.highlight .ap-kpi-val {
  color: var(--ap-burgundy);
}

.ap-kpi-sub {
  font-size: 11px;
  color: var(--ap-muted);
  margin-top: 4px;
}

/* Table styling */
.ap-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.ap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ap-table th {
  background: #F8FAFC;
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: #475569;
  border-bottom: 1px solid #CBD5E1;
}

.ap-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #E2E8F0;
  color: #334155;
}

/* Diagnostic Box */
.ap-diag-box {
  background: #F8FAFC;
  border-left: 4px solid var(--ap-burgundy);
  padding: 14px 16px;
  border-radius: 0 8px 8px 0;
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.55;
}

.ap-diag-part {
  margin-bottom: 8px;
}

.ap-diag-part:last-child {
  margin-bottom: 0;
}

.ap-diag-part strong {
  color: var(--ap-charcoal);
}

/* Actions footer */
.ap-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.ap-badge-import {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #F1F5F9;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: #475569;
}

/* Modales */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(53, 41, 37, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid var(--ap-cream-border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  padding: 24px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--ap-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.modal-close:hover {
  color: var(--ap-burgundy);
}

.cap-import-item {
  border: 1px solid var(--ap-cream-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #FAF8F5;
  transition: all 0.15s ease;
  cursor: pointer;
}

.cap-import-item:hover {
  border-color: var(--ap-burgundy);
  background: #FFFFFF;
}

/* ==========================================================================
   COMPARADOR FINANCIERO DE APARATOLOGÍA
   ========================================================================== */

.ap-tab-comparador {
  border-left: 2px solid var(--ap-burgundy) !important;
  font-weight: 700;
}

.ap-comp-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #FFFFFF;
  border: 1px solid var(--ap-border);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-charcoal);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.ap-comp-chip:hover {
  border-color: var(--ap-burgundy);
}

.ap-comp-chip:has(input:checked) {
  background: #FDF2F4;
  border-color: var(--ap-burgundy);
  color: var(--ap-burgundy);
}

.ap-comp-chip input[type="checkbox"] {
  accent-color: var(--ap-burgundy);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.comp-hz-btn {
  transition: all 0.15s ease;
}

.comp-hz-btn.active {
  background: var(--ap-burgundy) !important;
  border-color: var(--ap-burgundy) !important;
  color: #FFFFFF !important;
}

.ap-comp-winner-cell {
  background: #F0FDF4 !important;
  color: #166534 !important;
  font-weight: 700 !important;
}

.ap-comp-winner-cell::after {
  content: " ★";
  font-size: 10px;
  color: #16a34a;
}

.ap-comp-highlight-row td {
  background: #FAF8F5;
  font-weight: 600;
}

.ap-comp-details summary::-webkit-details-marker {
  display: none;
}
