:root {
  /* --brand-color: #ff5a5f;*/
  --brand-color: #4e68f9;
  /* Color moderno tipo Airbnb/Local */
  /* --brand-hover: #e0484d;*/
  --brand-hover: #5A77FA;
  --bg-gray: #f7f7f9;
  --text-dark: #212529;
  --text-muted: #6c757d;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-gray);
  padding-bottom: 85px;
  /* Espacio para el bottom nav en móvil y barra de compra */
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
}

.text-brand {
  color: var(--brand-color) !important;
}

.bg-brand {
  background-color: var(--brand-color) !important;
}

/* --- CABECERA --- */
.app-header {
  background-color: #fff;
  position: sticky;
  top: 0;
  z-index: 1030;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
}

.search-box {
  background-color: var(--bg-gray);
  border-radius: 12px;
}

.search-box input {
  background: transparent;
  border: none;
  box-shadow: none !important;
  font-size: 0.95rem;
}

.btn-back {
  color: #333;
  font-size: 1.4rem;
  text-decoration: none;
}

.btn-icon {
  color: var(--text-dark);
  font-size: 1.4rem;
  text-decoration: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f8f9fa;
  transition: background 0.2s;
}

.btn-icon:active {
  background: #e9ecef;
}

/* --- SCROLL HORIZONTAL NATIVO --- */
.scroll-wrapper {
  position: relative;
}

.btn-scroll {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #fff;
  border: 1px solid #e5e5e5;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.btn-scroll:hover {
  background-color: var(--brand-color);
  color: white;
  border-color: var(--brand-color);
}

.btn-scroll-prev {
  left: -15px;
}

.btn-scroll-next {
  right: -15px;
}

@media (max-width: 768px) {
  .btn-scroll {
    display: none !important;
  }
}

.scroll-horizontal {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 12px;
  padding-bottom: 15px;
  padding-top: 15px;
  /* Permite que los badges premium no se corten arriba */
  margin-top: -15px;
  /* Compensa el padding superior */
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.scroll-horizontal::-webkit-scrollbar {
  display: none;
}

/* --- CATEGORÍAS (PÍLDORAS) --- */
.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: #fff;
  border: 1px solid #e5e5e5;
  padding: 8px 16px;
  border-radius: 50px;
  color: #333;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.category-pill.active {
  background-color: var(--brand-color);
  color: white;
  border-color: var(--brand-color);
}

/* --- TARJETAS DE NEGOCIO --- */
.store-card {
  background: #fff;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid rgba(0, 0, 0, 0.06);
  position: relative;
}

.store-card:active,
.store-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08) !important;
}

.store-cover {
  height: 100px;
  width: 100%;
  background-color: #e9ecef;
  position: relative;
}

.store-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px 16px 0 0;
}

.store-logo-wrapper {
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 54px;
  background: #fff;
  border-radius: 50%;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  z-index: 2;
}

.store-logo-wrapper img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.store-card-featured {
  min-width: 260px;
  width: 260px;
}

.store-card-featured .store-cover {
  height: 110px;
}

.store-card-featured .store-logo-wrapper {
  left: 20px;
  transform: none;
  width: 60px;
  height: 60px;
  bottom: -25px;
}

.store-card-premium {
  border: 2px solid #ffc107;
  box-shadow: 0 6px 18px rgba(255, 193, 7, 0.18) !important;
  margin-top: 5px;
}

