/* Design system esportato da pen.dev - Parrocchia Maria Ausiliatrice */
@import url('https://fonts.googleapis.com/css2?family=Funnel+Sans:wght@300..800&family=Inter:wght@100..900&display=swap');

:root {
  --cream: #fff9f2;
  --panel: #344b45;      /* verde scuro */
  --accent: #d86f4b;     /* arancio */
  --accent-dark: #c25f3d;
  --card: #ffffff;
  --input-bg: #fff1e4;
  --text: #344b45;
  --muted: #687871;
  --faint: #a99f94;
  --step-off: #f6e5d7;
  --border: #f0e6da;
  --ok: #2f7d5b;
  --warn: #b8860b;
  --danger: #c0492f;
  --radius: 16px;
  --radius-sm: 9px;
  --sans: 'Funnel Sans', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--body); background: var(--cream); color: var(--text); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; font-weight: 700; }
h1, h2, h3 { font-family: var(--sans); margin: 0; }

/* ---------- Layout iscrizione: due colonne ---------- */
.split { display: flex; min-height: 100vh; }
.split .aside {
  background: var(--panel); color: #fff; padding: 48px; width: 410px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 20px;
}
.split .aside .brand { font-family: var(--sans); font-weight: 700; font-size: 21px; height: 24px; display: flex; align-items: center; }
.split .aside h1 { font-size: 42px; line-height: 1.05; margin-top: 40px; }
.split .aside p { color: #ffffffb8; font-size: 16px; margin: 0; }
.split .aside .spacer { flex: 1; }
.split .aside .help { color: #ffffffb8; font-size: 13px; }
.split .form-col { flex: 1; background: var(--card); padding: 48px 70px; }

@media (max-width: 820px) {
  .split { flex-direction: column; }
  .split .aside { width: auto; padding: 32px 24px; }
  .split .aside h1 { font-size: 30px; margin-top: 20px; }
  .split .form-col { padding: 28px 22px; }
  /* su mobile i campi in riga vanno in colonna: niente sforamento */
  .row .field { flex: 1 1 100%; min-width: 0; }
}

.container { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }

/* ---------- Testi ---------- */
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin: 30px 0 12px; color: var(--text); }
h3 { font-size: 1rem; }
.lead { color: var(--muted); margin: 0 0 24px; }
.hint { font-size: 0.8rem; color: var(--faint); margin-top: 4px; }

/* ---------- Card ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.form-col .card { box-shadow: none; border-color: var(--border); }

/* ---------- Campi ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 7px; }
.field input[type=text], .field input[type=email], .field input[type=tel],
.field input[type=date], .field input[type=password], .field select, .field textarea {
  width: 100%; padding: 13px 14px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: 14px; font-family: var(--body); background: var(--input-bg); color: var(--text);
}
.field input::placeholder { color: var(--faint); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); background: #fff;
}
.field input[type=file] {
  font-size: 13px; color: var(--muted); background: var(--input-bg);
  border-radius: var(--radius-sm); padding: 8px 10px; border: 1px solid transparent;
}
.field input[type=file]::file-selector-button {
  font-family: var(--body); font-size: 13px; font-weight: 700; color: #fff;
  background: var(--accent); border: none; border-radius: 8px; padding: 8px 14px;
  margin-right: 12px; cursor: pointer;
}
.field input[type=file]::file-selector-button:hover { background: var(--accent-dark); }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 170px; }
/* i date/time nativi hanno una larghezza minima propria: evita lo sforamento */
.field input[type=date] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; }

