/* ===== Booking Portal - Tap2Order ===== */

:root {
  --primary: #7c5cfc;
  --primary-dark: #6346e0;
  --primary-light: #f5f3ff;
  --primary-glow: rgba(124, 92, 252, 0.15);
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --bg: #f1f0fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
  --primary-hover: #6346e0;
}

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

/* min-height (non height fissa) così il body cresce col contenuto e il footer
   resta sempre in fondo anche con form lunghi (coerente con il portale asporto) */
html { min-height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  padding-top: 24px;
  min-height: calc(100dvh - 50px);
}

/* Steps */
.step {
  display: none;
  width: 100%;
  max-width: 480px;
  animation: fadeIn 0.35s ease;
}
.step.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Card */
.booking-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  max-width: 100%;
}

/* Restaurant header */
.restaurant-header {
  text-align: center;
  margin-bottom: 28px;
}
.restaurant-logo {
  font-size: 48px;
  margin-bottom: 8px;
}
.restaurant-header h1 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}
.restaurant-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Section header */
.section-header {
  text-align: center;
  margin-bottom: 24px;
}
.section-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}
.section-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Form */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
  margin-bottom: 4px;
}
.form-label .optional {
  font-weight: 400;
  color: var(--text-light);
  font-size: 12px;
}

.form-input {
  width: 100%;
  max-width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  box-sizing: border-box;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
}

/* Checkbox consensi (coerente con il portale asporto) */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  cursor: pointer;
  margin-top: 10px;
  line-height: 1.4;
}
.checkbox-label input {
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.checkbox-label a { color: var(--primary); }

/* Box informativo (es. messaggio "in attesa di conferma") */
.info-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 14px;
  color: #92400e;
  line-height: 1.5;
  text-align: left;
}

/* Phone input */
.phone-input-group {
  display: flex;
  align-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.phone-input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.phone-prefix {
  padding: 12px 14px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
  border-right: 2px solid var(--border);
  user-select: none;
}
.phone-input-group input {
  flex: 1;
  border: none;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  background: transparent;
}

/* OTP inputs */
.otp-input-group {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0;
  align-items: center;
}
.otp-digit {
  width: 44px;
  height: 52px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: 'Inter', monospace;
  color: var(--primary);
}
.otp-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.otp-dash {
  color: var(--text-light);
  font-size: 18px;
}

/* People selector */
.people-selector {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: center;
  margin: 8px 0;
}
.people-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.people-btn:active {
  background: var(--primary);
  color: #fff;
  transform: scale(0.95);
}
#people-count {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  min-width: 40px;
  text-align: center;
}

/* Time slots */
/* Telefono ed email affiancati, ma solo finche' ci stanno davvero.
   ─── PERCHE' NON UN PUNTO DI ROTTURA IN PIXEL ───────────────────────────────
   Prima le due colonne si scioglievano sotto i 380px. Su un iPhone 12 Pro, che
   ne ha 390, restavano affiancate: tolti i margini della pagina e del riquadro
   ogni colonna vale circa 146px, e «📞 Numero di telefono *» ne chiede quasi
   175. L'etichetta andava a capo e trascinava il campo fuori posto.
   E non era un caso italiano: francese, spagnolo e portoghese hanno etichette
   altrettanto lunghe, quindi il difetto valeva in quattro lingue su sei. Ogni
   soglia in pixel e' tarata su UNA parola in UNA lingua, e la prossima
   traduzione la sfonda di nuovo senza che nessuno se ne accorga.
   `auto-fit` con un minimo lascia decidere al contenuto: due colonne quando
   c'e' spazio per 165px l'una, una sola quando non c'e'. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 8px 10px;
}
.field { display: flex; flex-direction: column; min-width: 0; }
.field .form-label { margin-top: 8px; }
/* L'etichetta non si spezza a meta' parola nemmeno quando lo spazio e' poco:
   meglio due righe pulite che «telefo-no». */
.field .form-label { overflow-wrap: break-word; hyphens: none; }

/* Orari: chip a larghezza intrinseca che vanno a capo e restano CENTRATE.
   Con colonne fisse l'ultima riga incompleta lasciava buchi a destra
   (es. 9 orari su 4 colonne → 4+4+1); così ogni riga resta bilanciata
   qualunque sia il numero di orari disponibili. */
