/* =============================================================
   style.css — Print Custom Store
   Tema: refined / luxury — nero, bianco, grigio chiaro, accento oro.
   Mobile-first e responsive.
   ============================================================= */

/* ----------------------- VARIABILI ----------------------- */
:root {
  --bg: #0a0a0c;
  --bg-soft: #121216;
  --surface: #16161b;
  --surface-2: #1d1d24;
  --line: #2a2a32;
  --text: #f4f4f2;
  --text-dim: #a6a6ad;
  --text-faint: #6f6f78;
  --gold: #c9a227;
  --gold-soft: #e7c95a;
  --green: #36c98a;
  --danger: #e5544b;
  --white: #ffffff;

  --radius-s: 12px;
  --radius: 18px;
  --radius-l: 26px;

  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  --shadow-soft: 0 8px 24px -12px rgba(0, 0, 0, 0.6);

  --font-display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;

  --header-h: 62px;
  --bottomnav-h: 66px;
  --maxw: 1100px;
}

/* ----------------------- RESET ----------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: radial-gradient(1200px 600px at 80% -10%, #1a1a22 0%, var(--bg) 55%) fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
}

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; line-height: 1.08; margin: 0; }

/* ----------------------- HEADER ----------------------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 10, 12, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: #fff; overflow: hidden; padding: 5px;
  box-shadow: 0 0 0 1px var(--line);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text { font-family: var(--font-display); font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand-text em { color: var(--gold); font-style: normal; }

.top-nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  background: none; border: none; color: var(--text-dim);
  font-size: 14px; padding: 8px 10px; border-radius: 10px;
}
.nav-link:hover { color: var(--text); }
.install-link { color: var(--gold); border: 1px solid var(--line); }
.top-nav .nav-link:not(.install-link) { display: none; }

.cart-btn {
  position: relative; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
}
.cart-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 19px; height: 19px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--gold); color: #1a1300; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}

/* ----------------------- LAYOUT VISTE ----------------------- */
.view { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 30px; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { margin: 8px 0 20px; }
.page-head h1 { font-size: clamp(28px, 7vw, 42px); }
.page-head p { color: var(--text-dim); margin: 8px 0 0; max-width: 60ch; }
.kicker { color: var(--gold); font-weight: 600; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: 14px; margin-bottom: 14px;
}
.back-link:hover { color: var(--text); }

/* ----------------------- HERO ----------------------- */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius-l);
  border: 1px solid var(--line);
  background:
    radial-gradient(600px 240px at 90% 0%, rgba(201,162,39,.18), transparent 60%),
    linear-gradient(160deg, var(--surface-2), var(--surface));
  padding: 30px 22px;
  margin-bottom: 26px;
}
.hero h1 { font-size: clamp(30px, 8vw, 52px); max-width: 16ch; }
.hero p { color: var(--text-dim); margin: 14px 0 0; max-width: 46ch; }
.hero .hero-badge {
  display: inline-flex; gap: 8px; align-items: center;
  font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 14px;
}
.hero .hero-badge::before { content: ""; width: 28px; height: 1px; background: var(--gold); }

