/* ============================================================
   eSIM onboarding — stile
   Palette: blu (telefonia/fiducia) + verde (energia) = i due servizi
   ============================================================ */

:root {
  --brand:        #1B4D8F;
  --brand-dark:   #0E2F5C;
  --brand-tint:   #EAF1FB;
  --energy:       #00B87C;
  --energy-dark:  #009A67;
  --energy-tint:  #E4F7F0;

  --ink:          #0F1B2D;
  --ink-soft:     #44546B;
  --muted:        #6B7A90;
  --line:         #E3E9F2;
  --bg:           #EEF3FA;
  --card:         #FFFFFF;
  --danger:       #C8462F;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;

  --shadow: 0 10px 30px -12px rgba(14, 47, 92, 0.28);
  --shadow-sm: 0 2px 10px -4px rgba(14, 47, 92, 0.20);

  --maxw: 460px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* App shell — colonna centrata in stile telefono */
.app {
  max-width: var(--maxw);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--card);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  position: relative;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; }

.brand__logo {
  height: 26px;
  width: auto;
  display: block;
}

/* Indicatore "segnale" = avanzamento */
.signal { display: flex; align-items: flex-end; gap: 4px; height: 22px; }
.signal i {
  width: 5px;
  border-radius: 3px;
  background: var(--line);
  transition: background .35s ease, transform .35s ease;
}
.signal i:nth-child(1) { height: 8px; }
.signal i:nth-child(2) { height: 12px; }
.signal i:nth-child(3) { height: 16px; }
.signal i:nth-child(4) { height: 19px; }
.signal i:nth-child(5) { height: 22px; }
.signal i.on { background: linear-gradient(var(--energy), var(--energy-dark)); }

/* ---------- Banner installazione ---------- */
.install-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--brand-dark);
  color: #fff;
}
.install-bar[hidden] { display: none; }
.install-bar__icon {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.14);
  display: grid; place-items: center;
  color: #fff;
}
.install-bar__text { flex: 1; font-size: 13px; line-height: 1.38; }
.install-bar__text b { font-weight: 700; }
.install-bar__btn {
  flex: none;
  background: linear-gradient(135deg, var(--energy), var(--energy-dark));
  color: #fff; border: none; border-radius: 8px;
  padding: 8px 15px;
  font-family: "Inter", sans-serif;
  font-weight: 600; font-size: 13.5px;
  cursor: pointer; white-space: nowrap;
}
.install-bar__btn:active { transform: translateY(1px); }
.install-bar__close {
  flex: none;
  background: transparent; border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 24px; line-height: 1;
  cursor: pointer; padding: 0 2px;
}
.install-bar__close:hover { color: #fff; }

/* ---------- Screens ---------- */
.screens { flex: 1; display: flex; position: relative; }

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  width: 100%;
  animation: fade .35s ease both;
}
.screen.is-active { display: flex; }

@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.screen__body {
  flex: 1;
  padding: 26px 22px 16px;
  overflow-y: auto;
}
.screen__body--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  gap: 4px;
}

.screen__foot {
  padding: 14px 22px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
  display: flex;
  gap: 10px;
  flex-direction: column;
}
.screen__foot .btn--ghost + .btn--primary,
.screen__foot .btn--primary + .btn--ghost { margin: 0; }
/* due bottoni affiancati */
.screen[data-screen="data"] .screen__foot,
.screen[data-screen="document"] .screen__foot {
  flex-direction: row-reverse;
}
.screen[data-screen="data"] .btn,
.screen[data-screen="document"] .btn { flex: 1; }

/* ---------- Tipografia di contenuto ---------- */
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--energy-dark);
  margin: 0 0 10px;
}

.title {
  font-family: "Sora", sans-serif;
  font-weight: 800;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 12px;
}
.title--sm { font-size: 24px; }

.lede {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 20px;
}

/* ---------- Welcome ---------- */
.phone-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--brand-tint);
  border: 1px solid #D6E3F6;
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.phone-pill__label { font-size: 13px; color: var(--brand); font-weight: 500; }
.phone-pill__num {
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--brand-dark);
  letter-spacing: 0.01em;
}

.ticks { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.ticks li {
  position: relative;
  padding-left: 30px;
  font-size: 14.5px;
  color: var(--ink-soft);
}
.ticks li::before {
  content: "";
  position: absolute;
  left: 0; top: 1px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--energy-tint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2300B87C' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17 19 7'/%3E%3C/svg%3E") center/12px no-repeat;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--r-md);
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 16px;
  padding: 16px 20px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
  width: 100%;
}
.btn:active { transform: translateY(1px) scale(0.997); }

.btn--primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(27, 77, 143, 0.7);
}
.btn--primary:disabled {
  background: #C3CEDE;
  color: #fff;
  box-shadow: none;
  cursor: not-allowed;
}
.btn--ghost {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--line);
}

.microcopy {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  margin: 2px 0 0;
}