.time-slots-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}
/* Messaggi (caricamento / nessun orario / chiuso / errore): riga intera, non chip */
.time-slots-grid > p { flex: 1 1 100%; margin: 0; text-align: center; }

/* Gruppi fascia oraria (accordion) */
.slot-group {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex: 1 1 100%;
}
.slot-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--primary-light);
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}
.slot-group-header:hover {
  background: #e0d9ff;
}
.slot-group-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--primary-dark);
  flex: 1;
}
.slot-group-badge {
  font-size: 12px;
  color: #6b7280;
  background: white;
  border-radius: 12px;
  padding: 2px 8px;
}
.slot-group-badge--full {
  background: #fee2e2;
  color: #dc2626;
  font-weight: 600;
}
.slot-group-arrow {
  font-size: 11px;
  color: var(--primary);
}
.slot-group-body {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px 14px;
}
.slot-group-body .time-slot {
  flex: 0 1 auto;
}

/* Vista compatta dopo la scelta dell'orario (allineata al portale asporto) */
.slot-selected-row { flex: 1 1 100%; width: 100%; display: flex; align-items: stretch; gap: 10px; }
.slot-selected-chip {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 700; font-size: 16px; text-align: center;
}
.slot-change-btn {
  padding: 12px 16px; border-radius: var(--radius-sm); border: 2px solid var(--primary);
  background: #f5f3ff; color: var(--primary); font-weight: 700; font-size: 14px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.slot-change-btn:hover { background: #ede9fe; }

.time-slot {
  flex: 0 1 auto;
  min-width: 84px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}
.time-slot:hover:not(.disabled):not(.selected) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.time-slot.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}
.time-slot.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  text-decoration: line-through;
}
.time-slot .slot-status {
  font-size: 10px;
  font-weight: 400;
  display: block;
  margin-top: 2px;
}
.time-slot.selected .slot-status {
  color: rgba(255,255,255,0.8);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--primary-glow);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary.loading {
  color: transparent;
}
.btn-primary.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-confirm {
  background: var(--success);
  margin-top: 20px;
}
.btn-confirm:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 4px 16px rgba(16,185,129,0.3);
}

.btn-back {
  position: absolute;
  top: 16px;
  left: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0;
}
.btn-back:hover {
  color: var(--primary);
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 12px;
  text-align: center;
  width: 100%;
}
.btn-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-link:hover:not(:disabled) {
  color: var(--primary);
}

/* Hints */
.hint {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  margin-top: 12px;
  line-height: 1.4;
  grid-column: 1 / -1;
}

/* Loading */
#step-loading {
  text-align: center;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Confirmation */
.confirmation-card {
  text-align: center;
}
.confirm-icon {
  font-size: 56px;
  margin-bottom: 8px;
}
.confirmation-card h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--success);
  margin-bottom: 20px;
}
.confirm-details {
  background: var(--success-light);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: left;
  margin-bottom: 16px;
}
.confirm-details .detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 15px;
}
.detail-row .detail-icon {
  font-size: 18px;
  min-width: 24px;
  text-align: center;
}
.detail-row .detail-label {
  color: var(--text-secondary);
  font-size: 13px;
  min-width: 80px;
}
.detail-row .detail-value {
  font-weight: 600;
  color: var(--text);
}
.confirm-note {
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 8px;
}

/* Caparra (deposit) */
.deposit-policy {
  font-size: 12px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 12px 0 0;
  line-height: 1.5;
  text-align: center;
}
.payment-message { color: var(--danger); font-size: 13px; text-align: center; margin-top: 8px; }

/* Error toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--danger);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: transform 0.3s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.toast-success {
  background: var(--success);
}

/* Footer */
.booking-footer {
  text-align: center;
  padding: 12px 20px;
  font-size: 10px;
  color: var(--text-light);
  flex-shrink: 0;
}
.booking-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* Desktop responsive
   Gli orari non hanno più colonne fisse per breakpoint: le chip vanno a capo da sole
   (flex-wrap) e si adattano alla larghezza disponibile. */
