/* MAIN CSS COMPLETO */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background: white;
    color: black;
    transition: background 0.3s, color 0.3s;
}

header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #e4e6eb;
    padding: 10px 16px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.top-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
}

.top-header > div {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 18px;
  font-weight: bold;
  pointer-events: none; /* para que no interfiera con clicks */
}


#searchInput {
    width: 100%;
    max-width: 500px; /* Limita ancho máximo en PC */
    margin: 10px auto 0 auto; /* Centra horizontalmente */
    padding: 10px 16px;
    border-radius: 16px;
    background-color: #ffffff;
    border: 1.5px solid #cccccc00;
    font-weight: 600;
    font-size: 14px;
    box-sizing: border-box;
    display: block; /* Para que margin auto funcione */
}


button, input {
    margin: 5px 0;
    padding: 6px 6px;
    border-radius: 16px;
    border: 1.5px solid #cccccc00;
    font-weight: 600;
    color: #4e4e4f;
    font-size: 14px;
    cursor: pointer;
    background-color: #e4e6eb;
    transition: transform 0.15s ease, background-color 0.3s, border-color 0.3s, color 0.3s;
    user-select: none;
    outline-offset: 2px;
}

button:active, input:active {
    transform: scale(0.95);
}

button:hover:not(.active-filter) {
    background-color: #bfbfc0;
}

.active-filter {
    background-color: #007BFF;
    color: white;
    border-color: #007BFF;
    box-shadow: 0 0 10px #0077ffaa;
}

.sticky-controls {
    display: flex;
    flex-direction: column;    /* columnas para forzar filas */
    gap: 15px;
    padding: 10px 20px;
    align-items: center;       /* centra las filas horizontalmente */
}

.sticky-controls > div {
    width: 100%;               /* ocupa todo el ancho disponible */
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: center;   /* centra los botones dentro de cada fila */
}



#productContainer {
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    min-height: 300px;
}

.product-card {
    display: flex;
    flex-direction: column;
    width: 210px;
    position: relative; /* para badge de stock */
    border: 1.5px solid #ffffff00;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 6px 10px rgba(0,0,0,0.05);
    transition: transform 0.25s ease, border-color 0.3s;
    background: #e4e6eb;
    user-select: none;
    border-radius: 25px;
    overflow: hidden;
}

/* ===== STOCK BADGE ===== */
.stock-badge{
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    background: #d32f2f;
    color: #fff;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(0,0,0,0.18);
    max-width: calc(100% - 20px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stock-badge.out{
    background: #b71c1c;
}

.product-card.is-out{
    opacity: 0.82;
}

.stock-line{
    margin: 6px 0 0 0;
    font-size: 13px;
    font-weight: 700;
    color: #444;
}

.stock-line.out{
    color: #b71c1c;
}

.product-card:hover {
    transform: scale(1.05);
    border-color: #007BFF;
    box-shadow: 0 10px 15px #007BFF55;
}

.product-card img {
    display: block;
    width: 100%;
    height: 200px;           /* Altura fija para que ocupe el área del contenedor */
    object-fit: cover;       /* Ocupa todo el espacio, recortando si es necesario */
    border-radius: 25px;
  overflow: hidden;
    margin-bottom: 8px;      /* Espacio pequeño abajo para separar texto */
    user-select: none;
    pointer-events: none;
}


.product-card h4 {
    margin: 0 0 6px 0;
    font-weight: 700;
    font-size: 18px;
    user-select: text;
}

.product-card p {
margin: 0px 0 7px 0;
    font-size: 14px;
    color: #666;
    user-select: text;

}

.product-card button {
    margin-top: auto;
    background-color: #007BFF;
    color: white;
    border: none;
    font-weight: 700;
    font-size: 14px;
    border-radius: 25px;
    padding: 10px 0;
    cursor: pointer;
    transition: background-color 0.3s;
}

.product-card button:hover {
    background-color: #0056b3;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.35);
    display: none;
    z-index: 99;
    backdrop-filter: blur(3px);
}

.popup-visible {
    display: block !important;
}

.cart-popup, .discount-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 22px;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    padding: 24px 28px;
    max-width: 380px;
    width: 90vw;

    /* ✅ Scroll consistente tipo popup horarios */
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    z-index: 100;
    display: none;
    color: black;
    user-select: text;
    box-sizing: border-box;
}
.detail-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 22px;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    padding: 24px 28px;
    max-width: 500px;          /* aumenté un poco para PC */
    width: 90vw;
    max-height: 90vh;          /* limita altura máxima a 90% viewport */
    overflow-y: auto;          /* activa scroll vertical si contenido muy largo */
    z-index: 100;
    display: none;
    color: black;
    user-select: text;
    box-sizing: border-box;
}

