:root{
  --bg:#fff;
  --card:#f7f7f8;
  --accent:#0b6b2d;
  --muted:#666;
  --danger:#e53935;
}

*{box-sizing:border-box}

html,body,#app{
  height:100%;
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,"Helvetica Neue",Arial;
}

body{
  background:var(--bg);
  color:#111;
  -webkit-font-smoothing:antialiased;
  touch-action:manipulation;
}

/* espacio para topbar fija + barra inferior fija */
#app{
  min-height:100%;
  padding-top:56px;
  padding-bottom:96px;
}

/* Topbar siempre visible */
.topbar{
  height:56px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px;
  border-bottom:1px solid #eee;
  background:#fff;
  position:fixed;
  top:0;
  left:0;
  right:0;
  z-index:1000;
  opacity:1 !important;
  transform:none !important;
  visibility:visible !important;
  transition:none !important;
  -webkit-transform:none !important;
  will-change:auto;
}

.brand{
  font-weight:700;
  font-size:18px;
  color:var(--accent);
  padding:6px;
}

.search-wrap{flex:1}

#search{
  width:100%;
  padding:8px 10px;
  border-radius:8px;
  border:1px solid #eee;
}

.icon-btn{
  background:transparent;
  border:0;
  padding:8px;
  font-size:18px;
}

.badge{
  background:var(--accent);
  color:#fff;
  border-radius:999px;
  padding:2px 6px;
  margin-left:6px;
  font-size:12px;
}

.grid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:8px;
  padding:10px 10px 24px;
}

.card{
  background:var(--card);
  border-radius:10px;
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:160px;
}

.card img{
  width:100%;
  height:110px;
  object-fit:contain;
  border-radius:6px;
  background:#fff;
}

.title{
  font-size:13px;
  font-weight:600;
}

.price{
  color:var(--accent);
  font-weight:700;
}

.actions{
  display:flex;
  gap:6px;
  margin-top:auto;
}

.btn{
  flex:1;
  padding:8px 10px;
  border-radius:8px;
  border:0;
  font-weight:600;
}

.primary{
  background:var(--accent);
  color:#fff;
}

.secondary{
  background:#fff;
  border:1px solid #ddd;
}

.hidden{
  display:none !important;
  pointer-events:none !important;
}

/* Carrito */
.sheet{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  background:#fff;
  border-top-left-radius:12px;
  border-top-right-radius:12px;
  box-shadow:0 -8px 24px rgba(0,0,0,0.12);
  max-height:80%;
  display:flex;
  flex-direction:column;
  z-index:1500;
}

.sheet-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px;
  border-bottom:1px solid #eee;
}

.sheet-body{
  overflow:auto;
  padding:10px;
}

.sheet-footer{
  padding:10px;
  border-top:1px solid #eee;
}

.cart-item{
  display:flex;
  gap:10px;
  align-items:center;
  padding:8px;
  border-radius:8px;
  background:#fafafa;
  margin-bottom:8px;
}

.cart-item img{
  width:56px;
  height:56px;
  object-fit:contain;
  border-radius:6px;
}

.qty{
  display:flex;
  gap:6px;
  align-items:center;
}

.qty button{
  width:34px;
  height:34px;
  border-radius:8px;
  border:1px solid #ddd;
  background:#fff;
}

.total{
  font-weight:700;
  margin-bottom:8px;
}

.row{display:flex;gap:8px}

.toast{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom:100px;
  background:#111;
  color:#fff;
  padding:10px 12px;
  border-radius:8px;
  font-size:14px;
  z-index:2500;
}

/* Modal producto */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.45);
  display:flex;
  align-items:flex-end;
  justify-content:center;
  z-index:2000; /* por encima de bottom-nav */
  -webkit-overflow-scrolling:touch;
}

.modal .modal-content{
  background:#ffffff;
  position:relative;
  z-index:2001;
  width:100%;
  border-top-left-radius:12px;
  border-top-right-radius:12px;
  padding:18px;
  padding-bottom:110px; /* deja sitio para el final sin quedar tapado */
  max-height:calc(100vh - 80px);
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
}

.modal-close{
  position:absolute;
  right:12px;
  top:12px;
}

/* Detalle producto */
.pd-wrap{
  display:flex;
  flex-direction:column;
  gap:0;
  padding:8px 12px 24px;
}

.pd-image-wrap{
  display:flex;
  justify-content:center;
  align-items:center;
  padding:0 0 16px;
}

.pd-image{
  width:100%;
  max-width:420px;
  height:auto;
  object-fit:contain;
  border-radius:12px;
  background:#fff;
}

.pd-title{
  font-size:18px;
  margin:0 0 12px 0;
  color:var(--accent);
  font-weight:700;
  padding:0 4px;
}

.pd-description,
.product-description{
  font-size:14px;
  line-height:1.6;
  color:#555;
  margin-top:12px;
  margin-bottom:24px;
  padding:0 4px;
  max-height:none;
  overflow:visible;
}

.pd-label{
  font-size:16px;
  font-weight:700;
  color:#222;
  margin-top:20px;
  margin-bottom:10px;
  padding:0 4px;
  display:block;
}

