/**
 * compat-tab.css — wizard "Vehículos compatibles" 1.4.46+
 *
 * COMPLEMENTO de los estilos legacy en `front-deferred.css` (que ya define
 * .ks-compat__cats, .ks-compat__cat, .ks-compat__group, .ks-compat__brand-row,
 * .ks-compat__chevron, .ks-compat__brands grid…). Aquí solo añadimos:
 *   - lead AEO con border-left destacado
 *   - skeleton loader durante AJAX
 *   - estados (loading, error)
 *   - layer L4 chips de años (compactos)
 *
 * El visual de chips/marcas/modelos viene del legacy compartido.
 */

/* ── Lead AEO ──────────────────────────────────────────────────────── */

.ks-compat__lead {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #374151;
  background: #f5f8ff;
  border-left: 3px solid var(--ks-primary, #24b9d7);
  padding: 12px 14px;
  border-radius: 4px;
}
.ks-compat__lead strong {
  color: #1e3a8a;
  font-weight: 700;
}

/* ── Brand row: altura uniforme (con o sin logo) ───────────────────── */
/* Garantiza que cada fila de marca quede con la misma altura aunque la
   marca no tenga logo: reserva 48x48 con un placeholder visible (inicial). */

.ks-compat__brand-row {
  min-height: 64px; /* 48 logo + 8 padding × 2 (legacy ya define padding) */
  align-items: center;
}

.ks-compat__brand-logo--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #f0f4ff 0%, #e2e8f0 100%);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1.25rem;
  color: #5a6486;
  letter-spacing: 0;
  user-select: none;
}

/* ── Brand content (slot dentro de details) ────────────────────────── */

.ks-compat__brand-content,
.ks-compat__model-content,
.ks-compat__engine-content {
  padding: 0.5rem 1rem 0.75rem;
  background: #fff;
  border-top: 1px solid #f0f2f8;
}
.ks-compat__brand-content:empty,
.ks-compat__model-content:empty,
.ks-compat__engine-content:empty {
  display: none;
}

/* ── Sublist (modelos/motores/años) — L2/L3/L4 ─────────────────────── */
/* Cada nivel L2-L4 es un grid 1col mobile / 2col desktop de <details>
   anidados. El contenido del expand inyecta el siguiente nivel. */

