/* ============================================================
   Centro Abbronzatura — UI condivisa
   ============================================================ */
:root {
  --sun:       #F59E0B;
  --sun-dark:  #D97706;
  --sun-light: #FEF3C7;
  --cool:      #0EA5E9;
  --cool-light:#E0F2FE;
  --bg:        #FFFBF5;
  --card:      #FFFFFF;
  --ink:       #111827;
  --ink-soft:  #6B7280;
  --border:    #E5E7EB;
  --danger:    #EF4444;
  --success:   #10B981;
  --warning:   #F59E0B;
  --shadow:    0 4px 16px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, 0.10);
  --radius:    14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ============================================================
   LAYOUT
   ============================================================ */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px 80px;
  min-height: 100vh;
}
.app--wide { max-width: 1100px; }

header.top {
  padding: 20px 0 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
header.top .logo {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--sun) 0%, #DC2626 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
header.top .sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

footer.bot { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 20px 0; }

/* ============================================================
   STEPPER
   ============================================================ */
.stepper {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 0 8px;
}
.stepper .dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  transition: all .2s;
}
.stepper .dot.active { background: var(--sun); color: white; }
.stepper .dot.done   { background: var(--success); color: white; }
.stepper .line {
  flex: 1; height: 2px; background: var(--border); margin: 13px 4px;
  transition: background .2s;
}
.stepper .line.done { background: var(--success); }

/* ============================================================
   CARDS / SECTIONS
   ============================================================ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card .hint { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  transition: all .15s;
  width: 100%;
  text-align: center;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--sun  { background: var(--sun); color: white; }
.btn--sun:hover:not(:disabled) { background: var(--sun-dark); }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn--sm { padding: 8px 14px; font-size: 14px; width: auto; }
.btn--danger { background: var(--danger); }

/* ============================================================
   SCELTA TIPO (lettino / doccia)
   ============================================================ */
.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.type-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.type-card:hover { transform: translateY(-2px); }
.type-card.selected { border-color: var(--sun); background: var(--sun-light); }
.type-card .icon { font-size: 36px; line-height: 1; margin-bottom: 6px; }
.type-card .name { font-weight: 700; font-size: 16px; }
.type-card .meta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.type-card.cool.selected { border-color: var(--cool); background: var(--cool-light); }

