/* ============================================================
   Vincent Rewards — Brand stylesheet
   Premium · elegante · italiano
   Palette: Blu Fjord, Oro Premium, Marrone Cioccolato,
            Avorio Caldo, Beige Premium, Grigio Scuro
   ============================================================ */

:root {
  --fjord:  #355C6E;   /* istituzionale: header, pulsanti, icone */
  --fjord-dark: #2a4a59;
  --gold:   #C9A227;   /* premi, VIP, badge, livelli */
  --choco:  #4A3428;   /* premium, richiami al gelato artigianale */
  --ivory:  #F5F0E6;   /* sfondo principale */
  --beige:  #DCCDB8;   /* secondario, bordi */
  --ink:    #2E2E2E;   /* testo */
  --muted-c:#7a7163;

  /* Livelli fedeltà */
  --tier-standard:#9a958c;
  --tier-silver:#C0C0C0;
  --tier-gold:#C9A227;
  --tier-vip:#355C6E;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(53, 92, 110, 0.12);
  --shadow-sm: 0 4px 14px rgba(53, 92, 110, 0.08);
  --font: "Avenir Next", "Montserrat", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--ivory);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: "Montserrat", var(--font); letter-spacing: 0.01em; }

a { color: var(--fjord); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout: pagine centrate (cliente) ---------- */
.hero {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 2rem);
}

.card {
  background: #fff;
  border: 1px solid var(--beige);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 5vw, 2.5rem) clamp(1.2rem, 5vw, 2rem);
  text-align: center;
  max-width: 460px;
  width: 100%;
}
.card h2 { color: var(--choco); margin: 0 0 0.4rem; font-size: 1.15rem; }

.logo {
  width: 64px; height: 64px; margin: 0 auto 0.6rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--fjord); color: var(--gold);
  border-radius: 18px; font-family: Georgia, serif; font-weight: 700;
  border: 2px solid var(--gold);
  font-size: 0;                 /* nasconde l'emoji legacy (nodo di testo) */
}
.logo::before { content: "V"; font-size: 2rem; }

h1 { margin: 0.4rem 0 0.8rem; color: var(--fjord); font-size: clamp(1.3rem, 5vw, 1.7rem); }

.status { font-size: 1.05rem; font-weight: 600; margin: 0.5rem 0; color: var(--choco); }
.muted { color: var(--muted-c); font-size: 0.9rem; margin: 0.5rem 0 0; }

.code {
  font-size: clamp(1.4rem, 6vw, 1.7rem); font-weight: 700; letter-spacing: 3px;
  color: var(--fjord); margin: 0.8rem 0;
}

.qr { display: block; margin: 0.5rem auto; border-radius: 12px; max-width: 100%; height: auto; }

.balance { font-size: 1.2rem; margin-top: 0.6rem; }
.balance strong { color: var(--gold); }

.link-box {
  margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem;
  align-items: center; justify-content: center;
}
.link-box input {
  flex: 1; min-width: 160px; padding: 0.55rem 0.65rem; border: 1px solid var(--beige);
  border-radius: 8px; font-size: 16px; color: var(--muted-c); background: var(--ivory);
}