@media (min-width: 600px) {
  .booking-card {
    padding: 36px 32px;
  }
}

/* Very small screens */
@media (max-width: 360px) {
  .booking-card {
    padding: 20px 16px;
  }
}

/* ===== Phone Verification Styles ===== */
.verify-instructions {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.phone-form,
.otp-form {
  margin-bottom: 16px;
}

.phone-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.phone-prefix-select {
  width: 110px;
  flex-shrink: 0;
  font-size: 14px;
}
.phone-number-input {
  flex: 1;
  min-width: 0;
}
.otp-input {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 8px;
  font-family: 'Courier New', monospace;
  margin-bottom: 12px;
}
.btn-verify {
  width: 100%;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-verify:hover:not(:disabled) {
  background: var(--primary-hover);
}
.btn-verify:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-verify:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.verify-status {
  margin-bottom: 16px;
}
.verify-status-pending {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: #FFF7ED;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #c2410c;
  font-weight: 500;
}
.verify-status-confirmed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: var(--success-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: #059669;
  font-weight: 600;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background: #f59e0b;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Too many people alert */
.too-many-alert {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, #FFF7ED 0%, #FEF3C7 100%);
  border: 1px solid #fbbf24;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 8px 0 14px 0;
  width: 100%;
  flex: 1 1 100%;
  box-sizing: border-box;
  /* Occupa l'intera riga anche dentro la griglia degli slot */
  grid-column: 1 / -1;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.12);
}
.too-many-alert span {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}
.too-many-alert p {
  font-size: 14px;
  color: #92400e;
  line-height: 1.5;
  margin: 0;
  flex: 1;
  text-align: left;
}
.too-many-alert strong {
  color: #78350f;
  font-weight: 700;
}

/* ── Waitlist slot button ── */
.time-slot.waitlist {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
  cursor: pointer;
  opacity: 1;
}
.time-slot.waitlist:hover {
  background: #fef3c7;
  border-color: #d97706;
}
.time-slot.waitlist.waitlist-selected {
  background: #f59e0b;
  color: #fff;
  border-color: #d97706;
  box-shadow: 0 2px 8px rgba(245,158,11,0.35);
}
.time-slot.waitlist small {
  font-size: 9px;
  display: block;
  margin-top: 2px;
  font-weight: 500;
}

/* Banner modalità lista d'attesa (nel form) */
.waitlist-mode-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 4px;
}
.waitlist-mode-cancel {
  background: none;
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 12px;
  font-family: inherit;
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-weight: 600;
  margin-left: auto;
}
.waitlist-mode-cancel:hover { background: #fef3c7; }

/* Step waitlist-confirmed */
.waitlist-position-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fffbeb;
  border: 2px solid #f59e0b;
  border-radius: 50px;
  padding: 10px 24px;
  font-size: 15px;
  color: #92400e;
  font-weight: 600;
  margin: 12px auto 20px;
}
.waitlist-position-badge strong {
  font-size: 28px;
  font-weight: 800;
  color: #d97706;
}

/* ── Room selection ── */
/* Sale: una card per riga (a tutta larghezza), con 2 colonne un numero dispari di
   sale lasciava un buco nell'ultima riga. Layout orizzontale per non allungare troppo. */
.room-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 4px;
}
.room-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  text-align: left;
}
.room-card:hover {
  border-color: #7c5cfc;
  box-shadow: 0 2px 12px rgba(124,92,252,0.18);
  transform: translateY(-2px);
}
.room-card.selected {
  border-color: #7c5cfc;
  background: #f5f3ff;
  box-shadow: 0 0 0 3px rgba(124,92,252,0.25);
}
.room-card-photo {
  width: 96px;
  height: 68px;
  flex-shrink: 0;
  object-fit: cover;
  display: block;
}
.room-card-icon {
  font-size: 1.9rem;
  line-height: 1;
  flex-shrink: 0;
  padding: 0 2px 0 16px;
}
.room-card-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  padding: 14px 16px;
  word-break: break-word;
  background: #fff;
}
.room-card.selected .room-card-name {
  color: #5b21b6;
  background: #f5f3ff;
}