/* Autocomplete comuni */
.autocomplete { position: relative; }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 4px; box-shadow: 0 8px 24px rgba(52, 75, 69, .12); z-index: 30; max-height: 230px; overflow-y: auto; }
.ac-list div { padding: 10px 14px; font-size: 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.ac-list div:hover, .ac-list div.sel { background: var(--input-bg); }
.ac-list .prov { color: var(--faint); font-size: 12px; }

.check { display: flex; align-items: flex-start; gap: 9px; margin: 7px 0; font-size: 14px; color: var(--text); }
.check input { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; accent-color: var(--accent); }
.radio-group { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Sacramenti: scelta esplicita Sì/No ---------- */
.sacramento { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.sac-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sac-nome { font-size: 14px; font-weight: 700; color: var(--text); }
.sac-cert { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.sac-cert > span { font-size: 13px; color: var(--muted); }
.segmented { display: inline-flex; background: var(--input-bg); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented button { border: none; background: transparent; color: var(--muted); font-family: var(--body);
  font-size: 13px; font-weight: 700; padding: 7px 16px; border-radius: 999px; cursor: pointer; }
.segmented button.active { background: var(--accent); color: #fff; }
.segmented[data-f-group$="_ricevuta"] button.active[data-val="0"] { background: var(--panel); color: #fff; }

/* ---------- Bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: #fff;
  border: none; padding: 13px 18px; border-radius: 10px; font-size: 14px; font-weight: 700;
  font-family: var(--body); cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: var(--input-bg); color: var(--text); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 10px; }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Blocco bambino ---------- */
.bambino-block { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; position: relative; background: #fffdfb; }
.bambino-block .rimuovi { position: absolute; top: 14px; right: 12px; }
.bambino-block h3 { margin-bottom: 14px; }

/* ---------- Step indicator ---------- */
.steps { display: flex; gap: 18px; margin-bottom: 26px; align-items: center; min-height: 24px; }
.step { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.step .num { width: 24px; height: 24px; border-radius: 50%; background: var(--step-off); color: var(--faint);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.step.active .num { background: var(--accent); color: #fff; }
.step .lbl { color: var(--faint); font-weight: 400; }
.step.active .lbl { color: var(--text); font-weight: 700; }

/* ---------- Alert codice fiscale ---------- */
.cf-alert { margin-top: 8px; font-size: 12.5px; line-height: 1.45; padding: 9px 12px; border-radius: var(--radius-sm); }
.cf-alert.warn { background: #fdf0d8; color: #8a6100; border: 1px solid #f2d79b; }
.cf-alert.info { background: #e9f1fb; color: #2b5a9e; border: 1px solid #cadcf3; }
.cf-alert.muted { background: var(--input-bg); color: var(--muted); }
.cf-alert a { font-weight: 700; }

/* ---------- Alert ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert.error { background: #fbeae4; color: var(--danger); }
.alert.ok { background: #e6f4ec; color: var(--ok); }

/* ---------- Badge ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.in_attesa { background: #fdf0d8; color: var(--warn); }
.badge.confermata { background: #e0f2e8; color: var(--ok); }
.badge.annullata { background: #fbeae4; color: var(--danger); }

/* ---------- Dashboard ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { background: var(--panel); width: 236px; flex-shrink: 0; padding: 28px; color: #fff; display: flex; flex-direction: column; gap: 26px; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-weight: 700; font-size: 20px; }
.sidebar .brand .mark { width: 28px; height: 28px; border-radius: 8px; background: #ffe4cc; }
.sidebar nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #ffffffb8; font-weight: 400; font-size: 14px; }
.sidebar nav a.active { background: #ffffff1c; color: #fff; font-weight: 700; }
.sidebar .who { margin-top: auto; font-size: 13px; color: #ffffffb8; }
.sidebar .who strong { color: #fff; display: block; }

.main { flex: 1; padding: 34px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.topbar h1 { font-size: 26px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat .n { font-size: 30px; font-weight: 700; font-family: var(--sans); }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-family: var(--body); font-size: 14px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #fbf4ec; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fffdfb; cursor: pointer; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .who { margin: 0; }
  .main { padding: 22px 18px; }
}

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(52, 75, 69, .45); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 50; }
.modal-back.open { display: flex; }
.modal { background: var(--card); border-radius: var(--radius); max-width: 660px; width: 100%; padding: 26px; }
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; font-size: 14px; }
.dl dt { color: var(--muted); }
.hidden { display: none; }
