.hero-search-row {
  position: relative;
}
.hero-search-row .input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.hero-search-row .input-group input,
.hero-search-row .input-group select {
  padding-left: 38px !important;
}
.hero-search-row .input-group .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #94a3b8;
  pointer-events: none;
  z-index: 2;
}
.hero-search-row {
  display: flex;
  gap: 14px;
  align-items: center;
  background: rgba(255,255,255,0.96);
  padding: 16px 18px;
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(3,35,102,0.07);
  border: 1.5px solid #e6edf8;
  position: relative;
}
.hero-search-row input,
.hero-search-row select {
  height: 48px;
  padding: 0 44px 0 38px;
  border-radius: 12px;
  border: 1.5px solid #e6edf8;
  background: #fff;
  box-shadow: none;
  font-size: 1rem;
  color: #0b1220;
  transition: box-shadow 160ms, border-color 120ms;
}
.hero-search-row input:focus,
.hero-search-row select:focus {
  outline: none;
  box-shadow: 0 10px 30px rgba(3,35,102,0.10);
  border-color: #0091FF;
}
.hero-search-row .input-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #94a3b8;
  pointer-events: none;
}
.hero-search-row .input-icon.search { left: unset; right: 24px; }
.hero-search-row .input-icon.vehicle { color: #0091FF; }
.hero-search-row .input-icon.brand { color: #0041C2; }
.hero-search-row .input-icon.ref { color: #06b6d4; }
.hero-search-row .input-icon.cat { color: #475569; }
.hero-search-row #ap-hero-search-btn {
  background: linear-gradient(135deg,#0041C2 0%,#0091FF 100%);
  color: #fff;
  border: none;
  padding: 0 28px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  height: 48px;
  font-size: 1.08rem;
  box-shadow: 0 10px 26px rgba(3,35,102,0.10);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-search-row #ap-hero-search-btn svg {
  width: 20px;
  height: 20px;
  margin-left: 4px;
  color: #fff;
}
.hero-search-row #ap-hero-search-btn:hover { transform: translateY(-2px); background: linear-gradient(135deg,#0091FF 0%,#0041C2 100%); }
.hero-search-row #ap-brand-select, .hero-search-row #ap-hero-cat {
  min-width:140px; max-width:220px;
}
.hero-search-row #ap-brand-ref { min-width:160px; max-width:220px; }
.hero-search-row #ap-vehicle { min-width:200px; max-width:320px; }
.hero-search-row #ap-hero-search { flex: 1 1 240px; min-width:140px; }

@media (max-width: 920px) {
  .hero-compact .hero-inner { flex-direction: column; align-items: stretch; }
  .hero-search-row { flex-wrap: wrap; gap:10px; padding: 14px; }
  .hero-search-row input, .hero-search-row select, .hero-search-row .btn-primary { flex: 1 1 100%; }
}
/* MODAL: overlay/backdrop */
.preview-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}
.preview-modal-backdrop[style*="display: flex"] {
  display: flex !important;
}

/* HERO COMPACTO (arriba de la grilla) */
.hero-compact {
  background: linear-gradient(180deg, rgba(0,65,194,0.03) 0%, rgba(255,255,255,0.0) 100%);
  padding: 20px 0 26px 0;
  margin-bottom: 22px;
}
.hero-compact .hero-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
}

/* Full-bleed hero: hacer que el hero ocupe todo el ancho de la ventana
   independientemente del contenedor padre. El contenido interno sigue
   centrado y limitado por `max-width` en `.hero-inner`. */
.hero-compact {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}
.hero-compact .hero-inner { padding: 0 28px; }

/* Mejora visual del filtro en el hero: inputs y botones profesionales */
.hero-search-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,0.85);
  padding: 10px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(3,35,102,0.04);
}
.hero-search-row input,
.hero-search-row select,
.hero-search-row .btn-primary {
  height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #e6edf8;
  background: #fff;
  box-shadow: none;
  transition: box-shadow 160ms ease, transform 120ms ease, border-color 120ms ease;
  font-size: 0.95rem;
  color: #0b1220;
}
.hero-search-row input:focus,
.hero-search-row select:focus,
.hero-search-row .btn-primary:focus {
  outline: none;
  box-shadow: 0 10px 30px rgba(3,35,102,0.08);
  border-color: #cfe3ff;
}

