/* ==========================================================================
   AUTIP Comparador — Estilos específicos
   Hereda variables de styles.css (paleta editorial)
   ========================================================================== */

.comp-page {
  background: var(--paper);
  min-height: 100vh;
}

/* HERO */
.comp-hero {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(50px, 7vw, 90px) var(--gutter) clamp(30px, 5vw, 50px);
  text-align: center;
}

.comp-hero h1 {
  margin: 22px auto 28px;
  max-width: 900px;
}

.comp-hero p {
  font-size: clamp(17px, 1.6vw, 21px);
  color: var(--ink-soft);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.5;
}

/* SELECTORS */
.comp-selectors {
  max-width: var(--max);
  margin: 0 auto;
  padding: 30px var(--gutter);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.selector-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 26px;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  min-height: 230px;
  display: flex;
  flex-direction: column;
}

.selector-card.has-selection {
  border-color: var(--ink);
  background: var(--paper);
}

.selector-card.optional {
  border-style: dashed;
}

.selector-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
}

.selector-num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 28px;
  color: var(--accent);
  font-weight: 500;
}

.selector-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 500;
}
.selector-label small {
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  font-family: var(--font-body);
  font-style: italic;
  color: var(--muted);
}

.selector-input-wrap {
  position: relative;
}

.selector-input {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--paper);
  color: var(--ink);
  transition: border-color var(--transition);
}

.selector-input:focus {
  outline: none;
  border-color: var(--ink);
}

.selector-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 20px 50px -20px rgba(26,24,20,0.25);
  display: none;
}

.selector-dropdown.open {
  display: block;
}

.dropdown-item {
  padding: 12px 18px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--rule);
  transition: background var(--transition);
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--paper-2); }

.dropdown-item .item-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}

.dropdown-item .item-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
}

.dropdown-empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

/* Selected state */
.selector-selected {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.selected-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}

.selected-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.selected-remove {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  cursor: pointer;
  align-self: flex-start;
  margin-top: 8px;
  transition: all var(--transition);
}
.selected-remove:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ACTIONS */
.comp-actions {
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px var(--gutter) 60px;
  text-align: center;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.comp-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.comp-actions button:disabled:hover {
  transform: none;
  background: var(--ink);
}

/* RESULTS */
.comp-results {
  max-width: var(--max);
  margin: 0 auto;
  padding: 30px var(--gutter) 100px;
  scroll-margin-top: 100px;
}

.results-head {
  margin-bottom: 40px;
  text-align: center;
}

.results-head .eyebrow { display: inline-flex; }
.results-head h2 {
  margin-top: 16px;
  font-size: clamp(32px, 5vw, 56px);
}

/* Tabla comparativa principal */
.compare-table {
  border-top: 2px solid var(--ink);
}

.compare-row {
  display: grid;
  grid-template-columns: 200px repeat(var(--cols, 3), 1fr);
  gap: 16px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
  align-items: center;
}

.compare-row.header {
  align-items: flex-end;
  padding: 30px 0;
  border-bottom: 1px solid var(--ink);
}

.row-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 500;
}

