/**
 * CRITICAL MOBILE FIXES
 * Soluciones urgentes para problemas críticos de UX móvil
 * Version: 1.0.0
 *
 * PROBLEMAS SOLUCIONADOS:
 * 1. Precios amontonados en comparación de productos
 * 2. Scroll vertical bloqueado
 * 3. Botones de búsqueda y escaneo invisibles
 * 4. Menú de usuario fuera de pantalla
 * 5. Foto de perfil descuadrada
 * 6. Vista de escritorio incorrecta
 */

/* =============================================
   1. FIX: PRECIOS AMONTONADOS
   El problema era position:absolute sin coordenadas claras
   ============================================= */

.sp-product-card__price-badge {
  position: absolute !important;
  top: 8px !important;
  right: 8px !important;
  background: linear-gradient(135deg, #136213 0%, #1a741a 100%) !important;
  color: white !important;
  padding: 4px 12px !important;
  border-radius: 20px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 2px !important;
  font-weight: 700 !important;
  z-index: 10 !important;
  white-space: nowrap !important;
  max-width: calc(100% - 16px) !important;
}

.sp-product-card__price-currency {
  font-size: 0.875rem !important;
  opacity: 0.9 !important;
}

.sp-product-card__price-value {
  font-size: 1rem !important;
  line-height: 1 !important;
}

/* Asegurar que el contenedor de imagen permite absolute positioning */
.sp-product-card__image-wrapper {
  position: relative !important;
  width: 100% !important;
  aspect-ratio: 1 / 1 !important;
  overflow: hidden !important;
  background-color: #f8f9fa !important;
}

/* Tarjeta de producto: asegurar estructura correcta */
.sp-product-card {
  position: relative !important;
  background-color: white !important;
  border: 1px solid #dee2e6 !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

/* =============================================
   2. FIX: SCROLL VERTICAL BLOQUEADO
   ============================================= */

/* Remover cualquier overflow hidden del body Y RESTAURAR FONDO CON PATRÓN REPETIDO */
body {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  position: relative !important;
  /* RESTAURAR FONDO CON PATRÓN QUE SE REPITE (NO COVER) */
  background-image: url('/img/background3.webp') !important;
  background-size: auto !important;
  background-attachment: scroll !important;
  background-position: top left !important;
  background-repeat: repeat !important;
}

html {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scroll-behavior: smooth !important;
}

/* Asegurar que el contenedor principal permita scroll */
.container-fluid {
  overflow: visible !important;
  min-height: calc(100vh - 64px) !important;
}

main {
  overflow: visible !important;
  position: relative !important;
}

/* Prevenir que navbar bloquee el scroll */
.navbar.fixed-top {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1030 !important;
}

/* =============================================
   3. FIX: BOTONES DE BÚSQUEDA Y ESCANEO INVISIBLES
   ============================================= */

/* Botón de búsqueda - hacer visible y accesible (CUADRADO CON BORDES REDONDEADOS) */
.sp-navbar__btn--search,
button[type="submit"][aria-label*="Buscar"] {
  min-width: 44px !important;
  min-height: 44px !important;
  width: 44px !important;
  height: 44px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 10px !important;
  border: 2px solid rgba(255, 255, 255, 0.5) !important;
  background-color: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
  font-size: 1.25rem !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  opacity: 1 !important;
  visibility: visible !important;
  z-index: 10 !important;
}

.sp-navbar__btn--search:hover,
button[type="submit"][aria-label*="Buscar"]:hover {
  background-color: rgba(255, 255, 255, 0.3) !important;
  border-color: white !important;
  transform: scale(1.05) !important;
}

/* Botón de escaneo - solo estilos de estructura (estados manejados en header.edge) */
.sp-navbar__btn--scan,
button[aria-label*="Escanear"],
#tour2 {
  min-width: 44px !important;
  min-height: 44px !important;
  width: 44px !important;
  height: 44px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 10px !important;
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  font-size: 1.25rem !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  opacity: 1 !important;
  visibility: visible !important;
  z-index: 10 !important;
}

/*
 * FIX: Calculadora (<a> tag) - normalizar para que coincida con <button>
 * Un <a> tiene display:inline, line-height y text-decoration diferentes a <button>.
 * Forzar inline-flex + line-height:1 + text-decoration:none garantiza alineación
 * visual perfecta con los demás botones de acción.
 */
a.sp-navbar__btn--calc,
a.sp-navbar__btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  text-decoration: none !important;
  /* Asegurar que el box model sea idéntico al de <button> */
  box-sizing: border-box !important;
  vertical-align: middle !important;
}

