/* Area del paziente con il percorso attivo: schede in basso sul telefono, in alto sul computer */

.carta-p {
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
}
.vista__testa {
  display: grid;
  gap: 6px;
  margin: 8px 0 20px;
}
.vista__testa h1 {
  font-size: clamp(1.875rem, 6vw, 2.5rem);
  letter-spacing: -0.035em;
}
.vista__testa p {
  color: var(--muted);
}
.vista__testa--riga {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.vuoto-p {
  padding: 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink-2);
  list-style: none;
}
.invito-percorso {
  margin: 0 0 20px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--bosco-chiaro);
  color: var(--ink-2);
  font-size: 0.9375rem;
}
.link-testo {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

/* Consenso */
.consenso {
  display: grid;
  gap: 14px;
  max-width: 640px;
  margin: 8px 0 32px;
  padding: 24px;
}
.consenso h1 {
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  letter-spacing: -0.035em;
}
.consenso > p {
  color: var(--ink-2);
}

/* Schede */
.schede-p {
  display: flex;
}
.schede-p button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 550 0.9375rem var(--sans);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.schede-p button[hidden] {
  display: none;
}
.schede-p svg {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.schede-p button[aria-current="true"] {
  color: var(--ink);
}
.schede-p button.con-avviso {
  position: relative;
}
.schede-p button.con-avviso::after {
  content: "";
  position: absolute;
  top: 5px;
  right: calc(50% - 16px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ottone);
}
@media (max-width: 899px) {
  .schede-p {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
  }
  .schede-p button {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    min-height: 52px;
    padding: 6px 0 4px;
    font-size: 0.71875rem;
  }
  .schede-p button[aria-current="true"] svg {
    color: var(--bosco);
    stroke-width: 2.1;
  }
  /* Spazio per schede e pulsante WhatsApp: l'ultima riga resta leggibile */
  .con-schede .area {
    padding-bottom: calc(156px + env(safe-area-inset-bottom));
  }
  .con-schede.in-assistente .area {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  /* WhatsApp sale sopra le schede; nella chat si fa da parte */
  .con-schede .whatsapp {
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
  .in-assistente .whatsapp {
    opacity: 0;
    pointer-events: none;
  }
}
@media (min-width: 900px) {
  .schede-p {
    order: -1;
    position: sticky;
    top: 76px;
    z-index: 10;
    gap: 4px;
    width: max-content;
    margin: 0 0 24px;
    padding: 4px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
  }
  #contenuto-area {
    display: flex;
    flex-direction: column;
  }
  .schede-p button {
    padding: 8px 16px 8px 12px;
    border-radius: 999px;
  }
  .schede-p svg {
    width: 18px;
    height: 18px;
  }
  .schede-p button[aria-current="true"] {
    background: var(--bosco);
    color: #fff;
  }
  .vista {
    max-width: 820px;
  }
  #vista-visite {
    max-width: none;
  }
}

/* Piano */
.risposte-nuove {
  margin-bottom: 14px;
}
.materiali-p {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.materiale-p a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.materiale-p a:hover {
  border-color: var(--bosco);
}
.materiale-p__icona {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--bosco-chiaro);
  color: var(--bosco);
}
.materiale-p__icona svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.materiale-p__testo {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.materiale-p__testo small {
  color: var(--muted);
}
.materiale-p__apri {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bosco);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Andamento */
.chip-misure {
  display: flex;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter)) 14px;
  padding: 2px var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}
.chip-misure::-webkit-scrollbar {
  display: none;
}
.chip-misure button {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: 550 0.875rem var(--sans);
  cursor: pointer;
}
.chip-misure button[aria-pressed="true"] {
  border-color: var(--bosco);
  background: var(--bosco);
  color: #fff;
}
.grafico-p {
  padding: 18px 16px 10px;
}
.grafico-p__testa {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.grafico-p__testa > div {
  display: grid;
}
.grafico-p__testa strong {
  font-size: 1.75rem;
  font-weight: 550;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.grafico-p__testa span {
  color: var(--muted);
  font-size: 0.875rem;
}
.grafico-p__delta {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2) !important;
  font-weight: 550;
  white-space: nowrap;
}
#grafico-misura svg {
  display: block;
  width: 100%;
  height: auto;
}
#grafico-misura .linea {
  fill: none;
  stroke: var(--bosco);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#grafico-misura .area {
  fill: var(--bosco-chiaro);
  opacity: 0.7;
}
#grafico-misura circle {
  fill: var(--surface);
  stroke: var(--bosco);
  stroke-width: 2;
}
#grafico-misura circle.ultimo {
  fill: var(--bosco);
}
#grafico-misura text {
  fill: var(--muted);
  font: 500 12px var(--sans);
}
.valori-p {
  display: grid;
  margin: 14px 0 0;
  padding: 0 4px;
  list-style: none;
}
.valori-p li {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 0.9375rem;
}
.valori-p li + li {
  border-top: 1px solid var(--line);
}
.valori-p strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Messaggi */
.domanda-p {
  display: grid;
  gap: 12px;
  padding: 16px;
}
.domanda-p textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: 400 1rem/1.45 var(--sans);
  resize: vertical;
}
.domanda-p textarea:focus {
  outline: none;
  border-color: var(--bosco);
  box-shadow: 0 0 0 4px var(--bosco-chiaro);
}
.richieste-p {
  display: grid;
  gap: 12px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}
