:root{
  --green: #4CAF50;
  --mint: #A8E6A3;
  --white: #FFFFFF;
  --gray-100:#F2F2F2;
  --gray-800:#4D4D4D;

  --bg: var(--gray-100);
  --text: var(--gray-800);
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0,0,0,.12);

  /* capas */
  --z-fabs: 1200;
  --z-modal-overlay: 2000;
  --z-modal: 2100;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
  color:var(--text);
  background:var(--bg);
}

/* Top bar fija */
.topbar{
  position: fixed;
  top: 0; left: 0; right: 0;
  width: 100%;
  z-index: 100;
  background: linear-gradient(180deg, var(--white), #ffffffd9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #e9e9e9;
}
body.has-fixed-topbar{
  padding-top: var(--topbar-h, 120px);
}

.filters{
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  gap: 10px;
}
.filters .row{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}
.field{
  display:flex;
  flex-direction: column;
  gap:6px;
}
.field > span, .radios legend{
  font-size:.9rem;
  color:#555;
}
.field select,
.field input[type="search"],
.field textarea{
  border:1px solid #ddd;
  padding:12px 12px;
  border-radius: 12px;
  outline: none;
  background:#fff;
}
.field input[type="search"]{ width:100%; }
.field-search{ grid-column: 1 / -1; }

.container{
  max-width:1100px;
  margin: 18px auto 80px;
  padding: 0 16px;
}

/* Grid de productos */
.grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap:16px;
}
.card{
  background:#fff;
  border-radius: var(--radius);
  padding:12px;
  display:flex;
  gap:12px;
  box-shadow: var(--shadow);
}
.card img{
  width: 110px; height: 110px; object-fit: cover;
  border-radius: 12px; background: #eee;
}
.card .info{
  display:flex; flex-direction: column; justify-content: space-between;
  flex:1; min-width: 0;
}
.card h3{ margin:0; font-size:1rem; line-height:1.2; }
.price{ margin:6px 0; font-weight: 700; color: var(--green); }

