/* =====================================================
   CUSTOMLAB – Stile principale
   ===================================================== */

:root {
  --accent: #111;
  --accent-hover: #333;
  --bg: #f8f7f5;
  --surface: #ffffff;
  --border: #e0ddd8;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 16px rgba(0,0,0,.08);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 1.15rem; letter-spacing: -.5px; }
.logo strong { font-weight: 900; }
.header-nav { display: flex; gap: 24px; }
.header-nav a { text-decoration: none; color: var(--text-muted); font-size: .9rem; }
.header-nav a:hover { color: var(--text); }

/* ── Hero ── */
.hero {
  padding: 80px 24px 64px;
  text-align: center;
  background: linear-gradient(180deg, #fff 0%, var(--bg) 100%);
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 900; line-height: 1.1; letter-spacing: -.5px; }
.hero em { font-style: normal; color: #444; text-decoration: underline; text-underline-offset: 4px; }
.hero p { margin: 20px auto; max-width: 500px; color: var(--text-muted); font-size: 1.05rem; }

/* ── Buttons ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  padding: 14px 28px; border-radius: 999px;
  font-size: 1rem; font-weight: 700;
  text-decoration: none; border: none; cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--text);
  border: 1.5px solid var(--border);
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: border-color .2s, background .2s;
  width: 100%;
}
.btn-secondary:hover { border-color: var(--accent); background: #f5f5f5; }

/* ── Configuratore ── */
.configurator-section {
  max-width: 1100px; margin: 0 auto; padding: 40px 16px 100px;
}
.configurator-section > h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 24px; }

.configurator-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Pannello controlli ── */
.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; gap: 20px;
  box-shadow: var(--shadow);
}

.control-group { display: flex; flex-direction: column; gap: 10px; }
.group-label {
  font-size: .78rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
}

.button-group {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.pick-btn {
  padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff; color: var(--text);
  font-size: .875rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pick-btn:hover { border-color: #aaa; }
.pick-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Color swatches */
.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
  transition: transform .15s, box-shadow .15s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px #fff; }
.custom-swatch {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg,#f6d365,#fda085,#a18cd1);
  cursor: pointer; font-size: 14px;
}
.custom-swatch input[type=color] { display: none; }

/* Graphic tabs */
.graphic-options { display: flex; gap: 6px; flex-wrap: wrap; }
.graphic-btn {
  flex: 1; min-width: 90px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #fff; color: var(--text-muted);
  font-size: .8rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.graphic-btn.active { border-color: var(--accent); color: var(--accent); }

.graphic-panel { padding-top: 8px; }
.graphic-panel.hidden { display: none; }

/* Upload zone */
.upload-zone {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 24px 16px; cursor: pointer; text-align: center;
  background: #fafafa; font-size: .85rem; color: var(--text-muted);
  transition: border-color .2s, background .2s;
}
.upload-zone:hover { border-color: var(--accent); background: #f5f5f5; }
.upload-zone input[type=file] { display: none; }

/* Text panel */
#text-input {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 1rem; background: #fafafa;
}
#text-input:focus { outline: none; border-color: var(--accent); }

.font-picker, .color-row {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.font-picker label, .color-row label {
  font-size: .8rem; color: var(--text-muted); white-space: nowrap;
}
.font-picker select {
  flex: 1; padding: 8px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; font-size: .85rem;
}

/* AI panel */
#ai-prompt {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9rem; resize: none; background: #fafafa;
}
#ai-prompt:focus { outline: none; border-color: var(--accent); }
.ai-results {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px;
}
.ai-result-item {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer; transition: border-color .15s;
}
.ai-result-item:hover { border-color: var(--accent); }
.ai-result-item img { width: 100%; display: block; }
.ai-result-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Size + Qty */
.size-qty-row {
  display: flex; gap: 10px; align-items: center;
}
#size-select {
  flex: 1; padding: 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .95rem; background: #fff;
}
.qty-control {
  display: flex; align-items: center; gap: 0;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.qty-control button {
  width: 36px; height: 38px; border: none; background: #f5f5f5;
  font-size: 1.2rem; cursor: pointer; color: var(--text);
  transition: background .15s;
}
.qty-control button:hover { background: #e5e5e5; }
#qty-display {
  width: 40px; text-align: center; font-weight: 700; font-size: .95rem;
}

.hint { font-size: .78rem; color: var(--text-muted); }

/* ── Canvas wrapper ── */
.canvas-wrapper {
  position: sticky; top: 70px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#threejs-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  touch-action: none;
}
.canvas-hint {
  position: absolute; bottom: 12px;
  font-size: .75rem; color: rgba(0,0,0,.4);
  pointer-events: none;
}
.print-area-badge {
  position: absolute; top: 12px; left: 12px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: .7rem; font-weight: 700; letter-spacing: .1em;
  padding: 4px 10px; border-radius: 999px;
  pointer-events: none;
}

/* ── Barra prezzo ── */
.price-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border-top: 1px solid var(--border);
  padding: 12px 24px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.price-info { display: flex; flex-direction: column; gap: 2px; }
.price-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.price-value { font-size: 1.5rem; font-weight: 900; letter-spacing: -.5px; }
.price-unit { font-size: .78rem; color: var(--text-muted); }
.btn-order { font-size: 1rem; padding: 14px 32px; }

/* ── Come funziona ── */
.how-section {
  background: #fff; padding: 64px 24px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.how-section h2 { font-size: 1.6rem; font-weight: 800; text-align: center; margin-bottom: 40px; }
.steps-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px; max-width: 900px; margin: 0 auto;
}
.step { text-align: center; }
.step-icon { font-size: 2rem; margin-bottom: 12px; }
.step h3 { font-weight: 700; margin-bottom: 6px; }
.step p { font-size: .9rem; color: var(--text-muted); }

/* ── Galleria ── */
.gallery-section {
  padding: 64px 24px; max-width: 1100px; margin: 0 auto;
}
.gallery-section h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.gallery-subtitle { color: var(--text-muted); margin-bottom: 32px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.gallery-card {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; background: #fff;
  transition: box-shadow .2s, transform .2s;
}
.gallery-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.gallery-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.gallery-card-label {
  padding: 10px 12px;
  font-size: .85rem; font-weight: 600;
}

/* ── Footer ── */
.site-footer {
  background: var(--accent); color: rgba(255,255,255,.7);
  padding: 32px 24px; text-align: center;
  margin-bottom: 80px; /* spazio per price-bar */
}
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 24px; margin-bottom: 16px; }
.footer-links a { color: rgba(255,255,255,.7); text-decoration: none; font-size: .875rem; }
.footer-links a:hover { color: #fff; }
.footer-copy { font-size: .8rem; }

/* ──────────────── RESPONSIVE ──────────────── */
@media (max-width: 768px) {
  .configurator-layout {
    grid-template-columns: 1fr;
  }
  .canvas-wrapper {
    position: static;
    aspect-ratio: 1;
    width: 100%;
  }
  .controls-panel { order: 2; }
  .canvas-wrapper { order: 1; }
  .header-nav { display: none; }
  .btn-order { padding: 12px 20px; font-size: .9rem; }
  .price-value { font-size: 1.25rem; }
}

/* Loading spinner per IA */
.ai-spinner {
  display: flex; align-items: center; justify-content: center;
  height: 80px; color: var(--text-muted); font-size: .875rem;
}
.ai-spinner::before {
  content: '';
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Aggiunte prototipo v1 ── */
.muted { color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.configurator-section { padding-top: 16px; }
.canvas-wrapper { position: sticky; }
.canvas-tools {
  position: absolute; top: 10px; right: 10px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.92); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 6px; box-shadow: var(--shadow);
}
.canvas-tools[hidden] { display: none; }
.canvas-tools input[type=range] { width: 90px; accent-color: var(--accent); }
.tool-btn {
  border: none; background: transparent; padding: 8px 10px; border-radius: 999px;
  font-size: .85rem; font-weight: 700; cursor: pointer; color: var(--text);
}
.tool-btn.active { background: #3b82f6; color: #fff; }
.size-info {
  position: absolute; bottom: 34px; font-size: .75rem; font-weight: 700;
  color: #3b82f6; pointer-events: none;
}
.pick-btn .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  margin-left: 4px; vertical-align: middle; background: transparent;
}
.pick-btn.has-graphic .dot { background: #22c55e; }
.font-picker { gap: 8px; }
.font-picker input[type=color] { width: 42px; height: 38px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 2px; background: #fff; }
.apply-gap, #apply-text, #generate-ai { margin-top: 10px; }
.sizes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.size-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 6px;
}
.size-cell.filled { border-color: var(--accent); }
.size-name { font-weight: 800; font-size: .85rem; }
.size-cell .qty-control button { width: 30px; height: 30px; }
.size-cell .qty-control span { width: 28px; text-align: center; font-weight: 700; }
.discount-hint { color: #15803d; font-weight: 600; }
.ai-result-item { padding: 0; background: #f5f5f5; }
.gallery-card { padding: 0; text-align: left; font: inherit; color: inherit; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.price-bar { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
#order-dialog {
  border: none; border-radius: var(--radius); padding: 24px; width: min(420px, calc(100% - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,.3); margin: auto;
}
#order-dialog::backdrop { background: rgba(0,0,0,.5); }
#order-dialog h3 { margin-bottom: 12px; }
#order-preview { width: 100%; border-radius: var(--radius-sm); margin-bottom: 12px; aspect-ratio: 1; object-fit: cover; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.summary-row strong { text-align: right; }
#order-dialog .hint { margin: 12px 0; }
#order-dialog .btn-primary { width: 100%; justify-content: center; }

@media (max-width: 768px) {
  .configurator-section { padding: 0 0 100px; }
  .configurator-layout { gap: 0; }
  .canvas-wrapper {
    position: sticky; top: 56px; z-index: 10;
    aspect-ratio: auto; height: 46vh; border-radius: 0; border-left: none; border-right: none;
  }
  .controls-panel { border-radius: 0; border: none; box-shadow: none; }
  .canvas-tools input[type=range] { width: 70px; }
}

/* ── IA tappa 2 ── */
.ai-result-item { display: flex; flex-direction: column; font: inherit; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0 / 16px 16px; }
.ai-result-item img { aspect-ratio: 1; object-fit: contain; padding: 6px; }
.ai-result-item span { font-size: .75rem; font-weight: 700; padding: 4px; background: #fff; border-top: 1px solid var(--border); }
.ai-note { grid-column: 1 / -1; }
.ai-error { grid-column: 1 / -1; color: #b91c1c; font-size: .85rem; font-weight: 600; }
.ai-spinner { grid-column: 1 / -1; }
#generate-ai:disabled { opacity: .5; cursor: wait; }

/* ── Pagamento tappa 3 ── */
.terms-check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 6px; font-size: .85rem; line-height: 1.4; }
.terms-check input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; accent-color: var(--accent); }
.terms-check a { color: inherit; }
.order-error { color: #b91c1c; font-size: .85rem; font-weight: 600; min-height: 1.2em; margin-bottom: 6px; }
.pay-note { text-align: center; margin-top: 8px; }
.btn-link { display: block; margin: 6px auto 0; background: none; border: none; color: var(--text-muted); text-decoration: underline; cursor: pointer; font-size: .85rem; padding: 6px; }

/* ── Pagine legali e di servizio ── */
.legal { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; }
.legal h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 900; margin-bottom: 8px; line-height: 1.15; }
.legal h2 { font-size: 1.1rem; font-weight: 800; margin: 28px 0 8px; }
.legal p, .legal li { color: #333; margin-bottom: 8px; }
.legal ul { padding-left: 20px; }
.legal a { color: var(--text); }
.legal .updated { color: var(--text-muted); font-size: .85rem; margin-bottom: 20px; }
.draft-banner { background: #fef3c7; border: 1px solid #f59e0b; color: #78350f; padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600; margin-bottom: 20px; }
.fill { background: #fde68a; padding: 0 4px; border-radius: 4px; font-weight: 600; }
.legal-page .site-footer { margin-bottom: 0; }
.legal .btn-primary { margin-top: 16px; }
.contact-card { border: 1px solid var(--border); background: #fff; border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; }
.contact-card strong { display: block; margin-bottom: 4px; }
