:root{
  --wine:#7B1E3B;
  --wine-600:#6a1933;
  --gold:#C9A227;
  --stone:#3A3A3A;
  --paper:#F8F6F4;

  --border:#eee;
  --muted:#666;
  --shadow: 0 10px 24px rgba(0,0,0,.08);
  --shadow-strong: 0 12px 30px rgba(0,0,0,.16);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,'Helvetica Neue',Arial,'Noto Sans',sans-serif;
  background:var(--paper);
  color:var(--stone);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

.container{max-width:1100px;margin:0 auto;padding:16px}

.header{
  display:flex;align-items:center;gap:12px;
  padding:12px 16px;background:#fff;
  border-bottom:1px solid var(--border);
  position:sticky;top:0;z-index:50
}

.logo{
  height:36px;width:auto;border-radius:8px;
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-weight:700
}

.h1{font-size:20px;margin:0}

.link{color:var(--wine);text-decoration:none}
.link:hover{opacity:.9;text-decoration:underline}

/* Card */
.card{
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}

/* Grid */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(230px,1fr));
  gap:14px
}

/* Badge */
.badge{
  display:inline-block;
  padding:3px 10px;
  border-radius:999px;
  font-size:12px;
  border:1px solid #e9e9e9;
  background:#fafafa
}

/* Buttons */
.btn{
  appearance:none;
  border:none;
  border-radius:12px;
  padding:10px 14px;
  font-weight:700;
  background:var(--wine);
  color:#fff;
  cursor:pointer;
  transition:transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.btn:hover{filter:brightness(1.03)}
.btn:active{transform:scale(.98)}
.btn:disabled{opacity:.6;cursor:not-allowed;transform:none}

.btn.secondary{
  background:#f1ecea;
  color:var(--wine-600);
  border:1px solid #eadfdd;
}
.btn.secondary:hover{filter:brightness(1.02)}

/* Inputs */
.input, select, input{
  width:100%;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid #ddd;
  background:#fff;
  outline:none;
  transition:border-color .12s ease, box-shadow .12s ease;
}
.input:focus, select:focus, input:focus{
  border-color: rgba(123,30,59,.45);
  box-shadow: 0 0 0 4px rgba(123,30,59,.12);
}

/* Layout helpers */
.row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
@media (max-width:720px){.row{grid-template-columns:1fr}}

.footer{padding:24px;text-align:center;color:var(--muted)}

/* Topbar + filterbar */
.topbar{
  position:sticky;top:0;
  background:#ffffffcc;
  backdrop-filter:saturate(1.2) blur(8px);
  border-bottom:1px solid var(--border);
  z-index:60
}
.filterbar{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:10px;
  padding:12px
}
@media (min-width:860px){.filterbar{grid-template-columns:repeat(5,1fr)}}

/* Product card */
.product{display:flex;flex-direction:column;gap:8px}
.product img{
  width:100%;
  height:160px;
  object-fit:contain;
  border-radius:12px;
  background:#f2f2f2;
  border:1px solid #eee;
}
.price{font-weight:800;color:var(--wine)}

/* Floating buttons */
.cartfab{
  position:fixed;
  bottom:20px;
  right:16px;
  border-radius:999px;
  padding:12px 16px;
  min-height:48px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--wine-600);
  color:#fff;
  font-weight:800;
  border:none;
  box-shadow:var(--shadow-strong);
  cursor:pointer;
  transition:transform .12s ease, filter .12s ease;
}

.cartfab:hover{filter:brightness(1.03)}
.cartfab:active{transform:scale(.96)}

.cart-badge{
  position:absolute;
  top:-6px;
  right:-6px;
  background:#FACF0A;
  color:#000;
  font-size:13px;
  font-weight:800;
  border-radius:50%;
  width:22px;
  height:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 0 3px rgba(0,0,0,0.3);
}

.whatsapp{
  position:fixed;
  bottom:20px;
  left:16px;
  border-radius:999px;
  padding:12px 16px;
  min-height:48px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#25D366;
  color:#fff;
  font-weight:800;
  border:none;
  box-shadow:var(--shadow-strong);
  cursor:pointer;
  transition:transform .12s ease, filter .12s ease;
  text-decoration:none;
}

.whatsapp:hover{filter:brightness(1.02)}
.whatsapp:active{transform:scale(.98)}

/* Toast */
.toast{
  position:fixed;
  bottom:20px;
  left:50%;
  transform:translateX(-50%);
  background:#111;
  color:#fff;
  padding:10px 14px;
  border-radius:12px;
  display:none;
  box-shadow: var(--shadow-strong);
  z-index:9999;
}
.show{display:block}

