/*
 * Design system e layout del portale.
 * I componenti dinamici usano classi generate da app.js; prima di rinominare un
 * selettore verificare le occorrenze sia in index.html sia nel JavaScript.
 */
:root {
  --green: #2ebf91;
  --green-dark: #16996f;
  --blue: #1a3a5c;
  --ink: #183047;
  --muted: #657789;
  --line: #dce5e8;
  --surface: #ffffff;
  --background: #f2f7f6;
  --danger: #b64040;
  --warning: #9a6a00;
  font-family: "Comfortaa", system-ui, sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px clamp(18px, 5vw, 64px);
  background: var(--blue);
  color: white;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; opacity: .78; font-size: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--green);
  color: var(--blue);
  font-weight: 700;
}

.shell { width: min(1080px, calc(100% - 28px)); margin: 28px auto 80px; }
.site-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 18px 32px;
  color: var(--muted);
  font-size: 12px;
}
.site-footer a { color: var(--blue); }
.panel, .progress-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 35px rgba(26, 58, 92, .07);
  padding: clamp(20px, 4vw, 38px);
}

.hidden { display: none !important; }
.badge { font-size: 12px; opacity: .85; }
h1, h2, h3 { color: var(--blue); margin-top: 0; }
h2 { font-size: clamp(21px, 3vw, 29px); }
h2 small { display: block; margin-top: 7px; color: var(--muted); font-size: 13px; font-weight: 400; }
p { line-height: 1.55; }

.progress-card { margin-bottom: 18px; padding: 20px 24px; }
.progress-card > div:first-child { display: flex; justify-content: space-between; }
.progress { height: 9px; margin-top: 10px; border-radius: 999px; background: #e6efed; overflow: hidden; }
.progress i { display: block; width: 0; height: 100%; background: var(--green); transition: width .25s ease; }
#statusText { margin: 10px 0 0; color: var(--muted); font-size: 13px; }

.steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(115px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding: 3px 0 14px;
}

.step {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 11px;
  color: var(--muted);
  cursor: pointer;
}
.step.active { border-color: var(--green); color: var(--blue); box-shadow: inset 0 -3px 0 var(--green); }
.step.done { background: #eaf8f3; color: var(--green-dark); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.span-2 { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--blue); font-size: 13px; font-weight: 700; }
.privacy-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
  font-weight: 400;
}
.privacy-consent input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: 0 0 auto;
}
.privacy-consent a { color: var(--blue); font-weight: 700; }
input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #bdcbd0;
  border-radius: 10px;
  color: var(--ink);
  background: white;
  font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(46, 191, 145, .18); border-color: var(--green); }
textarea { min-height: 105px; resize: vertical; }
input[readonly] { background: #eef3f5; color: #4c6172; }
.hint { margin: -2px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; }
.notice { grid-column: 1 / -1; border-left: 4px solid var(--green); padding: 12px 14px; background: #eff9f6; border-radius: 8px; font-size: 13px; }
.notice.warning { border-color: #f0ad32; background: #fff8e8; color: var(--warning); }
.notice.danger { border-color: var(--danger); background: #fff0f0; color: var(--danger); }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; border-top: 1px solid var(--line); padding-top: 20px; }
button, .button-link {
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.primary { background: var(--green); color: #0d3141; font-weight: 700; }
.primary:hover { background: #45d2a5; }
.secondary { background: #e9eff2; color: var(--blue); }
button:disabled { cursor: wait; opacity: .55; }

.section-intro { margin-top: -8px; color: var(--muted); }
.document-table { display: grid; gap: 12px; }
.document-table-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.document-cell {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfd;
}
.document-cell.optional { border-style: dashed; }
.document-cell-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; min-height: 38px; }
.document-cell-title span { padding: 4px 7px; border-radius: 999px; background: #eaf8f3; color: var(--green-dark); font-size: 10px; white-space: nowrap; }
.document-cell.optional .document-cell-title span { background: #eef3f5; color: var(--muted); }
.upload-policy { margin-bottom: 16px; line-height: 1.55; }
.upload-note { display: block; min-height: 30px; color: var(--green-dark); font-size: 11px; line-height: 1.4; }
.document-cell input[type="file"] { padding: 9px; font-size: 11px; }
.document-cell-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.document-status { font-size: 12px; color: var(--muted); }
.document-status.ok { color: var(--green-dark); font-weight: 700; }

.repeat-card { grid-column: 1 / -1; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.repeat-head, .repeat-row { display: grid; grid-template-columns: 2fr 1fr .8fr 1.15fr auto; gap: 10px; }
.repeat-head { margin-top: 12px; color: var(--muted); font-size: 11px; }
.repeat-row { margin-top: 7px; }
.string-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbfb; }
.string-card-title { display: flex; justify-content: space-between; gap: 12px; }
.string-card-title .ok { color: var(--green-dark); }
.string-card-title .error { color: var(--danger); }
.string-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.mandate-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px; border: 1px solid #b8e5d7; border-radius: 14px; background: #eff9f6; }
.mandate-card p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.map-address { display: grid; gap: 12px; }
.address-autocomplete > * { width: 100%; }
.site-map { min-height: 390px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #e9eff2; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.summary-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbfb; }
.summary-card h3 { margin-bottom: 10px; font-size: 15px; }
.summary-card p { margin: 6px 0; color: var(--muted); font-size: 13px; }
.summary-actions { justify-content: flex-start; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 13px 16px;
  border-radius: 11px;
  background: var(--blue);
  color: white;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.duplicate-dialog {
  width: min(620px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(15, 40, 60, .28);
}
.duplicate-dialog::backdrop { background: rgba(16, 38, 56, .58); }
.dialog-content { padding: clamp(22px, 5vw, 36px); }
.duplicate-details { display: grid; gap: 8px; margin: 18px 0; padding: 14px; border-radius: 12px; background: #f2f7f6; }
.duplicate-details div { display: flex; justify-content: space-between; gap: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .document-table-row, .repeat-row, .string-grid, .summary-grid { grid-template-columns: 1fr; }
  .repeat-head { display: none; }
  .mandate-card { align-items: stretch; flex-direction: column; }
  .site-map { min-height: 320px; }
  .duplicate-details div { align-items: flex-start; flex-direction: column; gap: 3px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  #nextButton { grid-column: 1 / -1; }
}