/* ============================================================
   INPUTS
   ============================================================ */
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 600; }
input[type="text"], input[type="tel"], input[type="date"], input[type="password"] {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
input:focus { border-color: var(--sun); }

/* HONEYPOT: invisibile ma presente nel DOM (i bot lo compilano) */
.honeypot {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ============================================================
   GRIGLIA SLOT ORARI
   ============================================================ */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.slot-btn {
  padding: 14px 6px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.slot-btn:hover:not(:disabled) { border-color: var(--sun); }
.slot-btn.selected { background: var(--sun); color: white; border-color: var(--sun); }
.slot-btn:disabled { opacity: .35; cursor: not-allowed; text-decoration: line-through; }
.slot-btn .badge {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-top: 2px;
}
.slot-btn.selected .badge { color: rgba(255,255,255,.85); }
.slot-btn.full { }

/* ============================================================
   RIEPILOGO
   ============================================================ */
.summary {
  background: var(--sun-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.summary .row { display: flex; justify-content: space-between; padding: 6px 0; }
.summary .row .k { color: var(--ink-soft); }
.summary .row .v { font-weight: 600; }
.summary .row.total { border-top: 1px solid var(--sun); margin-top: 6px; padding-top: 10px; }
.summary .row.total .v { color: var(--sun-dark); font-size: 18px; }

/* ============================================================
   CONFERMA / QR
   ============================================================ */
.success {
  text-align: center;
  padding: 20px 0;
}
.success .check {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  font-size: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.success h2 { margin: 0 0 4px; font-size: 22px; }
.success .code-big {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 4px;
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  border-radius: 10px;
  display: inline-block;
  margin: 16px 0 8px;
}
.qr-box {
  background: white;
  padding: 16px;
  border-radius: var(--radius);
  display: inline-block;
  box-shadow: var(--shadow);
  margin: 12px 0;
}
.qr-box img { display: block; width: 240px; height: 240px; }

/* ============================================================
   GESTORE — DASHBOARD
   ============================================================ */
.dash-header {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.dash-header h1 { margin: 0; font-size: 22px; }
.dash-header-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: nowrap;
  justify-content: center;
  width: 100%;
}
.dash-header-actions input[type="date"],
.dash-header-actions .btn {
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  line-height: 44px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.dash-header-actions input[type="date"] {
  width: auto;
  padding: 0 12px;
  font-size: 15px;
}
.dash-header-actions input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.dash-header-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 12px;
  font-size: 15px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stats .stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stats .stat .v { font-size: 22px; font-weight: 800; color: var(--sun-dark); }
.stats .stat .k { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* Incassato: card cliccabile (tap per mostrare/nascondere) */
#stat-ric-card {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s, box-shadow .15s;
}
#stat-ric-card:hover { box-shadow: var(--shadow-lg); }
#stat-ric-card:active { transform: scale(.97); }
#stat-ric-card .k { position: relative; }
#stat-ric-card:not(.revealed) .v { letter-spacing: 2px; color: var(--ink-soft); }

.lookup-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.lookup-bar input { flex: 1; }

.export-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.export-bar .hint { font-size: 13px; color: var(--ink-soft); margin-right: 4px; }

/* ============================================================
   F4 CHART (ricavi) — pagina dedicata /ricavi
   ============================================================ */
.chart-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.chart-card--tall { padding-bottom: 20px; }
.chart-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-header h3 { margin: 0; font-size: 15px; }
/* CRUCIALE: altezza fissa sul container per evitare che Chart.js si espanda all'infinito */
.chart-wrap { position: relative; height: 320px; width: 100%; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* ============================================================
   F4 PAGINA RICAVI
   ============================================================ */
.revenue-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.revenue-header h1 { margin: 0; font-size: 22px; }
.revenue-header .hint { font-size: 13px; margin-top: 4px; }

.revenue-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.revenue-table th, .revenue-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  text-align: left;
}
.revenue-table thead th {
  background: var(--bg); font-weight: 700; color: var(--ink-soft);
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
}
.revenue-table tbody tr:hover { background: var(--bg); }

/* ============================================================
   CTA "Analisi ricavi" nella dashboard
   ============================================================ */
.cta-ricavi {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, var(--sun-light) 0%, #FFF7E6 100%);
  border: 1px solid var(--sun);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s, box-shadow .15s;
}
.cta-ricavi:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); text-decoration: none; }
.cta-icon { font-size: 28px; }
.cta-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cta-text strong { font-size: 16px; color: var(--sun-dark); }
.cta-text .hint { font-size: 12px; color: var(--ink-soft); }
.cta-arrow { font-size: 22px; color: var(--sun-dark); font-weight: 700; }

/* ============================================================
   F8 FILTER CHIPS
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .hint { font-size: 13px; color: var(--ink-soft); margin-right: 4px; }
.chip {
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--sun); color: var(--ink); }
.chip.active { background: var(--sun); color: white; border-color: var(--sun); }

/* ============================================================
   VIEW TOGGLE (Giorno / Settimana)
   ============================================================ */
.view-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.view-toggle .btn { flex: 1; }
.view-toggle .btn.active { background: var(--sun); color: white; border-color: var(--sun); }

/* ============================================================
   VISTA SETTIMANALE
   ============================================================ */
.week-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.week-grid-wrap { overflow-x: auto; }
.week-grid {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-size: 13px;
}
.week-grid th, .week-grid td {
  padding: 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.week-grid th { background: var(--bg); font-weight: 700; font-size: 12px; color: var(--ink-soft); }
.week-grid th.today { color: var(--sun-dark); }
.week-grid td { vertical-align: middle; }
.week-grid td.slot-label { font-weight: 700; background: var(--bg); color: var(--ink-soft); }
.week-grid td.day-cell { cursor: pointer; transition: background .15s; }
.week-grid td.day-cell:hover { background: var(--sun-light); }
.week-grid td.today-col { background: rgba(245, 158, 11, 0.06); }
.week-grid td.closed { background: var(--border); cursor: not-allowed; }
.week-grid .cell-bar {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  min-width: 22px;
}
.week-grid .cell-bar.empty { background: var(--border); color: var(--ink-soft); }
.week-grid .cell-bar.low    { background: #10B981; }
.week-grid .cell-bar.medium { background: #F59E0B; }
.week-grid .cell-bar.high   { background: #EF4444; }
.week-grid .cell-bar.full   { background: #6B7280; }
.week-grid .day-cell .count { font-size: 10px; color: var(--ink-soft); display: block; margin-top: 2px; }

.booking-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 14px;
  align-items: center;
  border-left: 4px solid var(--border);
  transition: all .2s;
}
.booking-card.highlight { box-shadow: 0 0 0 3px var(--sun), var(--shadow-lg); transform: scale(1.01); }
.booking-card.status-in_attesa   { border-left-color: var(--ink-soft); }
.booking-card.status-confermato  { border-left-color: var(--success); }
.booking-card.status-completato  { border-left-color: var(--cool); opacity: .7; }
.booking-card.status-cancellato  { border-left-color: var(--danger); opacity: .5; }

.booking-card .when { text-align: center; }
.booking-card .when .time { font-size: 22px; font-weight: 800; line-height: 1; }
.booking-card .when .res  { font-size: 11px; color: var(--ink-soft); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }

.booking-card .who .name { font-weight: 700; font-size: 15px; }
.booking-card .who .meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.booking-card .who .meta .code { font-family: ui-monospace, monospace; }

.booking-card .actions { display: flex; flex-direction: column; gap: 6px; }
.booking-card .actions .btn { width: auto; padding: 8px 14px; font-size: 13px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  background: var(--border);
  color: var(--ink);
}
.badge--in_attesa  { background: #E5E7EB; color: var(--ink-soft); }
.badge--confermato { background: #D1FAE5; color: #065F46; }
.badge--completato { background: var(--cool-light); color: #075985; }
.badge--cancellato { background: #FEE2E2; color: #991B1B; }

/*============================================================
   PIN LOGIN
   ============================================================ */
.pin-card {
  max-width: 360px;
  margin: 60px auto;
  text-align: center;
  padding: 32px 24px;
}
.pin-card .lock { font-size: 40px; margin-bottom: 8px; }
.pin-card input { text-align: center; font-size: 22px; letter-spacing: 8px; }

/* ============================================================
   SCANNER MODAL
   ============================================================ */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal.open { display: flex; }
.modal .box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 420px;
  width: 100%;
  position: relative;
}
.modal .close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--ink-soft);
}
#qr-reader { width: 100%; border-radius: 10px; overflow: hidden; margin-top: 12px; }
#qr-reader video { border-radius: 10px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 12px;
  display: none;
}
.alert.show { display: block; }
.alert.error { background: #FEE2E2; color: #991B1B; }
.alert.info  { background: var(--cool-light); color: #075985; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  /* --- Mobile: dashboard compatta, uso col pollice --- */
  .app, .app--wide { padding: 10px 10px 24px; }

  .slot-grid { grid-template-columns: repeat(2, 1fr); }

  /* Stats: 3 in linea, compatte (prima occupavano 3 schermate) */
  .stats { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
  .stats .stat { padding: 8px 4px; }
  .stats .stat .v { font-size: 18px; }
  .stats .stat .k { font-size: 10px; }

  /* Header dashboard: solo il margine; dimensioni/centratura in regola base */
  .dash-header { margin-bottom: 10px; }
  .dash-header-actions { gap: 8px; }
  .dash-header-actions input[type="date"],
  .dash-header-actions .btn { height: 46px; line-height: 46px; }

  /* Export bar: titolo su riga, bottoni che si dividono lo spazio */
  .export-bar { padding: 8px 10px; gap: 6px; margin-bottom: 10px; }
  .export-bar .hint { width: 100%; margin: 0 0 2px; }
  .export-bar .btn { flex: 1 1 0; min-width: 0; }

  /* CTA ricavi piu compatta */
  .cta-ricavi { padding: 12px 14px; margin-bottom: 10px; gap: 10px; }
  .cta-icon { font-size: 22px; }
  .cta-text strong { font-size: 15px; }
  .cta-text .hint { font-size: 11px; }

  /* Filtri: riga unica scrollabile orizzontalmente (niente wrap su 2 righe) */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 10px;
    padding-bottom: 2px;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar .hint { display: none; }
  .chip { flex: 0 0 auto; padding: 5px 10px; font-size: 12px; }

  /* View toggle (Giorno/Settimana) */
  .view-toggle { margin-bottom: 10px; }

  /* Lookup + scanner: input a tutta larghezza, bottoni touch-friendly */
  .lookup-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
  }
  .lookup-bar input {
    grid-column: 1 / -1;
    min-width: 0;
    font-size: 16px; /* >=16px evita lo zoom automatico su iOS */
    padding: 12px;
  }
  .lookup-bar .btn {
    min-height: 48px;
    font-size: 15px;
    padding: 12px 14px;
  }

  /* Prenotazioni */
  .booking-card { grid-template-columns: 62px 1fr; padding: 10px; }
  .booking-card .actions { grid-column: 1 / -1; flex-direction: row; gap: 6px; margin-top: 4px; }
  .booking-card .actions .btn {
    flex: 1;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Touch target minimo per tutti i bottoni/pill */
  .btn--sm { min-height: 40px; }
  .week-controls .btn { min-height: 44px; }

  /* Sezione blacklist: campi a piena larghezza */
  #blk-section .lookup-bar { grid-template-columns: 1fr; }
  #blk-section .lookup-bar input,
  #blk-section .lookup-bar select,
  #blk-section .lookup-bar .btn { grid-column: 1 / -1; width: 100%; box-sizing: border-box; }
  #blk-section .row { flex-wrap: wrap; gap: 6px; }

  /* Testo piu leggibile */
  body { font-size: 15px; }
}

/* Telefoni molto stretti */
@media (max-width: 380px) {
  .stats .stat .v { font-size: 16px; }
  .stats .stat .k { font-size: 9px; }
  .lookup-bar .btn { font-size: 14px; padding: 12px 10px; }
}