/* Variante hero con immagine di sfondo (illustrazione homepage) */
.hero-img {
  background: none;
  padding: 0;
  min-height: 420px;
  display: flex;
  align-items: flex-end;
}
.hero-img::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to top, rgba(10,10,12,.96) 4%, rgba(10,10,12,.55) 42%, rgba(10,10,12,.12) 100%),
    url("./hero.jpg");
  background-size: cover;
  background-position: center 18%;
}
.hero-img .hero-overlay { position: relative; z-index: 1; padding: 26px 22px; width: 100%; }
.hero-img .hero-overlay p { color: #e7e7e4; }
@media (min-width: 720px) { .hero-img { min-height: 480px; } }

/* ----------------------- GRID PRODOTTI ----------------------- */
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.card:hover { transform: translateY(-4px); border-color: #3a3a44; box-shadow: var(--shadow); }
.card-media {
  aspect-ratio: 4 / 3; background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden;
}
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-media .ph { color: var(--text-faint); font-size: 13px; }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h3 { font-size: 17px; }
.card-body .desc { color: var(--text-dim); font-size: 13px; flex: 1; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.price { font-family: var(--font-display); font-weight: 800; font-size: 18px; }
.price small { color: var(--text-dim); font-weight: 500; font-size: 12px; }
.tag {
  font-size: 11px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--gold); color: var(--gold); letter-spacing: .04em;
}
.tag.green { border-color: var(--green); color: var(--green); }

/* ----------------------- BOTTONI ----------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 14px;
  padding: 15px 20px; font-size: 16px; font-weight: 600;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  transition: transform .12s ease, filter .2s ease, background .2s ease;
  width: 100%;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--gold); color: #1a1300; border-color: var(--gold); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-green { background: var(--green); color: #042417; border-color: var(--green); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(229,84,75,.4); }
.btn-sm { padding: 10px 14px; font-size: 14px; width: auto; border-radius: 11px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ----------------------- DETTAGLIO PRODOTTO ----------------------- */
.detail { display: grid; gap: 22px; }
@media (min-width: 820px) { .detail { grid-template-columns: 1fr 1fr; align-items: start; } }
.detail-media {
  border-radius: var(--radius-l); overflow: hidden; border: 1px solid var(--line);
  background: var(--surface-2); aspect-ratio: 4/3; display: grid; place-items: center;
}
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.detail h1 { font-size: clamp(26px, 6vw, 38px); margin-bottom: 10px; }
.detail .lead { color: var(--text-dim); }
.detail .big-price { font-family: var(--font-display); font-weight: 800; font-size: 30px; margin: 16px 0; }

/* ----------------------- FORM / CONFIGURATORE ----------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.panel h2 { font-size: 18px; margin-bottom: 14px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; font-weight: 500; }
input, select, textarea {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; outline: none;
  transition: border-color .2s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { min-height: 90px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Selettori a chip (tipo adesivo, forma) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.choice {
  position: relative; border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; background: var(--bg-soft); cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.choice .ttl { font-weight: 600; font-size: 14px; }
.choice .sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice.selected { border-color: var(--gold); background: rgba(201,162,39,.08); }
.choice.selected::after {
  content: "✓"; position: absolute; top: 10px; right: 12px; color: var(--gold); font-weight: 700;
}

/* Box prezzo cliente (pulito) */
.price-box {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(120deg, var(--surface-2), var(--surface));
  border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 18px; margin: 16px 0;
}
.price-box .lab { color: var(--text-dim); font-size: 13px; }
.price-box .val { font-family: var(--font-display); font-weight: 800; font-size: 30px; color: var(--gold-soft); }
.price-error { color: var(--danger); font-size: 14px; margin: 10px 0; }

/* Upload file */
.uploader {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 18px; text-align: center; background: var(--bg-soft);
  transition: border-color .2s ease;
}
.uploader:hover { border-color: var(--gold); }
.uploader input { display: none; }
.uploader .hint { color: var(--text-dim); font-size: 13px; margin-top: 6px; }
.uploader .upload-cta { color: var(--gold); font-weight: 600; }
.file-preview { margin-top: 14px; display: flex; align-items: center; gap: 12px; }
.file-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.file-preview .fp-doc {
  width: 64px; height: 64px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--gold); font-weight: 700; font-size: 12px;
}
.file-preview .fp-name { font-size: 13px; word-break: break-all; }
.note { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

/* Debug admin */
.debug {
  background: #0d0d10; border: 1px dashed var(--line); border-radius: 12px;
  padding: 14px; font-size: 12.5px; color: var(--text-dim); line-height: 1.7;
}
.debug b { color: var(--text); }

/* ----------------------- CARRELLO ----------------------- */
.cart-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px;
  align-items: center; padding: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 12px;
}
.cart-item .ci-media { width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.cart-item .ci-media img { width: 100%; height: 100%; object-fit: cover; }
.cart-item .ci-media .fp-doc { color: var(--gold); font-size: 11px; font-weight: 700; }
.cart-item h3 { font-size: 15px; }
.cart-item .ci-config { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }
.cart-item .ci-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.cart-item .ci-price { font-family: var(--font-display); font-weight: 800; }
.link-remove { background: none; border: none; color: var(--danger); font-size: 13px; padding: 0; }

.summary {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-top: 8px;
}
.summary .row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--text-dim); font-size: 14px; }
.summary .row.total { color: var(--text); font-family: var(--font-display); font-weight: 800; font-size: 22px; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }

/* ----------------------- STATO VUOTO ----------------------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty .ico { font-size: 42px; margin-bottom: 10px; }
.empty h2 { margin-bottom: 8px; }

/* ----------------------- ADMIN ----------------------- */
.admin-list .admin-row {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); margin-bottom: 10px;
}
.admin-row .ar-media { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; font-size: 11px; color: var(--text-faint); }
.admin-row .ar-media img { width: 100%; height: 100%; object-fit: cover; }
.admin-row h3 { font-size: 15px; }
.admin-row .ar-meta { font-size: 12px; color: var(--text-dim); }

/* PIN */
.pin-wrap { max-width: 360px; margin: 30px auto; text-align: center; }
.pin-dots { letter-spacing: 8px; font-size: 24px; }

/* ----------------------- BOTTOM NAV (mobile) ----------------------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(12,12,15,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-faint); font-size: 12px;
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active { color: var(--gold); }
@media (min-width: 860px) {
  .bottom-nav { display: none; }
  body { padding-bottom: 30px; }
  .top-nav .nav-link:not(.install-link) { display: inline-block; }
}

/* ----------------------- TOAST ----------------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottomnav-h) + 18px);
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text); padding: 13px 18px; border-radius: 14px;
  box-shadow: var(--shadow); z-index: 100; font-size: 14px; max-width: 90vw;
  opacity: 0; transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--danger); }

/* ----------------------- MODALE ----------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.6);
  display: grid; place-items: end center; padding: 0;
  animation: fade .2s ease;
}
@media (min-width: 700px) { .modal-overlay { place-items: center; padding: 20px; } }
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .modal { border-radius: var(--radius-l); } }
.modal h2 { margin-bottom: 16px; }
.modal-close { position: absolute; }

.divider { height: 1px; background: var(--line); margin: 18px 0; border: none; }
.muted { color: var(--text-dim); font-size: 13px; }
.spaced { margin-top: 14px; }
.center { text-align: center; }