/* === MINI POPUP ADD-TO-CART === */
.add-popup{
  position:fixed;
  bottom:-120px;
  left:50%;
  transform:translateX(-50%);
  background:#fff;
  border:2px solid var(--wine-600);
  border-radius:14px;
  box-shadow: var(--shadow);
  padding:10px 16px;
  display:flex;
  align-items:center;
  gap:12px;
  min-width:260px;
  max-width:90%;
  z-index:9999;
  opacity:0;
  transition:all .35s ease;
}
.add-popup.show{bottom:25px;opacity:1}
.add-popup .popup-content{display:flex;align-items:center;gap:10px}
.add-popup .popup-img{
  width:42px;height:42px;
  border-radius:10px;
  border:1px solid #eee;
  object-fit:contain;
  background:#fafafa;
}

/* Modal */
.modal{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.55);
  z-index:1000;
  padding:16px
}
.modal.show{display:flex}
.modal-card{
  background:#fff;
  border-radius:18px;
  max-width:900px;
  width:100%;
  max-height:90vh;
  overflow:auto;
  position:relative;
  padding:12px;
  box-shadow: var(--shadow-strong);
}
.modal-close{
  position:absolute;
  top:10px;
  right:10px;
  border:none;
  background:#fff;
  border-radius:999px;
  width:38px;
  height:38px;
  box-shadow:0 2px 10px rgba(0,0,0,.18);
  cursor:pointer;
}
.modal-body img,
.modal-body iframe{
  width:100%;
  height:70vh;
  border:none;
  border-radius:12px;
  object-fit:contain;
  background:#f5f5f5
}

/* Back link */
.back-to-cart{
  margin-top:15px;
  background:transparent;
  border:none;
  color:#555;
  font-size:14px;
  cursor:pointer;
  text-decoration:underline;
}
.back-to-cart:hover{color:#000}

/* =========================
   FILTERS TOP SHEET (PWA mobile)
   ========================= */

.filterbar-compact{
  display:grid;
  grid-template-columns: 1fr auto;
  gap:10px;
  align-items:center;
  padding:10px 12px;
}

.filters-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease;
  z-index:999;
}

.filters-sheet{
  position:fixed;
  left:0; right:0;
  top:0;
  transform: translateY(-110%);
  transition: transform .22s ease;
  z-index:1000;

  background:#fff;
  border-bottom-left-radius:18px;
  border-bottom-right-radius:18px;
  box-shadow: 0 14px 30px rgba(0,0,0,.18);

  padding-top: calc(10px + env(safe-area-inset-top));
  padding-bottom: 12px;
  max-height: calc(85vh);
  display:flex;
  flex-direction:column;
}

.filters-sheet__handle{
  width:46px;
  height:5px;
  border-radius:999px;
  background:#ddd;
  margin:10px auto 6px;
}

.filters-sheet__header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  padding:10px 14px 8px;
  border-bottom:1px solid #eee;
}

.filters-sheet__title{
  font-weight:900;
  color: var(--wine-600);
  letter-spacing:-0.2px;
}

.filters-sheet__subtitle{
  font-size:13px;
  color:#777;
  margin-top:2px;
}

.filters-sheet__close{
  border:none;
  background:#f4efee;
  color: var(--wine-600);
  border-radius:999px;
  width:40px;
  height:40px;
  min-height:40px;
  cursor:pointer;
  font-weight:900;
}

.filters-sheet__body{
  padding:12px 14px;
  overflow:auto;
}

.filters-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
}

.filters-field{display:block}
.filters-label{
  display:block;
  font-size:12px;
  font-weight:800;
  color:#555;
  margin:0 0 6px 2px;
}

.filters-sheet__footer{
  padding:10px 14px 12px;
  border-top:1px solid #eee;
  display:flex;
  gap:10px;
}

.filters-sheet__footer .btn{
  flex:1;
}

/* OPEN STATE */
body.filters-open .filters-overlay{
  opacity:1;
  pointer-events:auto;
}
body.filters-open .filters-sheet{
  transform: translateY(0);
}

/* Desktop: sheet non serve */
@media (min-width: 900px){
  #openFiltersBtn{display:none;}
  .filters-overlay, .filters-sheet{display:none;}
  .filterbar-compact{grid-template-columns: 1fr;}
}

/* Layout azioni prodotto */
.buy-row{
  margin-top:10px;
}

.buy-btn{
  width:100%;
  font-size:15px;
  font-weight:900;
  border-radius:14px;
}

.extra-row{
  display:flex;
  gap:8px;
  margin-top:8px;
}

.extra-row .btn{
  flex:1;
  text-align:center;
  padding:8px 6px;
  font-size:12px;
  border-radius:12px;
}

/* === BOTTONI PRODOTTO === */

.product-actions{
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

/* Acquista ora full width */
.product-actions > .btn{
  width: 100%;
}

/* Riga secondaria */
.product-secondary{
  display: flex;
  gap: 8px;
}

.product-secondary .btn{
  flex: 1;
}