/* Contenedor de botones de acción */
.sp-navbar__actions {
  display: flex !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  align-items: center !important;
}

/*
 * FIX MOBILE: En pantallas <= 430px hay 4 botones de acción (40px c/u = 160px)
 * + usuario (44px) + gaps + padding = deja muy poco espacio al input.
 * Reducir a 38px con gap 4px: (4×38) + (3×4) = 164px total — mucho más manejable.
 */
@media (max-width: 430px) {
  .sp-navbar__actions {
    gap: 4px !important;
  }

  .sp-navbar__btn,
  .sp-navbar__btn--search,
  .sp-navbar__btn--scan,
  a.sp-navbar__btn--calc,
  a.sp-navbar__btn {
    min-width: 38px !important;
    min-height: 38px !important;
    width: 38px !important;
    height: 38px !important;
    font-size: 1.1rem !important;
    border-radius: 8px !important;
  }
}

/* Pantallas muy pequeñas (< 360px): visual más pequeño pero hit area 44px */
@media (max-width: 359px) {
  .sp-navbar__actions {
    gap: 3px !important;
  }

  .sp-navbar__btn,
  .sp-navbar__btn--search,
  .sp-navbar__btn--scan,
  a.sp-navbar__btn--calc,
  a.sp-navbar__btn {
    /* Visual size: 36px, but hit area stays 44px via padding */
    min-width: 36px !important;
    min-height: 36px !important;
    width: 36px !important;
    height: 36px !important;
    font-size: 1rem !important;
    border-radius: 7px !important;
    /* Extend touch target to 44px with transparent padding */
    position: relative !important;
  }

  /* Invisible hit area extension to meet 44px minimum */
  .sp-navbar__btn::before,
  .sp-navbar__btn--search::before,
  .sp-navbar__btn--scan::before,
  a.sp-navbar__btn--calc::before,
  a.sp-navbar__btn::before {
    content: '' !important;
    position: absolute !important;
    top: -4px !important;
    left: -4px !important;
    right: -4px !important;
    bottom: -4px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* =============================================
   4. FIX: MENÚ DE USUARIO FUERA DE PANTALLA
   ============================================= */

/* Dropdown menu: asegurar que se muestre dentro de la pantalla */
.dropdown-menu {
  position: absolute !important;
  right: 0 !important;
  left: auto !important;
  top: 100% !important;
  margin-top: 8px !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid #dee2e6 !important;
  padding: 8px !important;
  min-width: 220px !important;
  max-width: 280px !important;
  background-color: white !important;
  z-index: 1050 !important;
}

/* Alinear dropdown al final para móvil */
.dropdown-menu-end {
  right: 0 !important;
  left: auto !important;
}

/* Asegurar que el dropdown no se salga en mobile - MUY IMPORTANTE */
@media (max-width: 767px) {
  .dropdown-menu {
    right: 0 !important;
    left: auto !important;
    transform: translateX(0) !important;
    max-width: calc(100vw - 32px) !important;
    /* Forzar posicionamiento desde la derecha */
    margin-right: 0 !important;
    margin-left: auto !important;
  }

  /* Contenedor del dropdown también debe estar alineado */
  .dropdown,
  .sp-navbar__user {
    position: relative !important;
  }

  /* Si Bootstrap JS aplica estilos inline, sobrescribir */
  .dropdown-menu[style] {
    right: 0 !important;
    left: auto !important;
  }
}

/* Items del dropdown */
.dropdown-item {
  border-radius: 8px !important;
  padding: 12px 16px !important;
  font-size: 1rem !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  transition: background-color 0.15s ease !important;
  min-height: 44px !important;
  color: #212529 !important;
  text-decoration: none !important;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: #f8f9fa !important;
  color: #136213 !important;
}

.dropdown-item i {
  width: 20px !important;
  text-align: center !important;
  font-size: 1.125rem !important;
}

/* =============================================
   5. FIX: FOTO DE PERFIL DESCUADRADA
   ============================================= */

/* Avatar del usuario: corregir forma circular */
.sp-navbar__avatar {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: 2px solid rgba(255, 255, 255, 0.5) !important;
  display: block !important;
}

/* Botón de usuario */
.sp-navbar__user-btn {
  min-width: 44px !important;
  min-height: 44px !important;
  width: 44px !important;
  height: 44px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 50% !important;
  border: none !important;
  background: transparent !important;
  cursor: pointer !important;
  transition: transform 0.2s ease !important;
}

.sp-navbar__user-btn:hover {
  transform: scale(1.05) !important;
}

.sp-navbar__user-btn:focus {
  outline: 2px solid white !important;
  outline-offset: 2px !important;
}

/* Dropdown toggle arrow: ocultar o estilizar */
.sp-navbar__user-btn::after {
  display: none !important;
}

/* =============================================
   6. FIX: VISTA DE ESCRITORIO
   ============================================= */

/* Desktop: mejorar layout del navbar */
@media (min-width: 768px) {
  .navbar.fixed-top {
    min-height: 72px !important;
    padding: 12px 24px !important;
  }

  .sp-navbar__main {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
  }

  .sp-navbar__search {
    flex: 1 !important;
    max-width: 600px !important;
  }

  .sp-navbar__search-input {
    height: 48px !important;
    font-size: 1rem !important;
    padding: 12px 20px !important;
  }

  .sp-navbar__btn {
    width: 48px !important;
    height: 48px !important;
    font-size: 1.5rem !important;
  }

  .sp-navbar__avatar {
    width: 44px !important;
    height: 44px !important;
  }

  .sp-navbar__user-btn {
    width: 48px !important;
    height: 48px !important;
  }

  /* Grid de productos en desktop */
  .sp-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
    gap: 24px !important;
  }
}

@media (min-width: 992px) {
  .sp-product-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 32px !important;
  }
}

