/* ==================================================================
   AUTO KING — EXTRAS (favoritos, vistos, similares, chips, barra móvil)
   Animaciones solo con transform/opacity (baratas para la GPU) y
   desactivadas con prefers-reduced-motion.
   ================================================================== */

:root {
  --ak-x-surface: #0b1326;
  --ak-x-surface-2: #101b33;
  --ak-x-line: rgba(212, 168, 83, 0.22);
  --ak-x-gold: #d4a853;
  --ak-x-text: #f3f4f6;
  --ak-x-muted: #94a3b8;
  --ak-x-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Botón de favoritos en el menú ---------- */
.ak-fav-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  /* Escritorio: después de los enlaces del menú */
  order: 10;
  margin-left: 14px;
  border-radius: 50%;
  border: 1px solid var(--ak-x-line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ak-x-gold);
  cursor: pointer;
  transition: transform 0.25s var(--ak-x-ease), background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}
.ak-fav-btn .icon { width: 20px; height: 20px; }
.ak-fav-btn:hover { background: rgba(212, 168, 83, 0.12); border-color: var(--ak-x-gold); transform: translateY(-1px); }
.ak-fav-btn:focus-visible { outline: 2px solid var(--ak-x-gold); outline-offset: 2px; }
@media (min-width: 1101px) {
  header.menu .menu-links { margin-left: auto; }
}
@media (max-width: 1100px) {
  /* Móvil/tablet: entre el logo y el botón de menú */
  .ak-fav-btn { order: 0; margin-left: auto; margin-right: 10px; }
}
.ak-fav-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #c8102e;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px #050b1a;
  animation: akPop 0.35s var(--ak-x-ease);
}
.ak-fav-count[hidden] { display: none; }

/* ---------- Panel lateral de favoritos ---------- */
.ak-fav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 17, 0.6);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10040;
}
.ak-fav-overlay.open { opacity: 1; pointer-events: auto; }
.ak-fav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0d1a3a 0%, #070d19 100%);
  border-left: 1px solid var(--ak-x-line);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.55);
  color: var(--ak-x-text);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 0.42s var(--ak-x-ease), visibility 0s linear 0.42s;
  z-index: 10050;
}
.ak-fav-drawer.open { transform: none; visibility: visible; transition: transform 0.42s var(--ak-x-ease), visibility 0s; }
body.ak-fav-open { overflow: hidden; }
.ak-fav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--ak-x-line);
}
.ak-fav-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 20px;
  color: #fff;
}
.ak-fav-head h2 .icon { color: #c8102e; width: 22px; height: 22px; }
.ak-fav-body { flex: 1; overflow-y: auto; padding: 14px 16px; overscroll-behavior: contain; }
.ak-fav-foot { padding: 14px 16px 20px; border-top: 1px solid var(--ak-x-line); display: grid; gap: 10px; }
.ak-fav-foot:empty { display: none; }
.ak-fav-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  transition: transform 0.2s, filter 0.2s, background 0.2s;
}
.ak-fav-cta .icon { width: 18px; height: 18px; }
.ak-fav-cta:hover { transform: translateY(-1px); filter: brightness(1.08); }
.ak-fav-cmp { color: var(--ak-x-gold); border: 1px solid var(--ak-x-line); background: rgba(212, 168, 83, 0.06); }
.ak-fav-wa { color: #fff; background: #10b981; box-shadow: 0 8px 20px rgba(16, 185, 129, 0.25); }
.ak-fav-empty .ak-fav-cta { display: inline-flex; width: auto; margin-top: 16px; color: #050b1a; background: var(--ak-x-gold); }
.ak-fine { margin: 2px 0 0; font-size: 11px; color: var(--ak-x-muted); text-align: center; }

.ak-fav-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.25s var(--ak-x-ease), opacity 0.22s, border-color 0.25s;
  animation: akSlideIn 0.4s var(--ak-x-ease) both;
}
.ak-fav-item:nth-child(2) { animation-delay: 0.04s; }
.ak-fav-item:nth-child(3) { animation-delay: 0.08s; }
.ak-fav-item:nth-child(4) { animation-delay: 0.12s; }
.ak-fav-item:hover { border-color: var(--ak-x-line); }
.ak-fav-item .ak-mini-img { width: 92px; height: 66px; border-radius: 10px; }
.ak-fav-item .ak-mini-body { padding: 0; text-decoration: none; }
.ak-fav-gone { opacity: 0.7; }
.ak-leaving { opacity: 0 !important; transform: translateX(30px) scale(0.97) !important; }
.ak-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(240, 165, 0, 0.18);
  color: #f0a500;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: middle;
}
.ak-fav-empty { text-align: center; padding: 48px 18px; color: var(--ak-x-muted); }
.ak-fav-empty > .icon { width: 46px; height: 46px; color: rgba(200, 16, 46, 0.6); margin-bottom: 10px; animation: akBeat 1.8s ease-in-out infinite; }
.ak-fav-empty strong { color: #fff; font-size: 17px; }
.ak-fav-loading { display: flex; justify-content: center; padding: 40px; }
.ak-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--ak-x-gold);
  border-radius: 50%;
  animation: akSpin 0.7s linear infinite;
}