/* ---------- Dropzone documento ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 32px 20px;
  border: 2px dashed #C2D2E8;
  border-radius: var(--r-lg);
  background: var(--brand-tint);
  color: var(--brand);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.dropzone:hover { border-color: var(--brand); background: #E2EDFB; }
.dropzone__icon { color: var(--brand); margin-bottom: 2px; }
.dropzone__title { font-weight: 600; font-size: 16px; color: var(--ink); }
.dropzone__hint { font-size: 13px; color: var(--muted); max-width: 260px; }

.reading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--energy-tint);
  color: var(--energy-dark);
  font-weight: 500;
  font-size: 14.5px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(0, 184, 124, 0.3);
  border-top-color: var(--energy-dark);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.note { font-size: 13px; color: var(--muted); margin-top: 18px; }
.note--lock { position: relative; padding-left: 22px; }
.note--lock::before {
  content: "";
  position: absolute; left: 0; top: 1px;
  width: 15px; height: 15px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%236B7A90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* ---------- Riquadri documento (fronte/retro) ---------- */
.doc-slots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 6px 0 14px;
}
.doc-slot {
  border: 2px dashed #C2D2E8;
  border-radius: var(--r-md);
  background: var(--brand-tint);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color .2s ease, background .2s ease;
}
.doc-slot:hover { border-color: var(--brand); }
.doc-slot.done {
  border-style: solid;
  border-color: var(--energy);
  background: var(--energy-tint);
}
.doc-slot__preview {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 9px;
  background: #fff center / cover no-repeat;
  display: grid;
  place-items: center;
  color: var(--brand);
  overflow: hidden;
  border: 1px solid #E2E8F2;
}
.doc-slot.done .doc-slot__preview { border-color: transparent; }
.doc-slot__preview.has-img svg { display: none; }
.doc-slot__label { font-weight: 600; font-size: 14px; color: var(--ink); }
.doc-slot__status { font-size: 12px; color: var(--muted); line-height: 1.2; }
.doc-slot.done .doc-slot__status { color: var(--energy-dark); font-weight: 600; }

.doc-hint { font-size: 13px; color: var(--muted); margin: 0 0 4px; }

.build-tag {
  font-size: 11px;
  color: #AEB9CA;
  text-align: center;
  margin: 24px 0 0;
  letter-spacing: 0.04em;
}

/* ---------- Form ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.field input {
  font-family: "Inter", sans-serif;
  font-size: 15.5px;
  color: var(--ink);
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: #FBFCFE;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(27, 77, 143, 0.14);
  background: #fff;
}

/* ---------- Consensi ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--energy-tint);
  border: 1px solid #BEE9D8;
  color: #0B6B4A;
  border-radius: var(--r-md);
  padding: 13px 15px;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 18px;
}
.banner__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--energy);
  flex: none;
  box-shadow: 0 0 0 4px rgba(0, 184, 124, 0.18);
}

.consent {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 15px;
  margin-bottom: 10px;
  background: var(--card);
  transition: border-color .15s ease, background .15s ease;
}
.consent--required {
  border-color: #CFE0F5;
  background: var(--brand-tint);
}
.consent__tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand);
  background: #D7E5F9;
  border-radius: 6px;
  padding: 3px 8px;
  margin-bottom: 10px;
}

.consent-divider {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 20px 0 12px;
}

/* checkbox custom */
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
  flex: none;
  width: 22px; height: 22px;
  border: 2px solid #B9C7DC;
  border-radius: 7px;
  background: #fff;
  margin-top: 1px;
  display: grid;
  place-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.check__box::after {
  content: "";
  width: 12px; height: 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 10 17 19 7'/%3E%3C/svg%3E") center/contain no-repeat;
  transform: scale(0);
  transition: transform .15s ease;
}
.check input:checked + .check__box {
  background: var(--brand);
  border-color: var(--brand);
}
.check input:checked + .check__box::after { transform: scale(1); }
.check input:focus-visible + .check__box {
  box-shadow: 0 0 0 3px rgba(27, 77, 143, 0.22);
}
.check__text { font-size: 14.5px; line-height: 1.5; color: var(--ink-soft); }

.link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Done ---------- */
.done-mark {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--energy) 0%, var(--energy-dark) 100%);
  display: grid; place-items: center;
  margin-bottom: 18px;
  box-shadow: 0 12px 28px -10px rgba(0, 184, 124, 0.7);
  animation: pop .4s ease both;
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.recap {
  margin-top: 22px;
  width: 100%;
  text-align: left;
  display: grid;
  gap: 8px;
}
.recap__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  background: #F5F8FC;
  border: 1px solid var(--line);
}
.recap__row b { font-weight: 600; color: var(--ink); }
.recap__val { font-weight: 600; }
.recap__val.yes { color: var(--energy-dark); }
.recap__val.no { color: var(--muted); }

/* ---------- Accessibilità ---------- */
.btn:focus-visible,
.dropzone:focus-visible,
.link:focus-visible {
  outline: 3px solid rgba(27, 77, 143, 0.4);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