@media (min-width: 1200px) {
  .sp-product-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 32px !important;
  }
}

/* =============================================
   7. FIX: ESPACIADO Y LAYOUT MÓVIL
   ============================================= */

/* Mobile: asegurar espaciado correcto */
@media (max-width: 767px) {
  /* Reducir altura del navbar */
  .navbar.fixed-top {
    min-height: 64px !important;
    padding: 8px 16px !important;
  }

  /* Ajustar body padding-top */
  body {
    padding-top: 64px !important;
  }

  /* Navbar main: layout compacto */
  .sp-navbar__main {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
  }

  /* Search input: ocupar espacio disponible */
  .sp-navbar__search {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .sp-navbar__search-input {
    width: 100% !important;
    height: 44px !important;
    font-size: 1rem !important;
    padding: 8px 16px !important;
  }

  /* Grid de productos en mobile: 2 columnas */
  .sp-product-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    padding: 0 !important;
  }

  /* Ajustar cards en mobile */
  .sp-product-card__content {
    padding: 12px !important;
  }

  .sp-product-card__title {
    font-size: 0.875rem !important;
    -webkit-line-clamp: 2 !important;
    min-height: auto !important;
  }

  .sp-product-card__price-badge {
    padding: 4px 8px !important;
    top: 4px !important;
    right: 4px !important;
  }

  .sp-product-card__price-value {
    font-size: 0.875rem !important;
  }

  .sp-product-card__market-name {
    font-size: 0.75rem !important;
  }
}