.ak-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--ak-x-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}
.ak-icon-btn .icon { width: 17px; height: 17px; }
.ak-icon-btn:hover { background: rgba(200, 16, 46, 0.15); color: #fff; transform: rotate(90deg); }
.ak-icon-btn:focus-visible { outline: 2px solid var(--ak-x-gold); outline-offset: 2px; }

/* ---------- Tarjetas mini (vistos / similares / favoritos) ---------- */
.ak-mini-card {
  flex: 0 0 auto;
  width: 220px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: var(--ak-x-surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--ak-x-text);
  text-decoration: none;
  scroll-snap-align: start;
  transition: transform 0.35s var(--ak-x-ease), border-color 0.3s, box-shadow 0.35s;
}
.ak-mini-card:hover { transform: translateY(-4px); border-color: var(--ak-x-line); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45); }
.ak-mini-card:focus-visible { outline: 2px solid var(--ak-x-gold); outline-offset: 2px; }
.ak-mini-img {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #050b1a;
  color: var(--ak-x-muted);
}
.ak-mini-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.6s var(--ak-x-ease); }
.ak-mini-img .icon { width: 30px; height: 30px; }
.ak-mini-card:hover .ak-mini-img img { transform: scale(1.06); }
.ak-mini-body { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px 14px; color: var(--ak-x-text); }
.ak-mini-name { font-weight: 700; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ak-mini-price { font-weight: 800; color: var(--ak-x-gold); font-size: 16px; }
.ak-mini-mensual { font-size: 12px; color: var(--ak-x-muted); }

/* ---------- Franjas horizontales ---------- */
.ak-strip {
  max-width: 1200px;
  /* Mismo problema que .contenedor-plantilla: con margin:auto dentro de un
     flex, sin ancho explícito la tira crecía al ancho de todas sus tarjetas. */
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 36px auto;
  padding: 22px 0 8px;
  transition: opacity 0.3s, transform 0.3s;
  animation: akFadeUp 0.6s var(--ak-x-ease) both;
}
.ak-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 14px;
}
.ak-strip-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: clamp(19px, 2.4vw, 24px);
  /* Las zonas de contenido del sitio son claras */
  color: #0b1326 !important;
}
.ak-strip-head h2 .icon { color: var(--ak-x-gold); width: 22px; height: 22px; }
.ak-strip-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 6px 20px 18px;
  scroll-snap-type: x mandatory;
  scroll-padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 168, 83, 0.35) transparent;
  -webkit-overflow-scrolling: touch;
}
.ak-link-btn {
  background: none;
  border: 0;
  padding: 6px 2px;
  color: #9a7426;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.ak-link-btn:hover { border-bottom-color: currentColor; }
.ak-recent-compact .ak-mini-card { width: 190px; }
.ak-detalle-extras { min-width: 0; max-width: 100%; }
.ak-detalle-extras .ak-strip { margin: 28px 0 0; min-width: 0; max-width: 100%; }
.ak-detalle-extras .ak-strip-head, .ak-detalle-extras .ak-strip-track { padding-left: 0; padding-right: 0; }

/* ---------- Detalle: mensualidad, compartir ---------- */
.ak-detalle-mensual {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  margin: 4px 0 8px;
  color: #64748b;
  font-size: 15px;
  text-decoration: none;
}
.ak-detalle-mensual strong { color: #9a7426; font-size: 19px; }
.ak-detalle-mensual span { color: #9a7426; font-size: 13px; }
.ak-detalle-mensual:hover span { text-decoration: underline; }
.ak-share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--ak-x-line);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.ak-share-btn .icon { width: 18px; height: 18px; color: var(--ak-x-gold); }
.ak-share-btn:hover { background: rgba(212, 168, 83, 0.12); transform: translateY(-1px); }

/* ---------- Barra fija móvil (detalle) ---------- */
.ak-sticky-cta { display: none; }
@media (max-width: 768px) {
  .ak-sticky-cta {
    position: fixed;
    left: 0;
    right: 0;
    /* rey.js publica la altura del aviso de cookies en esta variable */
    bottom: var(--rey-banner-offset, 0px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(5, 11, 26, 0.96);
    border-top: 1px solid var(--ak-x-line);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
    transform: translateY(110%);
    /* Oculta de verdad: con el aviso de cookies abierto la barra está más
       arriba y el translateY(110%) la dejaba encima del texto del aviso. */
    visibility: hidden;
    transition: transform 0.35s var(--ak-x-ease), visibility 0s linear 0.35s;
    z-index: 9990;
  }
  .ak-sticky-cta.show { transform: none; visibility: visible; transition: transform 0.35s var(--ak-x-ease), visibility 0s; }
  .ak-sticky-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .ak-sticky-name { color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ak-sticky-price { color: var(--ak-x-gold); font-weight: 800; font-size: 13px; white-space: nowrap; }
  .ak-sticky-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
  }
  .ak-sticky-btn .icon { width: 17px; height: 17px; }
  .ak-sticky-sim { color: var(--ak-x-gold); border: 1px solid var(--ak-x-line); }
  .ak-sticky-wa { background: #10b981; color: #fff; }
  /* Que los botones flotantes no queden tapados por la barra */
  body.ak-has-sticky .whatsapp-fab,
  body.ak-has-sticky .wa-tooltip { transform: translateY(-72px); }
  body.ak-has-sticky .rey-fab { transform: translateY(-72px); }
  .whatsapp-fab, .rey-fab { transition: transform 0.35s var(--ak-x-ease); }

  .ak-fav-btn { width: 38px; height: 38px; }
  .ak-mini-card { width: 170px; }
  .ak-recent-compact .ak-mini-card { width: 160px; }
  .ak-fav-item { grid-template-columns: 80px 1fr auto; }
  .ak-fav-item .ak-mini-img { width: 80px; height: 60px; }
}

/* ---------- Chips de filtro rápido (catálogo) ---------- */
.ak-chips {
  display: flex;
  gap: 8px;
  max-width: 1200px;
  margin: 14px auto 4px;
  padding: 4px 20px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 24px), transparent);
  /* Sin ancho explícito, dentro de un contenedor flex la fila crecía al ancho
     de todos los filtros (~1100 px) y en el celular el catálogo se podía
     mover de lado. Así ocupa la pantalla y los filtros se deslizan dentro. */
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overscroll-behavior-x: contain;
}
.ak-chips::-webkit-scrollbar { display: none; }
.ak-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(11, 19, 38, 0.12);
  background: #fff;
  color: #0b1326;
  box-shadow: 0 2px 8px rgba(11, 19, 38, 0.06);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.ak-chip .icon { width: 15px; height: 15px; color: #b8892f; }
.ak-chip:hover { border-color: var(--ak-x-gold); background: #fffaf0; }
.ak-chip:active { transform: scale(0.95); }
.ak-chip:focus-visible { outline: 2px solid var(--ak-x-gold); outline-offset: 2px; }
.ak-chip.active { background: #0b1326; border-color: #0b1326; color: #fff; box-shadow: 0 6px 16px rgba(11, 19, 38, 0.25); }
.ak-chip.active .icon { color: var(--ak-x-gold); }

/* ---------- Mensualidad en tarjetas del catálogo ---------- */
.ak-card-mensual { margin: 2px 0 6px; font-size: 13px; color: #64748b; }
.ak-card-mensual strong { color: #9a7426; font-size: 14px; }

/* ---------- Keyframes ---------- */
@keyframes akPop { 0% { transform: scale(0.4); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes akSlideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes akFadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes akSpin { to { transform: rotate(360deg); } }
@keyframes akBeat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.12); } 30% { transform: scale(1); } 45% { transform: scale(1.08); } }

@media (prefers-reduced-motion: reduce) {
  .ak-fav-drawer, .ak-fav-overlay, .ak-sticky-cta, .ak-mini-card, .ak-mini-img img, .ak-fav-item, .ak-strip, .ak-chip, .ak-icon-btn {
    transition: none !important;
    animation: none !important;
  }
  .ak-fav-empty > .icon, .ak-fav-count { animation: none !important; }
  .ak-mini-card:hover, .ak-mini-card:hover .ak-mini-img img { transform: none; }
}

/* ---------- Ficha técnica en móvil ----------
   La tabla de 4 columnas (dato/valor/dato/valor) se salía de la pantalla en
   celulares y cortaba valores como el precio. En pantallas chicas cada fila
   se acomoda en 2 columnas. */
@media (max-width: 600px) {
  .spec-table, .spec-table tbody { display: block; width: 100%; }
  .spec-table tr { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; }
  .spec-table th, .spec-table td { display: block; width: auto !important; min-width: 0; overflow-wrap: anywhere; }
  .spec-table th.spec-empty, .spec-table th.spec-empty + td { display: none; }
}

/* ---------- "Tengo un auto a cuenta" (simulador del detalle) ---------- */
.ak-cuenta {
  margin: 14px 0 6px;
  padding: 12px 14px;
  border: 1px dashed rgba(154, 116, 38, 0.45);
  border-radius: 12px;
  background: #fffaf0;
}
.ak-cuenta-toggle { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: #0b1326; cursor: pointer; }
.ak-cuenta-toggle input { width: 18px; height: 18px; accent-color: #b8892f; }
.ak-cuenta #cuenta-campos { margin-top: 12px; animation: akFadeUp 0.35s var(--ak-x-ease) both; }
.ak-cuenta-nota { margin: 8px 0 0; font-size: 13px; color: #64748b; line-height: 1.5; }
.ak-cuenta-nota a { color: #9a7426; font-weight: 700; white-space: nowrap; }

/* Aviso en vender.html cuando viene de "auto a cuenta" */
.ak-cuenta-banner {
  margin: 0 auto 18px;
  max-width: 760px;
  padding: 14px 18px;
  border-radius: 12px;
  background: #fffaf0;
  border: 1px solid rgba(154, 116, 38, 0.45);
  color: #0b1326;
  font-weight: 600;
  line-height: 1.5;
}
.ak-cuenta-banner strong { color: #9a7426; }