.popup-header {
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 16px;
    text-align: center;
    user-select: none;
}

.cart-popup ul, .discount-popup div.items-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 0;
    margin: 0 0 16px 0;
    list-style: none;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

#cartItems li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    gap: 8px;
    font-size: 15px;
}

#cartItems li span.text {
    flex: 1;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cartItems li span.price {
    width: 90px;
    text-align: right;
    font-weight: 700;
    color: #007BFF;
}

#cartItems li button {
    background: none;
    border: none;
    color: #d33;
    font-weight: 700;
    font-size: 20px;
    cursor: pointer;
    padding: 0 8px;
    user-select: none;
    border-radius: 12px;
    transition: background-color 0.2s;
}

#cartItems li button:hover {
    background-color: #d33a3a33;
}

#cartItems li .qty-controls {
    display: flex;
    gap: 6px;
    user-select: none;
}

#cartItems li .qty-controls button {
    font-size: 18px;
    color: #007BFF;
    font-weight: 700;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 6px;
    border-radius: 12px;
    transition: background-color 0.2s;
}

#cartItems li .qty-controls button:hover {
    background-color: #007BFF22;
}

.btn-primary {
    background-color: #007BFF;
    color: white;
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    user-select: none;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background: none;
    border: 1.8px solid #999;
    color: #666;
    border-radius: 16px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.3s, color 0.3s;
    user-select: none;
}

.btn-secondary:hover {
    border-color: #333;
    color: #333;
}

div.detail-popup img {
    max-width: 100%;
    height: auto;
    border-radius: 16px;
    margin-bottom: 12px;
    user-select: none;
    pointer-events: none;
}

.detail-popup .desc {
    font-size: 15px;
    margin-top: 8px;
    color: #444;
}

.detail-popup .ingredients {
    margin-top: 8px;
    font-style: italic;
    font-size: 13px;
    color: #666;
}

.discount-popup input[type="text"],
.discount-popup input[type="tel"] {
    width: 100%;
    font-size: 16px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1.5px solid #ccc;
    margin-bottom: 14px;
    font-weight: 600;
}

/* === MÓVILES === */
@media (max-width: 600px) {
    .top-header {
        gap: 8px;
    }

    .top-header > button {
        font-size: 14px;
        padding: 8px 12px;
    }

    .top-header > div {
        font-size: 16px;
    }

    #searchInput {
        font-size: 14px;
        padding: 8px 12px;
    }

    .sticky-controls {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .sticky-controls > div {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        gap: 10px;
    }

    .product-card {
        width: calc(50% - 10px);
        padding: 10px;
    }

    .product-card img {
        width: 100px;
        height: 100px;
    }

    .product-card h4 {
        font-size: 15px;
    }

    .product-card p {
        font-size: 13px;
    }

    .product-card button {
        font-size: 13px;
        padding: 8px 0;
    }

    .popup-header {
        font-size: 18px;
    }

    .btn-primary,
    .btn-secondary {
        font-size: 14px;
        padding: 10px 18px;
    }

    .cart-popup,
    .discount-popup,
    .detail-popup {
        width: 95vw;
        max-width: none;
        padding: 20px;
    }

    #cartItems li {
        font-size: 14px;
    }

    input[type="text"] {
        font-size: 14px;
        padding: 8px 12px;
    }
}
/* Forcing horizontal scroll ONLY on filter containers, without wrapping or shrinking */

.sticky-controls {
    /* deja tu estilo normal */
    flex-wrap: nowrap; /* NO wrap para que no se achique la página */
    overflow-x: hidden; /* oculta scroll de sticky-controls, solo los hijos lo tienen */
    gap: 0;
}