/* =============================================
   8. FIX: COMPATIBILIDAD CON SAFE AREAS (NOTCH)
   ============================================= */

@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left)) !important;
    padding-right: max(0px, env(safe-area-inset-right)) !important;
  }

  .navbar.fixed-top {
    padding-left: max(16px, env(safe-area-inset-left)) !important;
    padding-right: max(16px, env(safe-area-inset-right)) !important;
    padding-top: max(8px, env(safe-area-inset-top)) !important;
  }
}

/* =============================================
   9. FIX: MEJORAR CONTRASTE Y LEGIBILIDAD
   ============================================= */

/* Asegurar que los iconos sean visibles (sin forzar color) */
.sp-navbar__btn i,
.sp-navbar__btn--search i,
.sp-navbar__btn--scan i,
button[type="submit"] i,
button[aria-label*="Buscar"] i,
button[aria-label*="Escanear"] i,
#tour2 i {
  font-size: 1.25rem !important;
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto !important;
  height: auto !important;
  line-height: 1 !important;
}

/* FORZAR VISIBILIDAD DE ICONOS BOOTSTRAP */
.bi-search,
.bi-upc-scan {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 1 !important;
  font-family: 'bootstrap-icons' !important;
  font-style: normal !important;
  font-weight: normal !important;
  font-variant: normal !important;
  text-transform: none !important;
  line-height: 1 !important;
  vertical-align: middle !important;
}

/* Si por alguna razón Bootstrap Icons no carga, usar texto fallback */
.bi-search::before {
  content: "\F52A" !important;
}

.bi-upc-scan::before {
  content: "\F8E9" !important;
}

/* Mejorar contraste en inputs */
.sp-navbar__search-input {
  border: 2px solid rgba(255, 255, 255, 0.3) !important;
  background-color: rgba(255, 255, 255, 0.95) !important;
  color: #212529 !important;
}

.sp-navbar__search-input::placeholder {
  color: #6c757d !important;
  opacity: 1 !important;
}

.sp-navbar__search-input:focus {
  border-color: white !important;
  background-color: white !important;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2) !important;
  outline: none !important;
}

/* =============================================
   10. FIX: PREVENIR ZOOM EN IOS
   ============================================= */