.ks-compat__sublist {
  display: grid;
  grid-template-columns: repeat(var(--ks-cols-m, 1), minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0.4rem 0;
}
@media (min-width: 768px) {
  .ks-compat__sublist {
    grid-template-columns: repeat(var(--ks-cols-d, 2), minmax(0, 1fr));
  }
}
.ks-compat__sublist--years {
  /* Años más estrechos: 4-6 col desktop */
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 600px) {
  .ks-compat__sublist--years { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 768px) {
  .ks-compat__sublist--years { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.ks-compat__model-group,
.ks-compat__engine-group,
.ks-compat__year-group {
  border: 1px solid #e5e8f2;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.ks-compat__model-group[open],
.ks-compat__engine-group[open],
.ks-compat__year-group[open] {
  border-color: var(--ks-primary, #24b9d7);
  box-shadow: 0 1px 4px rgba(36, 185, 215, 0.10);
}

.ks-compat__sub-row {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: #1f2937;
  transition: background 0.12s;
}
.ks-compat__sub-row::-webkit-details-marker { display: none; }
.ks-compat__sub-row:hover { background: #fafbff; }
.ks-compat__sub-row--year { padding: 0.4rem 0.55rem; font-size: 0.82rem; justify-content: center; }

.ks-compat__sub-name {
  flex: 1;
  font-weight: 600;
  color: #19416e;
  text-decoration: none;
  word-break: break-word;
}
.ks-compat__sub-name:hover { text-decoration: underline; color: var(--ks-primary, #24b9d7); }
.ks-compat__sub-pill {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--ks-primary, #24b9d7);
  border-radius: 999px;
  padding: 2px 8px;
  flex-shrink: 0;
}

.ks-compat__model-content,
.ks-compat__engine-content,
.ks-compat__year-content {
  padding: 0.4rem 0.6rem 0.6rem;
  border-top: 1px solid #f0f2f8;
  background: #fafbff;
}
.ks-compat__model-content:empty,
.ks-compat__engine-content:empty,
.ks-compat__year-content:empty {
  display: none;
}

/* ── L5: confirmación final (cat/marca/modelo/motor/año) ──────────── */

.ks-compat__l5 {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 1px solid #a7f3d0;
  border-radius: 8px;
}
.ks-compat__l5-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #065f46;
  background: #fff;
  border: 2px solid #10b981;
  border-radius: 50%;
  flex-shrink: 0;
}
.ks-compat__l5-body { flex: 1; min-width: 0; }
.ks-compat__l5-title {
  margin: 0 0 4px;
  font-weight: 700;
  color: #065f46;
  font-size: 0.95rem;
  line-height: 1.3;
}
.ks-compat__l5-text {
  margin: 0 0 8px;
  font-size: 0.88rem;
  color: #1f2937;
  line-height: 1.5;
}
.ks-compat__l5-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  background: #059669;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
}
.ks-compat__l5-cta:hover,
.ks-compat__l5-cta:focus-visible {
  background: #047857;
  color: #fff;
  text-decoration: none;
}

/* ── Vehicles grid (modelos/motores) ───────────────────────────────── */
/* Reusa --ks-cols-m / --ks-cols-d del legacy (ks-compat__brands) */

.ks-compat__vehicles {
  display: grid;
  grid-template-columns: repeat(var(--ks-cols-m, 1), 1fr);
  gap: 0.4rem;
  padding: 0.4rem 0;
}
@media (min-width: 768px) {
  .ks-compat__vehicles {
    grid-template-columns: repeat(var(--ks-cols-d, 2), 1fr);
  }
}

.ks-compat__vehicle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e5e8f2;
  border-radius: 6px;
  background: #fff;
  text-decoration: none;
  color: #1f2937;
  font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s;
}
.ks-compat__vehicle:hover,
.ks-compat__vehicle:focus-visible {
  border-color: var(--ks-primary, #24b9d7);
  background: rgba(36, 185, 215, 0.04);
  text-decoration: none;
}
.ks-compat__vehicle:focus-visible {
  outline: 2px solid rgba(36, 185, 215, 0.30);
  outline-offset: 1px;
}

.ks-compat__vehicle-label {
  flex: 1;
  font-weight: 600;
  color: #19416e;
  word-break: break-word;
}
.ks-compat__vehicle-pill {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--ks-primary, #24b9d7);
  border-radius: 999px;
  padding: 2px 8px;
  flex-shrink: 0;
}

/* ── Years (L4) — compactos horizontales ───────────────────────────── */

.ks-compat__years {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 4px;
  padding: 0.3rem 0;
}
.ks-compat__year {
  text-align: center;
  padding: 5px 8px;
  font-weight: 600;
  font-size: 0.82rem;
  color: #19416e;
  background: #f5f8ff;
  border: 1px solid #dde1f0;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.ks-compat__year:hover,
.ks-compat__year:focus-visible {
  background: var(--ks-primary, #24b9d7);
  color: #fff;
  text-decoration: none;
}

/* ── Skeleton loader (durante AJAX) ────────────────────────────────── */

.ks-compat__skeleton {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0.5rem 0;
}
.ks-compat__skeleton-row {
  height: 36px;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: ks-compat-skel 1.4s ease-in-out infinite;
}
@keyframes ks-compat-skel {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Error state ───────────────────────────────────────────────────── */

.ks-compat__error {
  margin: 0;
  padding: 0.6rem 0.8rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* ── Anchor invisible para deep-linking ────────────────────────────── */

.ks-anchor {
  display: block;
  position: relative;
  top: -80px;
  visibility: hidden;
}

/* ── Bloque "Después de los tabs" (HowTo + FAQ, 1.4.46+) ───────────── */
/* Contenedor común que separa visualmente del bloque de tabs y aplica
   el ancho del contenido de la ficha. Cada sección lleva su propio H2. */

.ks-product-aftertabs {
  margin: 32px 0 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.ks-product-aftertabs > section {
  background: #fff;
  border: 1px solid #e5e8f2;
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, 0.04);
}
.ks-pfaq__title,
.ks-howto__title {
  margin: 0 0 14px;
  font-size: 1.35rem;
  line-height: 1.2;
  color: #19416e;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── HowTo "Cómo cambiar la batería" (8 pasos numerados, 1.4.46+) ──── */

.ks-howto__header {
  margin-bottom: 18px;
}
.ks-howto__lead {
  margin: 0 0 12px;
  color: #374151;
  line-height: 1.55;
  font-size: 0.95rem;
}
.ks-howto__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ks-howto__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  background: #f5f8ff;
  border: 1px solid #dde1f0;
  border-radius: 999px;
  color: #19416e;
}
.ks-howto__chip--time {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-color: #c7d2fe;
  color: #1e3a8a;
}

.ks-howto__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: ks-howto-step;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ks-howto__step {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  background: #fafbff;
  border: 1px solid #eef0f7;
  border-radius: 8px;
  position: relative;
}
.ks-howto__step:hover {
  border-color: var(--ks-primary, #24b9d7);
  background: #fff;
  box-shadow: 0 2px 6px rgba(20, 30, 60, 0.04);
}
.ks-howto__step-num {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--ks-primary, #24b9d7) 0%, #1e3a8a 100%);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(36, 185, 215, 0.25);
}
.ks-howto__step-body {
  min-width: 0;
}
.ks-howto__step-name {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.3;
  color: #19416e;
  font-weight: 700;
}
.ks-howto__step-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-right: 4px;
}
.ks-howto__step-text {
  margin: 0;
  color: #374151;
  line-height: 1.55;
  font-size: 0.92rem;
}

/* ── Bloque "Preguntas frecuentes" (sustituye hifaq, 1.4.46+) ──────── */

.ks-product-faqs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.ks-pfaq__item {
  border: 1px solid #dde1f0;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.ks-pfaq__item[open] {
  border-color: var(--ks-primary, #24b9d7);
  box-shadow: 0 4px 14px rgba(30, 36, 80, 0.08);
}

/* `<summary>` debe quedar como list-item para que el toggle nativo funcione
   en todos los navegadores. El theme tiene `summary { display: block }` en
   el reset CSS — eso rompe el toggle en algunos motores. Forzamos
   `list-item` con specificity alta y posicionamos el icono "+" en absolute. */
.ks-product-faqs summary.ks-pfaq__question {
  display: list-item;
  list-style: none;
  cursor: pointer;
  padding: 14px 48px 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #19416e;
  position: relative;
  transition: background 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ks-pfaq__question::-webkit-details-marker {
  display: none;
}
.ks-pfaq__question::marker {
  display: none;
  content: '';
}
.ks-pfaq__question::after {
  content: '+';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f5f8ff;
  border-radius: 50%;
  color: var(--ks-primary, #24b9d7);
  font-weight: 700;
  font-size: 1.2rem;
  transition: transform 0.2s, background 0.2s, color 0.2s;
}
.ks-pfaq__item[open] .ks-pfaq__question::after {
  content: '−';
  background: var(--ks-primary, #24b9d7);
  color: #fff;
}
.ks-pfaq__question:hover {
  background: #f8fafc;
}

.ks-pfaq__answer {
  padding: 0 16px 16px;
  color: #374151;
  font-size: 0.92rem;
  line-height: 1.6;
  border-top: 1px solid #f0f2f8;
}
.ks-pfaq__answer p {
  margin: 0;
  padding-top: 12px;
}

@media (max-width: 600px) {
  .ks-pfaq__question {
    font-size: 0.88rem;
    padding: 12px 14px;
  }
  .ks-pfaq__answer {
    padding: 0 14px 14px;
    font-size: 0.85rem;
  }
}

/* ── Mobile tweaks ─────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .ks-compat__lead {
    font-size: 0.88rem;
  }
  .ks-compat__vehicle {
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
  }
  .ks-product-aftertabs {
    margin-top: 24px;
    gap: 20px;
  }
  .ks-product-aftertabs > section {
    padding: 16px 14px;
    border-radius: 8px;
  }
  .ks-pfaq__title,
  .ks-howto__title {
    font-size: 1.15rem;
  }
  .ks-howto__step {
    grid-template-columns: 36px 1fr;
    gap: 10px;
    padding: 12px 12px;
  }
  .ks-howto__step-num {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
  }
  .ks-howto__step-name {
    font-size: 0.95rem;
  }
  .ks-howto__step-text {
    font-size: 0.88rem;
  }
}
