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

:root {
  --color-bg: #f5f7fa;
  --color-card: #ffffff;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #16a34a;
  --color-error: #dc2626;
  --color-text: #1e293b;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-input-bg: #f8fafc;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px 48px;
}

#app {
  width: 100%;
  max-width: 680px;
}

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Card ── */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-top: 24px;
}

/* ── Loading / spinner ── */
#screen-loading,
#screen-submitting {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 16px;
  color: var(--color-muted);
}
#screen-loading.active,
#screen-submitting.active { display: flex; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Success / Error cards ── */
.success-card,
.error-card {
  text-align: center;
  padding: 48px 32px;
}

.icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}
.success-card .icon { color: var(--color-success); }
.error-card .icon { color: var(--color-error); }

.success-card h1 { color: var(--color-success); }
.error-card h1 { color: var(--color-error); }

/* ── Progress bar ── */
.progress-bar {
  display: flex;
  align-items: center;
  margin-bottom: 28px;
}

.progress-step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.progress-step.active {
  background: var(--color-primary);
  color: #fff;
}
.progress-step.completed {
  background: var(--color-success);
  color: #fff;
}

.progress-line {
  flex: 1;
  height: 2px;
  background: var(--color-border);
  margin: 0 6px;
}
.progress-line.active {
  background: var(--color-success);
}

/* ── Typography ── */
h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--color-text);
}
h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 12px;
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
  padding-top: 20px;
}
h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--color-text);
}
.subtitle {
  color: var(--color-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ── Form layout ── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.hint {
  color: var(--color-muted);
  cursor: help;
  margin-left: 4px;
  font-size: 12px;
}

input[type="text"],
input[type="date"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-input-bg);
  font-size: 14px;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── Buttons ── */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--color-text); color: var(--color-text); }

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border: 2px dashed var(--color-primary);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  transition: background 0.15s;
}
.btn-secondary:hover { background: rgba(37, 99, 235, 0.05); }

.btn-remove {
  background: transparent;
  color: var(--color-error);
  border: none;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.btn-remove:hover { background: rgba(220, 38, 38, 0.08); }

/* ── Guest card (ospiti aggiuntivi) ── */
.guest-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  background: #fafbfd;
}

.guest-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ── Summary (riepilogo) ── */
.summary-guest {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 14px;
}

dt {
  color: var(--color-muted);
  font-weight: 500;
}

dd {
  color: var(--color-text);
  font-weight: 400;
}

/* ── Error ── */
.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--color-error);
  font-size: 14px;
  margin-top: 16px;
}

/* ── Autocomplete ── */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-dropdown.open {
  display: block;
}

.autocomplete-item {
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
  color: var(--color-text);
  transition: background 0.1s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-primary);
}

/* ── Language toggle ── */
.lang-toggle {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 4px;
}

.lang-btn {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  transition: border-color 0.15s, opacity 0.15s;
  opacity: 0.5;
}

.lang-btn.active {
  border-color: var(--color-primary);
  opacity: 1;
}

.lang-btn:hover {
  opacity: 0.85;
}

.hidden { display: none !important; }