/* Prevenir zoom automático en iOS cuando se hace focus en inputs */
@media (max-width: 767px) {
  input[type="search"],
  input[type="text"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* =============================================
   11. FIX: PERFORMANCE Y SMOOTHNESS
   ============================================= */

/* GPU acceleration para elementos que se mueven */
.navbar.fixed-top,
.sp-product-card,
.dropdown-menu {
  will-change: transform !important;
  transform: translateZ(0) !important;
  backface-visibility: hidden !important;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  * {
    transition: none !important;
    animation: none !important;
  }
}

/* =============================================
   12. FIX: AJUSTES ESPECÍFICOS PARA OFERTAS
   ============================================= */

/* Si la sección ofertas usa el mismo componente de producto */
.sp-offers-section .sp-product-card__price-badge,
[class*="offer"] .sp-product-card__price-badge {
  background: linear-gradient(135deg, #dc3545 0%, #ff6b6b 100%) !important;
}

/* Asegurar que ofertas también tengan grid correcto */
.sp-offers-grid {
  display: grid !important;
  gap: 16px !important;
}

@media (max-width: 767px) {
  .sp-offers-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
}

@media (min-width: 768px) {
  .sp-offers-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 24px !important;
  }
}

@media (min-width: 992px) {
  .sp-offers-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 32px !important;
  }
}

/* Correcciones específicas para página de ofertas */

/* Asegurar scroll en página de ofertas */
.offers-container {
  overflow: visible !important;
  position: relative !important;
}

.offer-card {
  overflow: visible !important;
  position: relative !important;
}

/* Mobile: mejorar badges de ofertas para que no se amontonen */
@media (max-width: 767px) {
  /* Savings badge en ofertas */
  .savings-badge {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    z-index: 10 !important;
    padding: 6px 10px !important;
    border-radius: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    max-width: calc(100% - 16px) !important;
  }

  .savings-amount {
    font-size: 1.1rem !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  .savings-label {
    font-size: 0.6rem !important;
    white-space: nowrap !important;
  }

  /* Limited time badge */
  .limited-time-badge {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    left: auto !important;
    z-index: 10 !important;
    white-space: nowrap !important;
    max-width: calc(50% - 16px) !important;
  }

  /* Imagen de oferta: no debe cortar los badges */
  .offer-image-container {
    position: relative !important;
    overflow: visible !important;
    min-height: 280px !important;
    padding: 1.5rem !important;
  }

  /* Ajustar body de oferta para no sobreponerse */
  .offer-body {
    padding: 1rem !important;
    padding-top: 1rem !important;
  }

  /* Best price box en mobile */
  .best-price-box {
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
  }

  .best-price-content {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .market-logo-compact {
    height: 40px !important;
    max-width: 120px !important;
  }

  .best-price-amount {
    font-size: 2rem !important;
  }

  /* High price box en mobile */
  .high-price-box {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
    padding: 0.75rem !important;
  }

  .high-price-link {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  .market-logo-small {
    height: 32px !important;
    max-width: 100px !important;
  }

  .high-price-amount {
    font-size: 1.25rem !important;
  }

  /* Countdown wrapper */
  .countdown-wrapper {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
    padding: 0.75rem !important;
  }

  .countdown-time {
    font-size: 1.5rem !important;
    align-self: center !important;
  }

  /* Título de oferta */
  .offer-title {
    font-size: 1.1rem !important;
    line-height: 1.4 !important;
    margin-bottom: 0.75rem !important;
  }

  .offer-description {
    font-size: 0.9rem !important;
    line-height: 1.5 !important;
    margin-bottom: 1rem !important;
  }

  /* Header de ofertas */
  .offers-header {
    padding: 1.5rem 0 !important;
    margin-bottom: 1.5rem !important;
  }

  .offers-title {
    font-size: 1.75rem !important;
    margin-bottom: 0.5rem !important;
  }

  .offers-subtitle {
    font-size: 1rem !important;
  }

  /* Container de ofertas en mobile */
  .offers-container {
    padding: 0 1rem !important;
  }

  /* Card de oferta: layout vertical en mobile */
  .offer-card .row {
    flex-direction: column !important;
  }

  .offer-card .col-md-4,
  .offer-card .col-md-8 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }
}

/* =============================================
   13. FIX: Z-INDEX HIERARCHY
   ============================================= */

/* Asegurar jerarquía correcta de z-index */
.navbar.fixed-top {
  z-index: 1030 !important;
}

.dropdown-menu {
  z-index: 1050 !important;
}

.sp-product-card__price-badge {
  z-index: 10 !important;
}

.modal {
  z-index: 1055 !important;
}

.modal-backdrop {
  z-index: 1040 !important;
}

/* =============================================
   14. FIX: TOUCH TARGETS (ACCESSIBILITY)
   ============================================= */

/* Asegurar que todos los elementos interactivos tengan 44x44px mínimo */
button,
a,
input[type="submit"],
.btn,
.dropdown-item {
  min-height: 44px !important;
  min-width: 44px !important;
}

/* Exception para inline links */
a:not(.btn):not(.dropdown-item):not(.sp-navbar__btn) {
  min-height: auto !important;
  min-width: auto !important;
}

/* =============================================
   15. FIX CRÍTICO: SEARCHGROUPED - PRECIOS AMONTONADOS
   Esta es la página donde los precios se ven peor
   ============================================= */

/* Contenedor de precios en searchgrouped */
.card-text {
  display: flex !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  gap: 12px !important;
  padding: 12px 0 !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
}

/* Botones de precio en searchgrouped */
.card-text .btn {
  flex-shrink: 0 !important;
  min-width: 120px !important;
  padding: 12px 16px !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  height: auto !important;
  border-radius: 12px !important;
  border: 2px solid #dee2e6 !important;
  background-color: white !important;
  transition: all 0.2s ease !important;
}

.card-text .btn:hover,
.card-text .btn:focus {
  border-color: #136213 !important;
  background-color: #f8f9fa !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

/* Box dentro del botón */
.card-text .btn .box {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100% !important;
}

/* Logo del supermercado */
.card-text .btn .box img {
  height: 40px !important;
  max-width: 100px !important;
  object-fit: contain !important;
  display: block !important;
}

/* Precio */
.card-text .btn .box strong {
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  color: #136213 !important;
  display: block !important;
  white-space: nowrap !important;
}

/* Scroll indicator (opcional - muestra que hay más) */
.card-text::after {
  content: '' !important;
  position: sticky !important;
  right: 0 !important;
  width: 40px !important;
  height: 100% !important;
  background: linear-gradient(to right, transparent, white) !important;
  pointer-events: none !important;
  flex-shrink: 0 !important;
}

/* Mobile: ajustes específicos */
@media (max-width: 767px) {
  .card-text {
    gap: 8px !important;
    padding: 8px 0 !important;
  }

  .card-text .btn {
    min-width: 100px !important;
    padding: 10px 12px !important;
    gap: 6px !important;
  }

  .card-text .btn .box img {
    height: 32px !important;
    max-width: 80px !important;
  }

  .card-text .btn .box strong {
    font-size: 1.1rem !important;
  }
}

/* Card principal en searchgrouped */
.card.mb-3 {
  border-radius: 12px !important;
  overflow: hidden !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  border: 1px solid #dee2e6 !important;
  margin-bottom: 1.5rem !important;
}

.card.mb-3:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
  border-color: #136213 !important;
}

/* Imagen del producto */
.card.mb-3 .col-md-4 img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  background-color: #f8f9fa !important;
}

@media (max-width: 767px) {
  .card.mb-3 .col-md-4 {
    max-height: 250px !important;
  }

  .card.mb-3 .col-md-4 img {
    object-fit: contain !important;
    padding: 1rem !important;
  }
}

/* Card body */
.card.mb-3 .card-body {
  padding: 1.5rem !important;
}

@media (max-width: 767px) {
  .card.mb-3 .card-body {
    padding: 1rem !important;
  }
}

/* Card title */
.card.mb-3 .card-title {
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  color: #212529 !important;
  margin-bottom: 1rem !important;
  line-height: 1.4 !important;
}

@media (max-width: 767px) {
  .card.mb-3 .card-title {
    font-size: 1.1rem !important;
    margin-bottom: 0.75rem !important;
  }
}

/* Barcode text */
.card.mb-3 .text-muted {
  font-size: 0.875rem !important;
  margin-top: 0.75rem !important;
  display: block !important;
}

/* =============================================
   16. DEBUG: HELPERS (COMENTAR EN PRODUCCIÓN)
   ============================================= */

/* Descomentar para debugging en desarrollo */
/*
.sp-product-grid {
  outline: 2px solid red !important;
}

.sp-product-card {
  outline: 2px solid blue !important;
}

.sp-navbar__main {
  outline: 2px solid green !important;
}

.sp-navbar__actions {
  outline: 2px solid yellow !important;
}

.card-text {
  outline: 3px solid orange !important;
}

.card-text .btn {
  outline: 2px solid purple !important;
}
*/