/* Hacer que el campo de búsqueda principal ocupe el espacio restante */
.hero-search-row #ap-hero-search { flex: 1 1 240px; min-width:140px; }

/* Ajustes puntuales de anchura para otros controles */
.hero-search-row #ap-brand-select { min-width:140px; max-width:220px; }
.hero-search-row #ap-brand-ref { min-width:160px; max-width:220px; }
.hero-search-row #ap-vehicle { min-width:200px; max-width:320px; }
.hero-search-row #ap-hero-cat { min-width:160px; max-width:220px; }

/* Botón buscar más visible */
.hero-search-row #ap-hero-search-btn {
  background: linear-gradient(135deg,#0041C2 0%,#0091FF 100%);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(3,35,102,0.10);
}
.hero-search-row #ap-hero-search-btn:hover { transform: translateY(-2px); }

/* CTA dentro del hero */
.hero-compact .btn-primary#ap-hero-cta { display:none; }

/* Responsive: apilar buscador en dispositivos pequeños */
@media (max-width: 920px) {
  .hero-compact .hero-inner { flex-direction: column; align-items: stretch; }
  .hero-search-row { flex-wrap: wrap; gap:8px; }
  .hero-search-row input, .hero-search-row select, .hero-search-row .btn-primary { flex: 1 1 100%; }
  .hero-search-row { padding: 12px; }
  .hero-compact .hero-right { align-items: stretch; }
}
.hero-compact .hero-left h1 {
  margin: 0 0 6px 0;
  color: #002a66;
  font-size: 32px;
  font-weight: 800;
  line-height: 1.04;
}
.hero-compact .hero-left p {
  margin: 0;
  color: #556377;
  font-size: 0.99rem;
}