.premium-badge {
  position: absolute;
  top: -14px;
  right: 15px;
  background: linear-gradient(45deg, #ffd700, #ff8c00);
  color: #000;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  z-index: 10;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- PERFIL DE TIENDA COMPACTO --- */
.store-header-compact {
  background: #fff;
  padding: 15px 0;
  margin-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.store-logo-small {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #eee;
}

/* --- TARJETAS DE PRODUCTO COMPACTAS --- */
.product-card {
  background: #fff;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.05);
  transition: transform 0.15s;
}

.product-card:active {
  transform: scale(0.98);
}

.product-img-box {
  position: relative;
  width: 100%;
  padding-top: 100%;
  /* Cuadrado perfecto 1:1 */
  background-color: #fff;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.product-img-box img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge-add {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: var(--brand-color);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: none;
  box-shadow: 0 2px 6px rgba(255, 90, 95, 0.4);
  z-index: 5;
}

.product-details {
  padding: 8px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.product-name {
  font-size: 0.75rem;
  color: #333;
  margin-bottom: 4px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand-color);
  margin-top: auto;
}

.product-meta {
  font-size: 0.65rem;
  color: #888;
  margin-top: 2px;
}

@media (min-width: 992px) {
  .product-name {
    font-size: 0.85rem;
  }

  .product-price {
    font-size: 1.2rem;
  }
}

/* --- PRODUCTOS RELACIONADOS (MINI TARJETAS) --- */
.product-mini-card {
  min-width: 140px;
  width: 140px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #eee;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.product-mini-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.product-mini-details {
  padding: 8px;
}

/* --- CARRUSEL DE IMÁGENES --- */
.product-gallery {
  background-color: #fff;
  position: relative;
}

.carousel-item img {
  width: 100%;
  height: 350px;
  object-fit: cover;
}

.carousel-indicators [data-bs-target] {
  background-color: var(--brand-color);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: 0 4px;
}

@media (min-width: 992px) {
  .carousel-item img {
    height: 500px;
    border-radius: 16px;
    object-fit: contain;
    background: #fff;
  }

  .product-gallery {
    background: transparent;
  }
}

/* --- CONTENEDORES --- */
.info-section {
  background-color: #fff;
  padding: 15px;
  margin-bottom: 8px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 12px;
}

@media (min-width: 992px) {
  .info-section {
    border-radius: 16px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.05);
  }
}

/* --- PRECIOS --- */
.price-main {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--brand-color);
  line-height: 1;
}

.price-old {
  font-size: 1rem;
  color: #adb5bd;
  text-decoration: line-through;
  margin-left: 8px;
  font-weight: 500;
}

.discount-badge {
  background-color: #fee2e2;
  color: #dc2626;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  margin-left: 8px;
}

/* --- OPCIONES (E-commerce / Servicios) --- */
.color-option {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.color-option.active {
  border-color: var(--brand-color);
  transform: scale(1.1);
}

.pill-option {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  margin-right: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-dark);
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-option.active {
  background-color: var(--brand-color);
  border-color: var(--brand-color);
  color: #fff;
  font-weight: 600;
}

/* --- MODIFICADORES (Restaurantes) --- */
.addon-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f1f3f5;
}

.addon-item:last-child {
  border-bottom: none;
}

.custom-checkbox .form-check-input:checked {
  background-color: var(--brand-color);
  border-color: var(--brand-color);
}

/* --- TABLA DE ESPECIFICACIONES --- */
.specs-table {
  width: 100%;
  font-size: 0.85rem;
}

.specs-table td {
  padding: 8px 0;
  border-bottom: 1px solid #f8f9fa;
}

.specs-table td:first-child {
  color: var(--text-muted);
  width: 40%;
}

.specs-table td:last-child {
  color: var(--text-dark);
  font-weight: 500;
}

/* --- REVIEWS Y Q&A --- */
.review-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.qa-item {
  margin-bottom: 15px;
}

.qa-q {
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  gap: 8px;
}

.qa-a {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  margin-top: 4px;
  padding-left: 24px;
}

/* --- VENDEDOR Y PUBLICIDAD --- */
.seller-card {
  display: flex;
  align-items: center;
  padding: 12px;
  border: 1px solid #eee;
  border-radius: 12px;
  background-color: #fafafa;
}

.seller-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #ddd;
}

/* Banners Publicitarios */
.ad-banner {
  border-radius: 16px;
  position: relative;
  display: block;
  background-color: #fff;
  transition: transform 0.2s;
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.ad-banner:active,
.ad-banner:hover {
  transform: scale(0.98);
}

.ad-banner img {
  width: 100%;
  height: 110px;
  object-fit: cover;
}

.ad-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 10;
}