.richiesta-p {
  display: grid;
  gap: 8px;
}
.richiesta-p small {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78125rem;
}
.richiesta-p__domanda,
.richiesta-p__risposta {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.richiesta-p__domanda {
  justify-self: end;
  border-bottom-right-radius: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.richiesta-p__risposta {
  justify-self: start;
  border-bottom-left-radius: 6px;
  background: var(--bosco);
  color: #fff;
}
.richiesta-p__risposta small {
  color: var(--su-scuro);
}
.richiesta-p__attesa {
  justify-self: end;
  color: var(--muted);
  font-size: 0.8125rem;
}

/* Assistente */
.avviso-ia {
  position: sticky;
  top: 72px;
  z-index: 5;
  margin: -6px 0 14px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--ottone-chiaro);
  color: var(--ottone-scuro);
  font-size: 0.875rem;
  font-weight: 550;
}
.consenso-ia {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 20px;
  color: var(--ink-2);
}
.fumetti-p {
  display: grid;
  gap: 12px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}
.fumetto-p {
  max-width: min(100%, 640px);
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.fumetto-p--io {
  justify-self: end;
  max-width: 85%;
  border-bottom-right-radius: 6px;
  background: var(--bosco);
  color: #fff;
  white-space: pre-wrap;
}
.fumetto-p--ia {
  justify-self: start;
  border-bottom-left-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.fumetto-p--ia p + p,
.fumetto-p--ia p + ul,
.fumetto-p--ia ul + p {
  margin-top: 8px;
}
.fumetto-p--ia ul,
.fumetto-p--ia ol {
  margin: 0;
  padding-left: 20px;
}
.fumetto-p--errore {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 35%, transparent);
}
.rimando-p {
  display: grid;
  justify-items: start;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.rimando-p__ok {
  color: var(--ok);
  font-size: 0.875rem;
  font-weight: 550;
}
.rimando-p__errore {
  color: var(--error);
  font-size: 0.875rem;
}
.risorse-p {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: 0.9375rem;
  white-space: pre-line;
}
.puntini-p {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.puntini-p i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: puntino-p 1.2s infinite ease-in-out;
}
.puntini-p i:nth-child(2) {
  animation-delay: 0.15s;
}
.puntini-p i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes puntino-p {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}
.spunti-p {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.spunti-p[hidden] {
  display: none;
}
.spunti-p button {
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 500 0.9375rem/1.4 var(--sans);
  text-align: left;
  cursor: pointer;
}
.compositore-p {
  position: sticky;
  bottom: calc(76px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px -18px rgba(17, 26, 23, 0.45);
}
.compositore-p:focus-within {
  border-color: var(--bosco);
}
.compositore-p textarea {
  min-height: 40px;
  max-height: 160px;
  padding: 9px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 400 1rem/1.4 var(--sans);
  resize: none;
}
.compositore-p textarea:focus {
  outline: none;
}
.compositore-p__invia {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--bosco);
  color: #fff;
  cursor: pointer;
}
.compositore-p__invia svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.compositore-p__invia:disabled {
  opacity: 0.4;
}
.spegni-ia-p {
  margin: 14px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.8125rem;
}
.compositore-p__nota {
  grid-column: 1 / -1;
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 0.75rem;
}
@media (min-width: 900px) {
  .compositore-p {
    bottom: 20px;
  }
  .avviso-ia {
    top: 140px;
  }
}
