/* ============================================
   MESSICO SENZA STRESS — Styles v2
   ============================================ */

:root {
  --teal: #0D9488;
  --teal-dark: #0F766E;
  --teal-light: #F0FDFA;
  --teal-border: #99F6E4;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-800: #1F2937;
  --red: #EF4444;
  --red-light: #FEE2E2;
  --green: #10B981;
  --green-light: #D1FAE5;
  --amber: #F59E0B;
  --amber-light: #FEF3C7;
  --blue: #3B82F6;
  --blue-light: #DBEAFE;
  --radius: 12px;
}

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* Layout */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.header {
  background: var(--teal);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header h1 {
  color: white;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.header .subtitle {
  color: rgba(255,255,255,0.6);
  font-size: 11px;
  font-weight: 500;
}
/* Logo nell'intestazione — usato solo dove e' presente .header-logo,
   quindi il pannello admin resta invariato. */
.header-logo {
  height: 34px;
  width: auto;
  display: block;
}
@media (max-width: 480px) {
  .header-logo { height: 27px; }
}

/* Card */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--gray-200);
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}
.card-subtitle {
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 14px;
}

/* Forms */
label {
  display: block;
  font-size: 11px;
  color: var(--gray-500);
  margin-bottom: 3px;
  font-weight: 500;
}
label .required { color: var(--red); }
input[type="text"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: white;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-group { margin-bottom: 12px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--teal-dark); }
.btn-full { width: 100%; }
.btn-lg { padding: 13px 32px; font-size: 15px; font-weight: 700; border-radius: 9px; }
.btn-outline { background: var(--teal-light); color: var(--teal-dark); border: 1.5px solid var(--teal); }
.btn-sm { padding: 7px 14px; font-size: 12px; border-radius: 6px; }

/* Counter */
.counter { display: flex; align-items: center; gap: 10px; }
.counter-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--gray-200); background: white;
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600);
}
.counter-value {
  font-size: 18px; font-weight: 700; color: var(--teal);
  min-width: 24px; text-align: center;
}

/* Status badges */
.badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; margin-left: 8px;
}
.badge-generato { background: var(--amber-light); color: #D97706; }
.badge-compilato { background: var(--blue-light); color: var(--blue); }
.badge-confermato { background: var(--green-light); color: var(--green); }
.badge-scaricato { background: var(--gray-100); color: var(--gray-500); }

/* Excursion cards in admin */
.esc-card {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}
.esc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.esc-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal-dark);
}
.esc-card-subtitle {
  font-size: 11px;
  color: var(--gray-400);
}
.esc-card .form-grid { gap: 8px; }

/* Image upload / drop zone */
.drop-zone {
  border: 2px dashed var(--gray-200);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: white;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--teal);
  background: var(--teal-light);
}
.drop-zone-text {
  font-size: 12px;
  color: var(--gray-400);
}
.drop-zone-text strong {
  color: var(--teal);
}
.drop-zone.processing {
  border-color: var(--amber);
  background: var(--amber-light);
}
.drop-zone.done {
  border-color: var(--green);
  background: var(--green-light);
}

/* Escursion tags */
.esc-tag {
  display: inline-block; background: var(--teal-light); color: var(--teal-dark);
  padding: 3px 8px; border-radius: 4px; font-size: 11px; margin: 2px 3px 2px 0;
}

/* Summary boxes */
.summary-box {
  background: var(--teal-light); padding: 14px; border-radius: 8px; font-size: 13px;
}
.summary-row { display: flex; justify-content: space-between; margin-bottom: 3px; }
.summary-row:last-child { margin-bottom: 0; }
.summary-divider { padding-top: 6px; margin-top: 4px; border-top: 1px solid var(--teal-border); }

/* Booking card in admin list */
.booking-card {
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  padding: 13px 15px; margin-bottom: 10px; border-left-width: 4px;
}
.booking-card.status-compilato { background: #FEFCE8; }
.booking-link {
  font-size: 10px; color: var(--gray-500); font-family: monospace;
  background: var(--gray-50); padding: 4px 8px; border-radius: 5px;
  margin-bottom: 4px; word-break: break-all; cursor: pointer; transition: background 0.2s;
}
.booking-link:hover { background: var(--gray-200); }

/* Info box */
.info-box {
  background: var(--teal-light); padding: 9px 14px; border-radius: 8px;
  font-size: 13px; display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 14px;
}

/* State screens */
.state-screen { text-align: center; padding: 44px 20px; }
.state-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; font-size: 24px;
}
.state-icon-waiting { background: var(--amber-light); }
.state-icon-confirmed { background: var(--green-light); }
.state-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.state-text { font-size: 13px; color: var(--gray-600); line-height: 1.5; }