.sticky-controls > .filter-container {
    flex-grow: 0; /* evita que crezcan para no deformar */
    flex-shrink: 0; /* no se achican */
    display: flex;
    gap: 10px;
    overflow-x: auto; /* activa scroll horizontal */
    -webkit-overflow-scrolling: touch; /* suaviza scroll en iOS */
    padding-bottom: 8px; /* espacio para scroll */
    scrollbar-width: thin; /* Firefox */
}

/* Opcional: estilos para scrollbar en navegadores Webkit (Chrome, Safari) */
.sticky-controls > .filter-container::-webkit-scrollbar {
    height: 6px;
}
.sticky-controls > .filter-container::-webkit-scrollbar-track {
    background: transparent;
}
.sticky-controls > .filter-container::-webkit-scrollbar-thumb {
    background-color: #aaa;
    border-radius: 3px;
}

/* Que los botones dentro no se reduzcan ni se corten */
.sticky-controls > .filter-container button {
    white-space: nowrap;
    flex-shrink: 0;
}
#cartButton {
  position: relative;
  font-size: 18px;              /* Ícono más pequeño */
  cursor: pointer;
  background-color: white;
  border: 1px solid #ccc;       /* Borde más delgado */
  border-radius: 12px;
  padding: 6px 10px;            /* Menos padding para tamaño compacto */
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  user-select: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#cartButton:hover {
  border-color: #007BFF;
  box-shadow: 0 2px 6px #007BFF55;
}

.cart-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: red;
  color: white;
  font-weight: bold;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 12px;
  min-width: 18px;
  text-align: center;
  line-height: 1;
  pointer-events: none;
}
/* Opciones de envío dentro del popup */
.opcion-envio label,
.info-envio label {
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 500;
}

.opcion-envio input[type="radio"],
.info-envio input[type="radio"] {
  margin-right: 8px;
  accent-color: #5e9eff;
}

.info-envio {
  font-size: 14px;
  margin-top: 10px;
  color: #333;
}

#mapaContenedor {
  height: 200px;
  margin-top: 10px;
  display: none;
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: hidden;

  position: relative;
  isolation: isolate;          /* ✅ CLAVE iPhone: stacking aislado */
}

/* Botones sobre el mapa (delivery) */
#mapButtons {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 10px;
  z-index: 2000;
}
/* ===== FIX iPhone Leaflet: mapa abajo, overlays arriba ===== */
#mapaContenedor #mapa {
  position: relative;
  z-index: 1;
}

/* Leaflet panes abajo (iPhone bug compositor) */
#mapaContenedor .leaflet-pane,
#mapaContenedor .leaflet-tile-pane,
#mapaContenedor .leaflet-map-pane,
#mapaContenedor .leaflet-control-container {
  z-index: 2;
}

/* Overlays arriba siempre */
#mapButtons,
.map-msg,
#centerPinIcon {
  z-index: 5000;
  transform: translateZ(0);
}
.map-msg {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  z-index: 2000;
  display: none;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
  background: rgba(255,255,255,0.95);
  color: #111;
}

.map-msg[data-type='error']{
  background: rgba(255, 230, 230, 0.98);
  color: #8a0f0f;
}

.map-msg[data-type='ok']{
  background: rgba(231, 255, 236, 0.98);
  color: #0f5a22;
}

#btnUseMyLocation {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0,0,0,0.18);
}

#btnUseMyLocation {
  background: #ffffff;
  color: #111;
}


#btnUseMyLocation:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
#centerPinIcon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  font-size: 28px;
  pointer-events: none;
  z-index: 5000;               /* ✅ sube por encima de Leaflet en iPhone */
  -webkit-transform: translate(-50%, -100%) translateZ(0);
}
@media (max-width: 600px) {
  .product-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
    border-radius: 25px;
    margin: 0 auto 8px auto;
  }
}
#btnCloseDetail {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #333;
    user-select: none;
    padding: 0;
    line-height: 1;
    transition: color 0.3s;
}

#btnCloseDetail:hover {
    color: #007BFF;
}
.logo-container {
  display: flex;
  align-items: center;
  justify-content: center; /* Centrado */
  padding: 10px;
}