.pd-select{
  width:100%;
  padding:14px;
  border-radius:12px;
  border:2px solid #e5e5e5;
  background:#ffffff;
  font-size:16px;
  box-shadow:0 3px 8px rgba(0,0,0,0.04);
  margin-bottom:8px;
  -webkit-appearance:none;
  appearance:none;
  outline:none;
  transition:border-color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
  background-image:linear-gradient(transparent, transparent), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 12px center;
  padding-right:40px;
}

.pd-select:focus{
  border-color:#1f7a37;
  box-shadow:0 6px 18px rgba(31,122,55,0.08);
  transform:translateY(-1px);
}

.variant-hint{
  font-size:13px;
  color:#666;
  margin-top:8px;
  margin-bottom:12px;
  padding-left:4px;
}

.pd-quantity{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  padding:0 4px;
  margin-bottom:16px;
}

.qty-control{
  display:flex;
  align-items:center;
  gap:12px;
  background:transparent;
}

.qty-btn{
  width:48px;
  height:48px;
  min-width:48px;
  min-height:48px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,0.08);
  background:#fff;
  font-size:20px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:transform 120ms ease, box-shadow 120ms ease;
}

.qty-btn:hover{
  transform:translateY(-2px);
  box-shadow:0 6px 14px rgba(0,0,0,0.06);
}

.qty-value{
  min-width:56px;
  text-align:center;
  font-size:18px;
  font-weight:600;
  color:#111;
}

.pd-add-btn{
  width:100%;
  height:58px;
  border-radius:14px;
  background:#1f8a43;
  color:#fff;
  border:0;
  font-size:18px;
  font-weight:600;
  margin-top:8px;
  margin-bottom:8px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
  padding:0 18px;
  box-shadow:0 8px 24px rgba(26,122,60,0.14);
  cursor:pointer;
}

.pd-add-btn[disabled]{
  opacity:0.6;
  cursor:not-allowed;
  filter:grayscale(0.03);
}

.modal .modal-content .pd-wrap{
  padding:8px 8px 24px;
}

/* Barra inferior */
.bottom-nav{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  height:68px;
  background:#ffffff;
  border-top:0;
  border-top-left-radius:16px;
  border-top-right-radius:16px;
  display:flex;
  justify-content:space-around;
  align-items:center;
  z-index:900; /* por debajo del modal, por encima del contenido */
  box-shadow:0 -6px 20px rgba(0,0,0,0.12);
  padding:8px 0;
}

.bottom-nav::before{
  content:"";
  position:absolute;
  left:0;
  right:0;
  top:0;
  height:4px;
  background:#000;
  border-top-left-radius:0;
  border-top-right-radius:0;
}

.nav-btn{
  background:transparent;
  border:0;
  padding:4px;
  font-weight:700;
  color:var(--muted);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  font-size:14px;
  cursor:pointer;
  text-align:center;
  height:100%;
}

.bottom-nav .nav-btn:nth-child(1)::before{
  content:"🏠";
  font-size:18px;
  display:block;
}

.bottom-nav .nav-btn:nth-child(2)::before{
  content:"🛒";
  font-size:18px;
  display:block;
}

.bottom-nav .nav-btn:nth-child(3)::before{
  content:"💬";
  font-size:18px;
  display:block;
}

.card-meta{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
}

.small{
  font-size:12px;
  color:var(--muted);
}

@media (min-width:600px){
  .grid{grid-template-columns:repeat(3,1fr)}
}

/* Paginación */
.pagination{
  display:flex;
  gap:10px;
  justify-content:center;
  align-items:center;
  padding:12px 10px 0;
  margin-top:10px;
  margin-bottom:0;
  padding-bottom:100px; /* suficiente para no quedar tapada por bottom-nav */
  z-index:90;
  position:relative;
  width:100%;
}

.pagination .page-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  background:#fff;
  border:1px solid #e6e6e6;
  color:#111;
  padding:10px 14px;
  border-radius:12px;
  font-weight:700;
  font-size:14px;
  box-shadow:0 6px 18px rgba(0,0,0,0.06);
  cursor:pointer;
}

.pagination .page-btn[disabled]{
  opacity:0.45;
  cursor:not-allowed;
  box-shadow:none;
}

.pagination .page-info{
  font-size:14px;
  color:#666;
  padding:0 8px;
}

/* Botones checkout */
.checkout-buttons{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:20px;
}

.pay-btn,
.whatsapp-btn{
  width:100%;
  min-height:56px;
  height:auto;
  font-size:18px;
  border:0;
  border-radius:12px;
  font-weight:600;
  cursor:pointer;
  padding:12px 16px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  box-shadow:0 6px 18px rgba(0,0,0,0.08);
  transition:background-color 120ms ease, transform 120ms ease;
}

.pay-btn{
  background:#1a7f37;
  color:#fff;
}

.pay-btn:hover{
  background:#16662d;
  transform:translateY(-1px);
}

.whatsapp-btn{
  background:#25D366;
  color:#fff;
}

.whatsapp-btn:hover{
  filter:brightness(0.97);
  transform:translateY(-1px);
}

.sheet-footer .row{display:block}
.sheet-footer .total{margin-bottom:0}