/* Voucher card on client page */
.voucher-card {
  background: white; border: 1.5px solid var(--gray-200);
  border-radius: 12px; overflow: hidden; margin-bottom: 14px;
}
.voucher-header {
  background: var(--teal); padding: 12px 18px;
  display: flex; justify-content: space-between; align-items: center;
}
.voucher-header h3 { color: white; font-size: 14px; font-weight: 700; letter-spacing: 0.5px; }
.voucher-body { padding: 16px 18px; }
.voucher-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: var(--gray-50); padding: 12px; border-radius: 8px; font-size: 12px;
}
.voucher-label { font-size: 9px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }

/* PIN overlay */
.pin-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.pin-box {
  background: white; padding: 28px 26px; border-radius: 16px;
  text-align: center; max-width: 380px; width: 92%;
}
.pin-box h2 { font-size: 18px; color: var(--teal); margin-bottom: 4px; }
.pin-box p { font-size: 13px; color: var(--gray-500); margin-bottom: 16px; }

/* I campi di accesso sono testo normale: l'email deve leggersi tutta.
   Solo il codice a sei cifre resta grande e distanziato. */
.pin-box input {
  width: 100%; box-sizing: border-box;
  font-size: 14px; text-align: left; letter-spacing: normal;
  padding: 11px 12px; margin-bottom: 10px;
  border: 1px solid var(--gray-200); border-radius: 10px;
  font-family: inherit; color: var(--gray-800); background: #fff;
}
.pin-box input:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-light);
}
.pin-box input::placeholder { color: var(--gray-400); letter-spacing: normal; }

/* Password con il pulsante per vedere quello che si sta scrivendo */
.campo-password { position: relative; }
.campo-password input { padding-right: 44px; }
.occhio {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  margin-top: -5px;
  width: 32px; height: 32px; border: none; background: none; cursor: pointer;
  color: var(--gray-400); display: flex; align-items: center; justify-content: center;
  border-radius: 8px; padding: 0;
}
.occhio:hover { color: var(--gray-600); background: var(--gray-100); }
.occhio:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.occhio svg { width: 18px; height: 18px; }

/* Il codice arriva per email: sei cifre, larghe e leggibili */
/* La lunghezza del codice la decide Supabase: sei o otto cifre.
   Niente spaziatura fissa, cosi non va mai a capo ne si taglia. */
#codiceInput {
  text-align: center; font-size: 22px; letter-spacing: 4px;
  padding: 13px 12px; font-variant-numeric: tabular-nums;
}
#codiceInput::placeholder { font-size: 14px; letter-spacing: normal; }

.pin-box .btn-full { margin-top: 4px; }

/* I due modi alternativi di entrare restano leggibili ma non competono
   col pulsante principale */
.pin-box .alt-accesso { margin-top: 14px; font-size: 12.5px; }
.pin-box .alt-accesso a { color: var(--gray-500); text-decoration: none; }
.pin-box .alt-accesso a:hover { color: var(--teal); text-decoration: underline; }
.pin-box .alt-accesso + .alt-accesso { margin-top: 6px; }

/* Remove button */
.btn-remove {
  width: 24px; height: 24px; border-radius: 50%; border: none;
  background: var(--red-light); color: var(--red); cursor: pointer;
  font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Price input */
.price-input {
  width: 60px !important; padding: 5px 7px !important; font-size: 13px !important;
  font-weight: 600; text-align: center;
  border: 1.5px solid var(--gray-200) !important; border-radius: 6px !important;
}

/* Loading spinner */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--gray-200);
  border-top-color: var(--teal); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
/* Niente nowrap: gli avvisi lunghi uscivano dallo schermo tagliati a
   meta' da tutte e due le parti, e il messaggio non si leggeva. */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-800); color: white; padding: 12px 20px;
  border-radius: 10px; font-size: 14px; font-weight: 500; z-index: 300;
  transition: transform 0.3s ease;
  width: max-content; max-width: min(92vw, 520px);
  text-align: center; line-height: 1.45;
}
.toast.show { transform: translateX(-50%) translateY(0); }
/* Con la barra di salvataggio aperta l'avviso le sta sopra, non dietro. */
body.con-barra .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }

/* Responsive */
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
  .header h1 { font-size: 14px; }
}

/* Utility */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state .icon { font-size: 32px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; }
.text-teal { color: var(--teal); }
.text-amber { color: var(--amber); }
.text-green { color: var(--green); }
.text-gray { color: var(--gray-400); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }


/* Pratica senza link ricomponibile: si genera, non si copia */
.booking-link-assente {
  font-family: inherit; font-size: 13px; letter-spacing: normal;
  color: var(--teal); font-weight: 500; text-align: center;
  border: 1px dashed var(--teal-border); background: var(--teal-light);
}
.booking-link-assente:hover { background: #E6FFFA; }