.car-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.car-header-img {
  width: 100%;
  height: 130px;
  background: var(--paper-3);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.car-header-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 55%;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.car-header-img img.loaded { opacity: 1; }

.car-header-img.is-loading {
  background: linear-gradient(90deg, var(--paper-3) 25%, var(--paper-2) 50%, var(--paper-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite linear;
}

.car-header-img-placeholder {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 24px;
  color: var(--muted);
  opacity: 0.5;
  position: absolute;
}

.car-header-name {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 500;
  line-height: 1.1;
  color: var(--ink);
}

.car-header-brand-tier {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 500;
}

.cell {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.cell strong {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 500;
  color: var(--ink);
  display: block;
  letter-spacing: -0.01em;
}

.cell-diff {
  position: relative;
}
.cell-diff strong {
  color: var(--accent);
}
.cell-diff::before {
  content: "●";
  color: var(--accent);
  font-size: 8px;
  position: absolute;
  top: -3px;
  left: -14px;
  display: none; /* opcional: marca el más destacado */
}

.cell-tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.cell-tag.tier-premium { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cell-tag.tier-generalista { background: var(--paper-2); }
.cell-tag.tier-lowcost { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-dark); }

.dgt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 14px;
  color: var(--paper);
  letter-spacing: 0;
}
.dgt-0   { background: #2563eb; }
.dgt-ECO { background: #059669; }
.dgt-C   { background: #d97706; }
.dgt-B   { background: #6b7280; }
.dgt-A   { background: #4b5563; }

/* Pros y contras lado a lado */
.compare-prosc {
  margin-top: 50px;
  display: grid;
  grid-template-columns: 200px repeat(var(--cols, 3), 1fr);
  gap: 16px;
  align-items: start;
  padding-top: 30px;
  border-top: 1px solid var(--ink);
}

.prosc-cell h4 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--ink);
}

.prosc-list {
  list-style: none;
  padding: 0;
  margin: 0 0 22px 0;
}

.prosc-list li {
  font-size: 14px;
  padding: 7px 0;
  display: flex;
  gap: 10px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.prosc-list.pros li::before {
  content: "+";
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.prosc-list.cons li::before {
  content: "−";
  color: var(--muted);
  font-weight: 700;
  flex-shrink: 0;
}

.prosc-divider {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin: 16px 0 10px;
  font-weight: 500;
}

/* Diferencias destacadas (resumen arriba de la tabla) */
.diffs-summary {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 50px;
}

.diffs-summary h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 18px;
  font-weight: 500;
}

.diffs-summary ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 30px;
}

.diffs-summary li {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.5;
  display: flex;
  gap: 12px;
}

.diffs-summary li::before {
  content: "→";
  color: var(--accent);
  flex-shrink: 0;
  font-weight: 500;
}

.diffs-summary strong {
  color: var(--ink);
  font-weight: 500;
}

/* EXAMPLES */
.comp-examples {
  max-width: var(--max);
  margin: 0 auto;
  padding: 50px var(--gutter) 80px;
}

.comp-examples h2 {
  margin: 16px 0 50px;
}

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

.example-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 26px;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.example-card:hover {
  transform: translateY(-3px);
  border-color: var(--ink);
  background: var(--paper);
}

.example-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  font-weight: 500;
}

.example-card h3 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  margin: 0;
}

/* CTA FINAL */
.comp-cta {
  max-width: 900px;
  margin: 0 auto;
  padding: 80px var(--gutter) 120px;
  text-align: center;
}

.comp-cta h2 { margin: 18px 0 24px; }
.comp-cta p {
  font-size: clamp(17px, 1.6vw, 21px);
  color: var(--ink-soft);
  margin-bottom: 36px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

/* MESSAGES */
.comp-message {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px 22px;
  font-size: 14px;
  color: var(--accent-dark);
  text-align: center;
  margin: 20px auto;
  max-width: 600px;
  font-family: var(--font-mono);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* RESPONSIVE */
@media (max-width: 900px) {
  .comp-selectors {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .selector-card { min-height: auto; }

  /* Tabla en móvil: fila = bloque vertical con separación clara */
  .compare-row {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 20px 0;
  }

  .compare-prosc {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 20px 0;
  }

  .compare-row.header {
    padding: 20px 0;
  }

  .row-label {
    color: var(--accent);
    margin-bottom: 12px;
  }

  /* Cada celda: bloque separado con etiqueta del coche arriba */
  .compare-row:not(.header) .cell {
    display: block;
    padding: 10px 0 10px 0;
    border-bottom: 1px solid var(--rule);
    overflow: hidden;
  }

  .compare-row:not(.header) .cell:last-child {
    border-bottom: none;
  }

  /* Etiqueta del coche encima del valor */
  .compare-row:not(.header) .cell::before {
    content: attr(data-car-name);
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: var(--muted);
    margin-bottom: 6px;
    line-height: 1.3;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
  }

  /* En móvil quitar el highlight de precio más barato — confunde */
  .compare-row:not(.header) .cell-diff strong {
    color: var(--ink);
  }

  /* Headers de coche en móvil */
  .car-header {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
  }

  .car-header:last-child {
    border-bottom: none;
  }

  .car-header-img {
    display: none; /* Sin fotos, el bloque de imagen no ocupa espacio */
  }

  /* Diferencias clave */
  .diffs-summary ul {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Pros y contras */
  .prosc-cell {
    border-top: 1px solid var(--rule);
    padding-top: 20px;
    margin-top: 10px;
  }
  .prosc-cell:first-child { border-top: none; padding-top: 0; margin-top: 0; }

  /* Evitar que los tags de etiqueta se corten */
  .cell-tag {
    display: inline-block;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Precio destacado — asegurar que no se solape */
  .cell strong {
    display: block;
    margin-top: 4px;
  }
}

/* ==========================================================================
   LOGOS DE MARCA EN COMPARADOR
   ========================================================================== */

/* Logo en items del dropdown */
.dropdown-item {
  display: flex !important;
  align-items: center;
  gap: 12px;
}

.dropdown-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  padding: 0;
  flex-shrink: 0;
  overflow: visible;
}
.dropdown-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dropdown-text {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Logo en cabecera de coche en tabla comparativa */
.car-header-logo {
  width: 64px;
  height: 64px;
  background: transparent;
  border: none;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: visible;
}
.car-header-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 900px) {
  .car-header-logo { width: 52px; height: 52px; padding: 0; margin-bottom: 0; }
  .car-header { display: flex; align-items: center; gap: 12px; }
}

/* ==========================================================================
   AUTIP DICE en comparador
   ========================================================================== */
.compare-autip-says {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin: 24px 0;
}

.compare-autip-says-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--ink);
}

.compare-autip-says-title::before {
  content: "—";
  color: var(--accent);
  margin-right: 12px;
}

.compare-autip-says-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  gap: 20px;
  margin-top: 24px;
}

.compare-autip-says-cell {
  background: var(--paper-2);
  border-left: 3px solid var(--accent);
  padding: 18px 20px;
  border-radius: 4px;
}

.compare-autip-says-cell h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 12px;
}

.compare-autip-says-cell p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  margin: 0;
}

.compare-autip-says-cell .autip-says-empty {
  font-style: normal;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-body);
}

@media (max-width: 800px) {
  .compare-autip-says-grid {
    grid-template-columns: 1fr;
  }
  .compare-autip-says {
    padding: 24px 20px;
  }
}