/* Botones */
.btn{
  appearance: none; border: none;
  padding: 10px 14px; border-radius: 999px;
  cursor: pointer; font-weight: 600;
  transition: transform .05s ease, box-shadow .2s ease, background .2s ease;
}
.btn:active{ transform: translateY(1px); }
.btn.primary{ background: var(--green); color: #fff; box-shadow: 0 6px 14px rgba(76,175,80,.35); }
.btn.primary:disabled{ opacity:.5; cursor:not-allowed; box-shadow:none; }
.btn.ghost{ background:#fff; color: var(--text); border:1px solid #ddd; }
.btn.ghost:disabled{ opacity:.5; cursor:not-allowed; box-shadow:none; }
.btn.add{ background: linear-gradient(180deg, var(--green), #3b9b41); color:#fff; }

/* FAB carrito */
.fab{
  position: fixed; right: 18px; bottom: 18px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); color:#fff; border:none; font-size: 20px;
  box-shadow: var(--shadow); cursor:pointer; z-index: 100;
}
.badge{
  position:absolute; top:-6px; right:-6px;
  min-width: 22px; height:22px; padding:0 6px; border-radius:11px;
  background:#e53935; color:#fff; font-size:12px;
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* Modal base */
.modal{ position: fixed; inset:0; display:none; z-index: var(--z-modal); }
.modal.open{ display:block; }
.modal__overlay{ position:absolute; inset:0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); z-index: var(--z-modal-overlay); }
.modal__content{
  position:absolute; inset:auto 0 0 0; margin:auto;
  background:#fff; border-radius: 16px 16px 0 0;
  padding: 16px; max-width: 720px; width: 100%;
  box-shadow: var(--shadow); animation: slideUp .2s ease-out; z-index: var(--z-modal);
}
@keyframes slideUp{ from{ transform: translateY(10px); opacity:.9; } to{ transform: translateY(0); opacity:1; } }
@media (min-width: 780px){
  .modal__content{ inset: 0; height: fit-content; max-height: 82vh; border-radius: 20px; overflow: auto; }
}
.modal__close{
  position:absolute; right:10px; top:10px;
  border:none; background:#fff; width:36px; height:36px; border-radius:50%;
  cursor:pointer; box-shadow: var(--shadow);
}

/* Carrito */
.cart-list{ list-style:none; margin:0; padding:0; display:grid; gap:12px; }
.cart-item{ border:1px solid #eee; border-radius: 12px; padding: 12px; background: #fff; }
.cart-item .row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.cart-item .name{ font-weight:600; }
.cart-item .unit{ color:#666; }
.qty{ display:flex; align-items:center; gap:10px; }
.chip{ border:1px solid #ddd; background:#fff; padding:6px 10px; border-radius:999px; cursor: pointer; }
.line-total{ font-weight:700; color:var(--green); }
.cart-total{ margin-top: 14px; border-top:1px solid #eee; padding-top: 12px; }
.sum-row{ display:flex; align-items:center; justify-content:space-between; font-size:1.05rem; }
.note{ margin:.35rem 0 0; font-size:.85rem; color:#cf7500; }

/* Formulario checkout */
.form{ display:grid; gap:14px; margin-top: 8px; }
.radios{
  display: flex; flex-direction: row; align-items: center; gap: 20px; flex-wrap: nowrap;
  border: none; padding: 0; margin: 0;
}
.radios label{ display: inline-flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
textarea{ resize: vertical; }

/* Títulos */
h2{ margin: 8px 0 12px; }

/* Focus */
select:focus, input:focus, textarea:focus, .btn:focus{
  outline: 3px solid var(--mint);
  outline-offset: 2px;
}

/* Utilidad */
.hidden{ display: none !important; }

.empty{
  max-width: 1100px; margin: 24px auto; padding: 18px 16px;
  color: #555; background: #fff; border: 1px dashed #ddd; border-radius: 12px; text-align: center;
  box-shadow: var(--shadow);
}

.qty-control{ display:flex; align-items:center; gap:8px; }
.qty-control button{
  border: 1px solid #ddd; background:#fff; padding: 6px 10px; border-radius: 999px;
  cursor: pointer; font-weight: bold; font-size: 1rem;
}
.qty-control span{ min-width: 20px; text-align: center; font-weight: 600; }

/* === SOCIAL FABs (rail izquierda) === */
.fab-btn{
  --w-collapsed: 44px; --w-expanded: 280px;
  width: var(--w-collapsed); height: 44px;
  display:flex; align-items:center; gap:10px; padding:0; border:none;
  background:#1f2937; color:#e5e7eb; cursor:pointer;
  box-shadow: 0 6px 14px rgba(2,6,23,.15);
  border-radius: 8px; overflow:hidden;
  transition: width .22s ease, background .18s ease, border-radius .18s ease, box-shadow .2s ease;
}
.fab-icon-wrap{ width:44px; height:44px; display:grid; place-items:center; flex:0 0 auto; }
.fab-icon{ width:26px; height:26px; fill: currentColor; }
.fab-text{ display:flex; flex-direction:column; justify-content:center; min-width:0; opacity:0; transform: translateX(-6px); transition: opacity .18s ease, transform .18s ease; }
.fab.open .fab-btn{ width: var(--w-expanded); border-radius: 8px 9999px 9999px 8px; }
.fab[data-net="fb"].open .fab-btn{ background:#1877F2; color:#fff; }
.fab[data-net="wa"].open .fab-btn{ background:#25D366; color:#0b301c; }
.fab.open .fab-text{ opacity:1; transform:translateX(0); }
.fab-btn:hover{ box-shadow: 0 8px 18px rgba(2,6,23,.18); }

@media (max-width: 768px){
  .social-fabs{ left: 10px !important; top: 18vh !important; gap: 10px; }
  .fab-btn{ --w-expanded: 240px; }
}

.social-fabs{
  position: fixed !important; left: 0 !important; top: 30vh !important;
  z-index: var(--z-fabs) !important; display:flex; flex-direction:column; gap:12px;
  margin-left:0 !important; padding-left:0 !important;
}
.social-fabs .fab{
  position: static !important; width:auto !important; height:auto !important;
  background:transparent !important; border-radius:0 !important; box-shadow:none !important; overflow:visible !important;
  right:auto !important; left:auto !important; top:auto !important; bottom:auto !important;
  display:flex !important; align-items:center;
}
.social-fabs .fab, .social-fabs .fab-btn{ margin-left:0 !important; }
.social-fabs .fab-btn{ border-radius:0 8px 8px 0 !important; opacity:.5; transition: opacity .18s ease, box-shadow .2s ease; }
.social-fabs .fab.open .fab-btn{ border-radius:0 9999px 9999px 0 !important; opacity:1; }
.social-fabs .fab-btn:focus-visible{ outline:2px solid rgba(59,130,246,.6); outline-offset:2px; }

/* Overlay servicio OFF */
.service-overlay{
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15,23,42,.92); color:#e5e7eb;
  display:grid; place-items:center; padding:24px;
}
.service-card{
  max-width: 860px; width: 100%;
  background: rgba(2,6,23,.35); backdrop-filter: blur(4px);
  border: 1px solid rgba(148,163,184,.25); border-radius: 18px;
  padding: 28px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.service-card h1{ font-size: clamp(22px, 4vw, 36px); margin: 0 0 8px; }
.service-card p{ font-size: clamp(15px, 2.2vw, 18px); opacity: .95; }
.service-card img{
  max-width: 220px; max-height: 220px; object-fit: cover;
  border-radius: 16px; margin: 14px auto 6px; display:block;
  box-shadow: 0 0 0 1px rgba(226,232,240,.25) inset;
}
body.service-blocked{ overflow: hidden; }

/* Botón del carrito colores */
#btnCart{ background:#22c55e; color:#fff; }
#btnCart svg, #btnCart svg *{ fill: currentColor !important; stroke: currentColor !important; }
#btnCart img{ filter: brightness(0) invert(1) !important; }
#btnCart svg{ width:22px; height:22px; }

/* Carrito: scroll cuando hay muchos items */
#cartList{ margin:0; padding:0; list-style:none; }
#cartList.scroll{ max-height:48vh; overflow-y:auto; padding-right:.25rem; overscroll-behavior:contain; }
#cartList.scroll::-webkit-scrollbar{ width:8px; }
#cartList.scroll::-webkit-scrollbar-track{ background: rgba(0,0,0,.06); border-radius:8px; }
#cartList.scroll::-webkit-scrollbar-thumb{ background: rgba(0,0,0,.18); border-radius:8px; }
#cartList.scroll::-webkit-scrollbar-thumb:hover{ background: rgba(0,0,0,.28); }

/* Campo efectivo */
#cashField{ position: relative; }
.cash-bubble{
  position:absolute; left:0; top:calc(100% + 6px);
  background:#FDE68A; border:1px solid #F59E0B; color:#111827;
  padding:6px 10px; border-radius:10px; font-size:.9rem; box-shadow:0 6px 18px rgba(0,0,0,.12);
  z-index:60; max-width:320px;
}
.cash-bubble::before{
  content:""; position:absolute; left:16px; top:-6px;
  border-width:6px; border-style:solid; border-color:transparent transparent #F59E0B transparent;
}
.cash-bubble::after{
  content:""; position:absolute; left:16px; top:-5px;
  border-width:6px; border-style:solid; border-color:transparent transparent #FDE68A transparent;
}
#cashField input:invalid{ border-color:#e53e3e; box-shadow:0 0 0 2px rgba(229,62,62,.12); }

/* === Free Shipping Toast === */
.fs-pill{
  position: fixed; right: 0; top: 30%;
  transform: translateY(-50%) translateX(24px);
  transform-origin: right center;
  background:#111827; color:#fff; padding:10px 14px;
  border-radius: 999px 0 0 999px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  max-width: min(92vw, 520px); width:max-content;
  display:grid; gap:8px; justify-items:center;
  opacity:0; clip-path: inset(0 0 0 100%);
  transition: opacity .25s ease, transform .25s ease, clip-path .45s cubic-bezier(.22,.61,.36,1);
  z-index: 4000; pointer-events:none;
}
.fs-pill.show{ opacity:1; transform: translateY(-50%) translateX(0); clip-path: inset(0 0 0 0); }
.fs-pill.hidden{ display:none; }
.fs-msg{ font-size:.95rem; text-align:center; line-height:1.25; }
.fs-progress{ width:100%; height:8px; background:rgba(255,255,255,.15); border-radius:8px 0 0 8px; overflow:hidden; }
.fs-bar{ height:100%; width:0%; background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e); transition: width .35s ease; box-shadow: inset 0 0 6px rgba(255,255,255,.25); }
.fs-pill.is-red .fs-msg{ color:#fee2e2; }
.fs-pill.is-amber .fs-msg{ color:#ffedd5; }
.fs-pill.is-green .fs-msg{ color:#dcfce7; }
@media (max-width: 480px){ .fs-msg{ font-size:.9rem; } }

/* Estado no disponible */
.btn.add.unavailable{ background:#f59e0b; color:#111827; cursor:not-allowed; box-shadow:none; opacity:.95; }
.card.is-unavailable .price{ opacity:.75; }
.btn.add.unavailable:focus{ outline: 2px dashed rgba(245,158,11,.6); outline-offset: 2px; }

/* ======== FAVORITOS (Carrusel) — centrado real ======== */
.favs{
  max-width:1100px; margin:0 auto; padding:8px 16px 6px; border-top:1px solid #e9e9e9; position:relative;
}
.favs.hidden{ display:none; }

.favs-head{ display:flex; align-items:center; justify-content:space-between; margin:2px 0 8px; }
.favs-title{ margin:0; font-size:1rem; font-weight:700; color:#111827; }
.favs-actions{ display:flex; gap:8px; align-items:center; }
/* Si JS pone hidden en una flecha, que desaparezca de verdad */
.favs-nav[hidden]{ display:none !important; }
.favs-nav{ width:34px; height:34px; border-radius:999px; border:1px solid #ddd; background:#fff; cursor:pointer; }
.btn.small{ padding:6px 10px; font-size:.9rem; }

/* Viewport */
.favs-viewport{ position:relative; overflow:hidden; }

/* Track con slide variable y padding para centrar 1.º/último */
.favs-track{
  /* ancho de cada slide (móvil: ~2 por viewport) */
  --slide: clamp(200px, 42vw, 240px);
  display:flex; gap:12px;
  overflow-x:auto; -webkit-overflow-scrolling:touch;
  scroll-snap-type: x mandatory; scroll-behavior: smooth;
  padding-block: 4px 16px;
  /* centrar extremos: medio de viewport - medio del slide */
  padding-inline: max(12px, calc(50% - var(--slide) / 2));
  scroll-padding-inline: calc(50% - var(--slide) / 2);
}
/* Oculta el scroll en todos los navegadores */
.favs-track{
  scrollbar-width: none;           /* Firefox */
}
.favs-track::-webkit-scrollbar{
  display: none;                   /* WebKit */
}

/* Mini-card */
.fav-card{
  flex: 0 0 var(--slide);
  scroll-snap-align: center;            /* ❤️ centra cada item */
  background:#fff; border:1px solid #e5e7eb; border-radius:14px;
  padding:10px; box-shadow: var(--shadow);
  display:grid; grid-template-columns: 84px 1fr; gap:10px; align-items:center;
}
.fav-card .media{
  position:relative; width:84px; height:84px; border-radius:10px; overflow:hidden; background:#eee; flex:0 0 84px;
}
.fav-card .media img{ width:100%; height:100%; object-fit:cover; display:block; }
.fav-card .fav-heart{
  position:absolute; left:6px; bottom:6px; width:28px; height:28px; border:none; border-radius:999px;
  background:rgba(255,255,255,.92); backdrop-filter: blur(4px); box-shadow:0 4px 12px rgba(0,0,0,.18);
  display:grid; place-items:center; cursor:pointer; transition: transform .12s ease, background .2s ease;
}
.fav-card .fav-heart:active{ transform: translateY(1px); }
.fav-card .fav-heart svg{ width:16px; height:16px; }
.fav-card .fav-heart .icon-fill{ display:none; }
.fav-card .fav-heart.is-fav .icon-stroke{ display:none; }
.fav-card .fav-heart.is-fav .icon-fill{ display:block; }

.fav-card .meta{ min-width:0; display:grid; gap:6px; }
.fav-card .meta h4{ margin:0; font-size:.95rem; line-height:1.15; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.fav-card .price{ margin:0; color:#16a34a; font-weight:700; }
.fav-card .btn.add{ width:100%; padding:8px 10px; border-radius:999px; }

/* Dots */
.favs-dots{
  pointer-events:none;
  position:absolute; left:50%; bottom:4px; transform:translateX(-50%);
  display:grid; grid-auto-flow:column; gap:8px;
}
.favs-dot{ width:8px; height:8px; border-radius:999px; background:#d1d5db; }
.favs-dot.is-active{ background:#6366f1; }

/* Corazón en tarjetas del grid normal */
.card .media{ position:relative; width:110px; height:110px; flex:0 0 110px; border-radius:12px; overflow:hidden; background:#eee; }
.card .media img{ width:100%; height:100%; object-fit:cover; display:block; }
.card .media .fav-heart{
  position:absolute; left:8px; bottom:8px; width:34px; height:34px;
  display:grid; place-items:center; border:nonfve; border-radius:999px;
  background:rgba(255,255,255,.92); box-shadow:0 6px 16px rgba(0,0,0,.18);
}
.card .media .fav-heart svg{ width:18px; height:18px; }
.card .media .fav-heart .icon-fill{ display:none; }
.card .media .fav-heart.is-fav .icon-stroke{ display:none; }
.card .media .fav-heart.is-fav .icon-fill{ display:block; }

/* Breakpoints: más tarjetas visibles en pantallas grandes */
@media (min-width: 640px){
  .favs-track{ --slide: clamp(210px, 36vw, 260px); }
}
@media (min-width: 900px){
  .favs-track{ --slide: clamp(220px, 28vw, 280px); }
}
@media (min-width: 1200px){
  .favs-track{ --slide: clamp(230px, 22vw, 300px); }
}
/* ======== FAVORITOS: Modal "Ver todos" ======== */
#modalFavs .modal__overlay{
  background: rgba(0,0,0,.45);
}

/* En escritorio: centrado, tamaño contenido y scroll interno */
@media (min-width: 780px){
  #modalFavs .modal__content{
    inset: 0;                      /* centrado */
    margin: auto;
    width: min(92vw, 900px);
    max-height: 85vh;              /* no tapa toda la pantalla */
    border-radius: 20px;
    overflow: auto;                /* scroll dentro del modal */
  }
}

/* Contenedor de tarjetas dentro del modal */
#favsModalList{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 6px;
}

/* Tarjeta dentro del modal */
.favs-modal-card{
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #eee;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.05);
}
.favs-modal-card img{
  width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: #eee;
}
.favs-modal-card .meta h4{
  margin: 0 0 4px; font-size: .98rem; line-height: 1.15;
}
.favs-modal-card .p{
  margin: 0; color: #16a34a; font-weight: 700;
}
.favs-modal-card .actions{
  grid-column: 1 / -1;
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px;
}

/* Botón "Quitar" con estilo de advertencia ligera */
.btn.btn-remove{
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.btn.btn-remove:hover{
  filter: brightness(.97);
}
/* ======== FAVORITOS: control de cantidad compacto en el rail ======== */
.fav-qty{
  display: inline-flex;
  align-items: center;
  gap: 6px;                 /* antes 8px */
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 4px 8px;         /* antes 6px 10px */
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(0,0,0,.05);
  max-width: 100%;
}
.fav-qty .qminus,
.fav-qty .qplus{
  appearance: none; border: none; background: #fff;
  width: 24px; height: 24px;     /* antes 28x28 */
  border-radius: 999px;
  display: grid; place-items: center;
  cursor: pointer;
  font-weight: 700; font-size: 14px; line-height: 1; /* más compacto */
  border: 1px solid #e5e7eb;
}
.fav-qty .qminus:active,
.fav-qty .qplus:active{ transform: translateY(1px); }
.fav-qty .qcount{
  min-width: 20px;              /* antes 22px */
  text-align: center; font-weight: 700;
  font-size: 14px;
}
/* Lista con scroll si hay muchos favoritos */
#favsModalList.scroll{
  max-height: 60vh;           /* ajustable */
  overflow-y: auto;
  padding-right: 6px;
}
#favsModalList.scroll::-webkit-scrollbar{ width: 8px; }
#favsModalList.scroll::-webkit-scrollbar-thumb{
  background: rgba(0,0,0,.15); border-radius: 999px;
}

/* En móviles, un poco más alto (para 3-4 tarjetas visibles) */
@media (max-width: 380px){
  .fav-qty{ gap: 4px; padding: 3px 6px; }
  .fav-qty .qminus, .fav-qty .qplus{ width: 22px; height: 22px; font-size: 13px; }
  .fav-qty .qcount{ min-width: 18px; font-size: 13px; }
}
/* En tablets */
@media (min-width: 481px) and (max-width: 779px){
  #favsModalList.scroll{ max-height: 68vh; }
}
.fab-title{
  text-decoration: none;
  color: #FFF;
}