.logo-svg {
  height: 48px;
  width: auto;
  max-width: 100%;
}

/* Estilos para móviles */
@media (max-width: 600px) {
  .logo-svg {
    height: 36px; /* Más pequeño en móvil */
  }

  .logo-container {
    justify-content: center; /* Puedes cambiar a flex-start si lo quieres a la izquierda */
  }
}
#businessFilters button {
  background: #e4e6eb;
  border: 1.5px solid #cccccc00;          /* agrega borde igual a cajas productos */
  cursor: pointer;
  padding: 5px !important;
  border-radius: 25px;               /* bordes iguales a cajas productos */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  box-sizing: border-box;
  margin-left: 0px;                 /* separación izquierda para evitar corte de resplandor */
}

#businessFilters button:hover {
    transform: scale(1.05);
    border-color: #007BFF;
    box-shadow: 0 10px 15px #007BFF55;
}

#businessFilters button:first-child {
  margin-left: 0;
}

#businessFilters button img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  max-height: none !important;
  box-sizing: border-box !important;
}




#businessFilters button.text-button {
  width: 60px;
  height: 30px;           /* más alto, igual que categoría */
  padding: 12px 28px;     /* más padding para tamaño visual mayor */
  font-weight: 600;
  font-size: 15px;        /* letra más grande */
  background: #e4e6eb;
  border: 1.5px solid #cccccc00;
  border-radius: 15px;
  color: #333;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  align-self: center;
}

#businessFilters button.text-button:hover {
  border-color: #007BFF;
  box-shadow: 0 0 10px #007BFFaa;
  color: #007BFF;
}

#businessFilters button.text-button.active-filter {
  background-color: #007BFF;
  color: white;
  border-radius: 30px;
  border-color: #007BFF;
  box-shadow: 0 0 10px #007BFFaa;
  position: relative;
  z-index: 1;
}
.extra-categories-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    width: 90%;
    max-width: 280px;

    max-height: 80vh; /* altura responsive según pantalla */
    background: white;
    border-radius: 20px;

    overflow-y: auto;
    display: none;
    flex-direction: column;

    z-index: 9999;
    padding: 12px;

    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
}

/* Botones */
.extra-categories-popup button {
    margin: 4px 0;
    padding: 8px 12px;
    text-align: left;
    border: none;
    background: #f5f5f5;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.extra-categories-popup button:hover {
    background: #e0e0e0;
}

button.out-of-stock {
    background-color: #e74c3c; /* rojo */
    color: white;
    cursor: not-allowed;
    pointer-events: none;
}
/* Para que los saltos de línea en descripciones se respeten */
.product-card p,
.detail-popup .desc,
.detail-popup .ingredients {
    white-space: pre-wrap; /* respeta saltos de línea y espacios */
    word-wrap: break-word; /* permite cortar palabras largas si es necesario */
    overflow-wrap: break-word;
}

/* ===== AJUSTE SOLO PARA PC ===== */
@media (min-width: 1024px) {

  .cart-popup,
  .discount-popup {
    max-height: 85vh;
    overflow-y: auto;
  }

  #mapaContenedor {
    height: 260px;
  }

}
.wa-btn-danger{
  flex: 1;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  user-select:none;
}
.wa-btn-danger:hover{ background:#c0392b; }
/* Lupa al final del search (mantiene tu color actual) */
#searchInput{
  padding-right: 42px; /* espacio para la lupa */
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='11' cy='11' r='7' stroke='%23666666' stroke-width='2'/%3E%3Cpath d='M20 20l-3.5-3.5' stroke='%23666666' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px 18px;
}
/* === Categorías (título + botón) === */
.category-header{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  margin: 6px 0;
  justify-content: flex-start; /* 📱 móvil: izquierda */
}

.category-title{
  font-family: 'Lobster', 'Segoe UI', cursive;
  font-size: 30px;
  font-weight: 400;
  color: #007BFF;
  letter-spacing: -1;
  line-height: 1;
}

/* 💻 PC / tablets alargadas: centro (título + botón juntos) */
@media (min-width: 900px){
  .category-header{
    justify-content: center;   /* centra el bloque completo */
  }
}