@media (min-width: 768px) {
  .ad-banner img {
    height: 160px;
  }
}

/* --- BARRA DE NAVEGACIÓN INFERIOR (MOBILE APP FEEL) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-around;
  padding: 10px 0 15px;
  z-index: 1040;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #888;
  text-decoration: none;
  font-size: 0.7rem;
  gap: 3px;
}

.nav-item.active {
  color: var(--brand-color);
}

.nav-item i {
  font-size: 1.3rem;
}

/* --- BARRA DE ACCIÓN INFERIOR (COMPRA/CHAT) --- */
.bottom-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #fff;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
  z-index: 1040;
}

.bottom-action-wrapper {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
}

@media (min-width: 992px) {
  .bottom-action-wrapper {
    max-width: 960px;
    gap: 15px;
    padding: 15px;
  }
}

.action-chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-muted);
  min-width: 45px;
}

.action-chat i {
  font-size: 1.3rem;
  color: var(--text-dark);
  line-height: 1;
  margin-bottom: 3px;
}

.action-chat span {
  font-size: 0.65rem;
  font-weight: 500;
}

.btn-outline-brand {
  border: 2px solid var(--brand-color);
  color: var(--brand-color);
  font-weight: 600;
  border-radius: 12px;
  flex: 1;
  padding: 10px 4px;
  background: #fff;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-brand {
  background-color: var(--brand-color);
  border: 2px solid var(--brand-color);
  color: #fff;
  font-weight: 600;
  border-radius: 12px;
  flex: 1;
  padding: 10px 4px;
  font-size: 0.95rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- CARRITO FLOTANTE (PÍLDORA) --- */
.floating-cart-container {
  position: fixed;
  bottom: 20px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 1040;
  pointer-events: none;
}

.floating-cart {
  background: #212529;
  color: white;
  border-radius: 50px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 15px;
  text-decoration: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  transition: transform 0.2s;
}

.floating-cart:active {
  transform: translateY(2px);
}

.floating-cart .cart-qty {
  background: var(--brand-color);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  font-weight: bold;
}

/* --- UTILES --- */
.truncate-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lazy-image { opacity: 0; transition: opacity 0.5s ease-in-out; }
.lazy-image.loaded { opacity: 1; }


/* --- SWEETALERT2 CUSTOMIZATIONS --- */
.swal2-popup.custom-swal {
    border-radius: 1.5rem !important;
    padding: 1.5rem !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
}
.swal2-title.custom-swal-title {
    font-weight: 700 !important;
    font-size: 1.5rem !important;
    color: var(--text-dark) !important;
}
.swal2-html-container.custom-swal-text {
    color: var(--text-muted) !important;
}
.swal2-confirm.custom-swal-confirm {
    background-color: var(--brand-color) !important;
    border-radius: 50rem !important;
    padding: 10px 24px !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 10px rgba(78, 104, 249, 0.3) !important;
}
.swal2-confirm.custom-swal-confirm:hover {
    background-color: var(--brand-hover) !important;
}
.swal2-cancel.custom-swal-cancel {
    border-radius: 50rem !important;
    padding: 10px 24px !important;
    font-weight: 600 !important;
    background-color: #f1f3f5 !important;
    color: var(--text-dark) !important;
}
.swal2-cancel.custom-swal-cancel:hover {
    background-color: #e9ecef !important;
}
.swal2-toast.custom-swal-toast {
    border-radius: 12px !important;
    padding: 12px !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08) !important;
}


/* Market Global Loader */
#marketLoaderOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 99999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}
#marketLoaderOverlay.hide {
    opacity: 0;
    visibility: hidden;
}


/* --- BOTN VOLVER ARRIBA --- */
.back-to-top {
  position: fixed;
  bottom: 80px;
  right: 15px;
  background-color: var(--brand-color);
  color: white;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1030;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover, .back-to-top:active {
  background-color: var(--brand-hover);
  color: white;
  transform: translateY(-3px);
}

@media (min-width: 768px) {
  .back-to-top {
    bottom: 30px;
    right: 30px;
  }
}