/* ---------- Livelli fedeltà ---------- */
.tier-badge {
  display: inline-block; padding: 0.22rem 0.7rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.tier-standard { background: #e9e5dd; color: var(--tier-standard); }
.tier-silver   { background: var(--tier-silver); color: #2E2E2E; }
.tier-gold     { background: var(--tier-gold); color: #3a2f0c; }
.tier-vip      { background: var(--tier-vip); color: var(--gold); border: 1px solid var(--gold); }

/* ---------- Form ---------- */
.form-card { max-width: 480px; text-align: left; }
.form { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1rem; }
.form label { display: flex; flex-direction: column; font-size: 0.9rem; gap: 0.3rem; color: var(--choco); }

.form input, .form select, .form textarea {
  padding: 0.65rem 0.7rem; border: 1px solid var(--beige); border-radius: 10px;
  font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--fjord); box-shadow: 0 0 0 3px rgba(53,92,110,0.12);
}

.form .check { flex-direction: row; align-items: flex-start; gap: 0.5rem; font-size: 0.85rem; }
.form .check input { width: auto; margin-top: 0.2rem; }

.fieldset { border: 1px solid var(--beige); border-radius: 12px; padding: 0.8rem 1rem; }
.fieldset legend { font-size: 0.85rem; color: var(--muted-c); padding: 0 0.4rem; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-bottom: 0.6rem; }
.allergens { color: var(--choco); font-weight: 600; }

button, .form button, button[type="submit"] {
  margin-top: 0.2rem; padding: 0.8rem 1.1rem; background: var(--fjord); color: #fff;
  border: none; border-radius: 12px; font-size: 1rem; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background 0.15s ease;
}
button:hover, button[type="submit"]:hover { background: var(--fjord-dark); }

.errors {
  background: #f6e7e3; color: #8c3b2e; border-radius: 10px;
  padding: 0.7rem 1rem 0.7rem 1.6rem; margin: 0.8rem 0 0; font-size: 0.9rem;
}

.notice { padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.9rem; }
.notice.ok  { background: #f3ecd9; color: var(--choco); border: 1px solid var(--gold); }
.notice.err { background: #f6e7e3; color: #8c3b2e; }

/* ---------- Link punti vendita (home) ---------- */
.store-links { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.6rem; }
.store-link {
  display: block; padding: 0.8rem 1rem; background: var(--fjord); color: #fff;
  border-radius: 12px; text-decoration: none; font-weight: 600;
}
.store-link:hover { background: var(--fjord-dark); text-decoration: none; }

/* ---------- Promozioni / prodotti (area cliente) ---------- */
.promo-list, .product-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.6rem; text-align: left; }
.promo-item, .product-item { background: var(--ivory); border: 1px solid var(--beige); border-radius: 12px; padding: 0.7rem 0.9rem; }
.promo-item strong, .product-item strong { color: var(--fjord); }
.product-item .price { float: right; font-weight: 700; color: var(--gold); }
.promo-item .media, .product-item .media {
  display: block; width: 100%; max-height: 180px; object-fit: cover;
  border-radius: 10px; margin-bottom: 0.5rem;
}
.promo-item a, .product-item a { display: inline-block; margin-top: 0.4rem; font-weight: 600; }

.thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 8px; vertical-align: middle; margin-right: 0.5rem; }

/* ============================================================
   Area operatore / admin
   ============================================================ */
.page { max-width: 960px; margin: 0 auto; padding: clamp(0.8rem, 3vw, 1.2rem); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  padding: 0.6rem 0.2rem 0.9rem; font-size: 0.9rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--beige); margin-bottom: 1rem;
}
.topbar strong { color: var(--fjord); }

.nav { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.nav a { color: var(--fjord); font-weight: 600; }

.link-btn { background: none; color: var(--fjord); border: none; cursor: pointer; font: inherit; padding: 0; margin: 0; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger, .danger { color: #9b4722; }

.panel {
  background: #fff; border: 1px solid var(--beige); border-radius: 14px;
  padding: clamp(1rem, 4vw, 1.4rem); margin-bottom: 1rem; box-shadow: var(--shadow-sm);
}
.panel h1 { margin-top: 0; }
.panel h2 { font-size: 1.1rem; color: var(--choco); margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.panel-head h1 { margin: 0; }

.search { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search input {
  flex: 1; min-width: 180px; padding: 0.65rem 0.7rem; border: 1px solid var(--beige);
  border-radius: 10px; font-size: 16px;
}
.btn-scan {
  display: inline-flex; align-items: center; padding: 0.65rem 0.9rem; background: #fff;
  color: var(--fjord); border: 1px solid var(--fjord); border-radius: 10px;
  text-decoration: none; font-weight: 600; white-space: nowrap;
}
.btn-scan:hover { background: var(--ivory); text-decoration: none; }

.btn-sm {
  padding: 0.5rem 0.85rem; background: var(--fjord); color: #fff; border: none;
  border-radius: 10px; text-decoration: none; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.btn-sm:hover { background: var(--fjord-dark); text-decoration: none; }
.btn-danger {
  padding: 0.5rem 0.85rem; background: #fff; color: #9b4722; border: 1px solid #9b4722;
  border-radius: 10px; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}

.privacy-actions { display: flex; gap: 0.8rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.row-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Tabelle */
.list { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.list th, .list td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--beige); }
.list th { color: var(--muted-c); font-weight: 600; }
.list tbody tr[onclick] { cursor: pointer; }
.list tbody tr:hover { background: var(--ivory); }
.pts { font-weight: 700; color: var(--fjord); text-align: right; }
.pts.neg { color: #9b4722; }

/* Statistiche admin */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.stat {
  background: #fff; border: 1px solid var(--beige); border-radius: 14px; padding: 1rem;
  text-align: center; box-shadow: var(--shadow-sm); font-size: 0.8rem; color: var(--muted-c);
}
.stat span { display: block; font-size: 1.4rem; font-weight: 700; color: var(--fjord); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ============================================================
   Responsive — cellulare
   ============================================================ */
@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .topbar { font-size: 0.85rem; gap: 0.5rem; }
  .checks { grid-template-columns: 1fr; }
  /* Tabelle scrollabili in orizzontale invece di sfondare il layout */
  .list { display: block; width: 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .stat span { font-size: 1.2rem; }
  .product-item .price { float: none; display: block; margin-bottom: 0.2rem; }
}