/* Mejora visual del bloque de texto del hero */
.hero-compact .hero-left {
  background: rgba(255,255,255,0.92);
  border-radius: 18px;
  box-shadow: 0 6px 24px rgba(3,35,102,0.06);
  padding: 28px 28px 22px 32px;
  margin-bottom: 18px;
  max-width: 340px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.hero-compact .hero-left h1 {
  font-size: 2.2rem;
  font-weight: 900;
  color: #003399;
  margin-bottom: 10px;
  letter-spacing: -1px;
  line-height: 1.08;
  text-shadow: 0 2px 8px rgba(0,65,194,0.08);
}
.hero-compact .hero-left p {
  font-size: 1.08rem;
  color: #475569;
  margin-bottom: 0;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .hero-compact .hero-left {
    padding: 18px 12px 14px 14px;
    max-width: 100%;
    min-width: 0;
  }
  .hero-compact .hero-left h1 { font-size: 1.3rem; }
  .hero-compact .hero-left p { font-size: 0.98rem; }
}
.hero-compact .hero-right { display:flex; flex-direction:column; align-items:flex-end; }
.hero-search-row { display:flex; gap:10px; align-items:center; }
.hero-search-row input[type="search"], .hero-search-row input[list] {
  padding:12px 14px;
  border-radius:12px;
  border:1px solid #e6edf8;
  min-width:220px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(3,35,102,0.03);
  transition: box-shadow 180ms ease, transform 120ms ease;
}
.hero-search-row input[type="search"]:focus, .hero-search-row input[list]:focus {
  outline: none;
  box-shadow: 0 10px 30px rgba(3,35,102,0.08);
  transform: translateY(-1px);
  border-color: #cfe3ff;
}
.hero-search-row select {
  padding:10px 12px;
  border-radius:10px;
  border:1px solid #e6edf8;
  background:#fff;
}
.hero-search-row button.btn-primary {
  padding:10px 14px;
  border-radius:12px;
  border:none;
  color:#fff;
  background: linear-gradient(135deg,#0041C2 0%,#0077e6 100%);
  cursor:pointer;
  box-shadow: 0 8px 22px rgba(3,35,102,0.12);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.hero-search-row button.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(3,35,102,0.14); }

/* make CTA link visually subtle but aligned */
.hero-compact a#ap-hero-cta { display:none; }

/* small polish: align hero-left within container on small screens */

@media (max-width: 880px) {
  .hero-compact .hero-inner { flex-direction:column; align-items:flex-start; }
  .hero-compact .hero-right { width:100%; align-items:stretch; }
  .hero-search-row { width:100%; flex-wrap:wrap; }
  .hero-search-row input[type="search"] { min-width:100%; }
  .hero-compact .hero-left h1 { font-size: 22px; }
  .hero-compact .hero-left p { font-size: 0.95rem; }
}

/* CONTENEDOR PRINCIPAL DEL MODAL */
.preview-modal {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(9,30,66,0.12);
  max-width: 880px;
  width: 92vw;
  max-height: 90vh;
  overflow: auto;
  padding: 20px 22px;
  z-index: 2100;
  display: block; /* será centrado por .preview-modal-backdrop */
}

/* Estructura interna del modal */
.modal-content {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
  border-radius: 20px;
}

.modal-img {
  flex: 1.4;
  min-width: 240px;
  max-width: 460px;
  background: linear-gradient(180deg, #fbfdff 0%, #f4f7fb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px; /* reducir padding para que la caja no deje tanto espacio vacío */
  box-sizing: border-box;
}
.modal-img img {
  /* Permitir que la imagen ocupe el máximo espacio disponible sin forzar ancho fijo.
     Esto evita grandes áreas vacías debajo de la imagen en cajas altas. */
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(9,30,66,0.08);
}

.modal-info {
  flex: 1.8;
  padding: 28px 28px 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 260px;
}

.modal-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: #0b1b33;
  margin: 0;
}
.modal-sub { font-size: 0.98rem; color: #5b6b84; }
.modal-price { font-size: 1.25rem; font-weight: 700; color: #0041C2; }
.modal-unit { font-size: 0.95rem; color: #6b7280; }
.modal-qty { display: flex; align-items: center; gap: 8px; }
.modal-qty button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid #e6edf8; background: #fff; cursor: pointer; }
.modal-actions { display: flex; gap: 12px; margin-top: 6px; }
.modal-actions button { padding: 10px 18px; border-radius: 10px; border: none; cursor: pointer; font-weight: 700; }
.modal-actions .add {
  background: linear-gradient(135deg, #0041C2 0%, #0091FF 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(3,35,102,0.08);
}
.modal-actions .add:hover {
  background: linear-gradient(135deg, #003399 0%, #0077e6 100%);
}
.modal-actions .buy {
  background: #fff;
  color: #0041C2;
  border: 1px solid #e6edf8;
}
.modal-actions .buy:hover {
  background: #f4f8ff;
}

.modal-desc-card { background: #fbfbfb; border-radius: 10px; padding: 12px 14px; font-size: 0.98rem; color: #333; margin-top: 10px; align-self: flex-start; box-shadow: 0 6px 18px rgba(9,30,66,0.04); }
.preview-modal .modal-desc-fields { font-size: 1rem; color: #222; }
.preview-modal .modal-desc-fields b { font-weight: 700; color: #222; }
.preview-modal .modal-desc-link { margin-top: 10px; font-size: 0.98rem; color: #0041C2; text-decoration: underline; cursor: pointer; }
.offer-card .eye-btn { transition: box-shadow 0.22s, background 0.22s, color 0.22s, transform 0.22s; }
.offer-card .eye-btn:hover { background: #0091FF; color: #fff; box-shadow: 0 4px 16px rgba(0,145,255,0.18); transform: scale(1.15) rotate(-8deg); }
/* Fondo blanco con textura sutil (puntos muy discretos) */
html, body { background-color: #ffffff; background-image: radial-gradient(circle, rgba(0,0,0,0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.01) 1px, transparent 1px); background-size: 20px 20px, 100% 100%; background-repeat: repeat, no-repeat; color: #0b1b33; }

/* Ajuste para evitar que el contenido quede oculto debajo del header */
body { padding-top: 80px; background: linear-gradient(135deg, #f4f7fb 0%, #e6edf8 100%); min-height: 100vh; font-family: 'Segoe UI', 'Segoe UI Symbol' !important; color: #0b1220; }

.container {
  /* Usar prácticamente todo el ancho de la ventana para mostrar más tarjetas
     y reducir los márgenes laterales visibles en pantallas grandes. */
  max-width: none;
  width: calc(100vw - 48px);
  margin: 24px auto;
  padding: 0 24px;
}

.layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

aside.sidebar {
  /* aumentar ligeramente el sidebar para mejor legibilidad en pantallas anchas */
  width: 320px;
  flex: 0 0 320px;
  background: #fff;
  border: 1px solid #e6edf8;
  padding: 24px;
  border-radius: 16px;
  position: sticky;
  top: 32px;
  box-shadow: 0 8px 24px rgba(9,30,66,0.06);
  min-height: 320px;
}

main.content {
  flex: 1;
}

.ap-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

#ap-results-count {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0041C2;
}

.ap-controls button {
  background: linear-gradient(135deg, #0041C2 0%, #0091FF 100%);
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  box-shadow: 0 4px 12px rgba(0,65,194,0.10);
  transition: background 0.2s, transform 0.2s;
}
.ap-controls button:hover {
  background: linear-gradient(135deg, #0091FF 0%, #0041C2 100%);
  transform: translateY(-2px) scale(1.04);
}

#ap-grid {
  display: grid;
  /* Centrar las tarjetas y usar columnas de ancho constante para mantener
     una apariencia consistente entre recargas y resoluciones. */
  grid-template-columns: repeat(auto-fit, minmax(320px, 320px));
  justify-content: center; /* centra el conjunto de columnas */
  grid-auto-rows: 1fr; /* hace que las filas tengan la misma altura si es posible */
  gap: 32px;
}

.offer-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(9,30,66,0.08);
  padding: 22px 20px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  transition: box-shadow 0.2s, transform 0.2s;
  border: 1px solid #e6edf8;
}
/* Asegurar ancho máximo para que las tarjetas se mantengan idénticas y centradas
   dentro de la celda del grid; usar margin auto para robustez frente a reglas inline. */
.offer-card {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.offer-card:hover {
  box-shadow: 0 12px 32px rgba(0,65,194,0.12);
  transform: translateY(-4px) scale(1.02);
  border-color: #0091FF;
}
.card-media img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 12px;
  background: #f4f7fb;
}
/* Hacer que el cuerpo de la tarjeta ocupe el espacio disponible y empujar el footer
   hacia abajo para que todas las tarjetas tengan altura uniforme en la fila. */
.offer-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
.offer-footer {
  margin-top: auto; /* empuja el footer al final del contenedor */
}
.offer-name {
  /* evitar que el nombre largo rompa la tarjeta */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  hyphens: auto;
  font-size: 1.18rem;
  font-weight: 700;
  color: #0041C2;
  margin-bottom: 4px;
}

.offer-desc {
  font-size: 1rem;
  color: #6b7280;
  margin-bottom: 10px;
  /* limitar a 3 líneas y recortar con puntos suspensivos si es necesario */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  hyphens: auto;
}
.offer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}
.offer-price {
  font-size: 1.08rem;
  font-weight: 700;
  color: #0091FF;
}
.offer-actions .add-to-cart {
  background: linear-gradient(135deg, #0041C2 0%, #0091FF 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,65,194,0.10);
  transition: background 0.2s, transform 0.2s;
}
.offer-actions .add-to-cart:hover {
  background: linear-gradient(135deg, #0091FF 0%, #0041C2 100%);
  transform: translateY(-2px) scale(1.04);
}

/* Meta items dentro de la tarjeta (Familia, Vehículos, Marca repuesto) */
.offer-meta { margin-top:8px; }
.offer-meta .meta-item {
  font-size: 0.92rem;
  color: #475569;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; /* evitar que un valor largo empuje el layout */
  max-width: 100%;
}

/* En pantallas muy pequeñas permitir que meta items ocupen varias líneas sin salirse */
@media (max-width: 480px) {
  .offer-meta .meta-item { white-space: normal; }
}

/* Sidebar categorías */
#ap-categories {
  margin-bottom: 18px;
}
.ap-category {
  background: #f4f7fb;
  color: #0041C2;
  border: 1px solid #e6edf8;
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ap-category.active, .ap-category:hover {
  background: linear-gradient(135deg, #0041C2 0%, #0091FF 100%);
  color: #fff;
  border-color: #0091FF;
  transform: scale(1.04);
}
.cat-label {
  flex: 1;
}
.cat-count {
  background: #e6edf8;
  color: #0041C2;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.92rem;
  margin-left: 8px;
}
.ap-category.active .cat-count, .ap-category:hover .cat-count {
  background: #fff;
  color: #0091FF;
}

/* Inputs y select */
input[type="search"], select {
  background: #f4f7fb;
  border: 1px solid #e6edf8;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 1rem;
  margin-bottom: 8px;
  color: #0b1220;
  transition: border 0.2s;
}
input[type="search"]:focus, select:focus {
  border-color: #0091FF;
  outline: none;
}

/* Botones secundarios */
#ap-reset, #ap-bottom-reset {
  background: #fff;
  color: #0041C2;
  border: 1px solid #e6edf8;
  border-radius: 10px;
  font-weight: 600;
  padding: 8px 18px;
  transition: background 0.2s, color 0.2s;
}
#ap-reset:hover, #ap-bottom-reset:hover {
  background: #e6edf8;
  color: #0091FF;
}

/* Animación sutil de entrada */
.offer-card, .ap-category { animation: fadeInUp 0.7s ease; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

/* Sección con degradado suave azul oscuro -> azul claro */
.section-gradient-blue {
  background: linear-gradient(135deg, #0041C2 0%, #0073FF 60%);
  color: #fff;
  padding-top: 48px;
  padding-bottom: 48px;
  position: relative;
  overflow: hidden;
}

.section-gradient-blue .section-title,
.section-gradient-blue h2,
.section-gradient-blue .offers-title {
  color: #ffffff !important;
}

/* Añadir una capa semitransparente para que el contenido blanco siga legible */
.section-gradient-blue .inner-white {
  background: rgba(255,255,255,0.06);
  padding: 18px;
  border-radius: 12px;
}

/* Versión ligera del gradiente para cuando queramos cards dentro */
.section-gradient-blue .card {
  background: rgba(255,255,255,0.9);
  color: #0b1b33;
}

/* Ajustes responsivos: menos altura de padding en móviles */
@media (max-width: 640px) {
  .section-gradient-blue { padding-top: 28px; padding-bottom: 28px; }
  html, body { background-size: 16px 16px, 100% 100%; }
}

/* Degradado rojo para secciones promocionales */
.section-gradient-red {
  background: linear-gradient(135deg, #E31837 0%, #FF6B6B 60%);
  color: #ffffff;
  padding-top: 40px;
  padding-bottom: 40px;
  position: relative;
  overflow: hidden;
}

.section-gradient-red .section-title,
.section-gradient-red h2 {
  color: #fff !important;
}

@media (max-width: 640px) {
  .section-gradient-red { padding-top: 20px; padding-bottom: 20px; }
}

/* Asegurar que el header no interfiera con otros elementos */
header.topbar {
  position: relative; /* Cambiado de fixed a relative */
}
