/* Aba Anamnese da ficha. Ver js/ui/anamnese.js.
   Três estados: vazio (convite a preencher), formulário (perguntas sim/não em
   toggle e dissertativas em textarea) e leitura (pares pergunta/resposta,
   sim/não com selo colorido). */

/* ------------------------------------------------------------ Vazio */
.vazio-anamnese { text-align: center; padding: 3rem 1.5rem; }
.vazio-anamnese::before {
  content: '📋';
  display: grid; place-items: center;
  width: 60px; height: 60px; margin: 0 auto 1.1rem;
  border-radius: 50%;
  background: var(--acento-claro);
  font-size: 1.7rem;
  box-shadow: var(--sombra-suave);
}
.vazio-anamnese h2 { margin-bottom: .4rem; }
.vazio-anamnese .nota { max-width: 38ch; margin: 0 auto 1.3rem; }

/* ------------------------------------------------------------ Cabeçalho (formulário e leitura) */
.cabecalho-formulario {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; margin-bottom: 1.3rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--borda);
}
.cabecalho-formulario h2 { font-size: 1.1rem; letter-spacing: -.01em; }
.cabecalho-formulario .nota { margin: .3rem 0 0; }
.cabecalho-formulario .link { font-weight: 600; font-size: .85rem; white-space: nowrap; }

/* ------------------------------------------------------------ Formulário: perguntas */
.campo-pergunta {
  position: relative;
  padding: 1.05rem 1.1rem 1.15rem 3.5rem;
  margin-bottom: .6rem;
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  background: var(--superficie);
  transition: border-color var(--transicao), box-shadow var(--transicao);
}
.formulario-anamnese .campo-pergunta:last-of-type { margin-bottom: 0; }
.campo-pergunta:hover { border-color: var(--borda-forte); }
.campo-pergunta:focus-within { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-claro); }

.num-pergunta {
  position: absolute; left: 1.05rem; top: 1.05rem;
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--acento-claro); color: var(--acento-forte);
  font-size: .74rem; font-weight: 700;
}

.texto-pergunta { display: block; font-weight: 600; line-height: 1.45; margin-bottom: .75rem; }
.campo-pergunta.tipo-simnao .texto-pergunta { margin-bottom: .85rem; }

textarea.campo-largo { margin-top: 0; }

/* Dissertativa: caixa larga (100% do cartão, que ocupa a largura da tela),
   com altura moderada — dá pra arrastar e crescer se precisar (resize
   vertical já vem do estilo base). */
.campo-pergunta.tipo-texto textarea.campo-largo {
  min-height: 130px;
}

/* ------------------------------------------------------------ Toggle sim/não */
.opcoes-simnao {
  display: inline-flex; gap: .2rem;
  background: var(--fundo); border: 1px solid var(--borda);
  border-radius: 999px; padding: .2rem;
}
.opcoes-simnao label {
  position: relative; display: flex; align-items: center; gap: .45rem;
  padding: .42rem 1.2rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--texto-suave);
  cursor: pointer; user-select: none;
  transition: background var(--transicao), color var(--transicao), box-shadow var(--transicao);
}
.opcoes-simnao input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0; margin: 0; pointer-events: none;
}
.opcoes-simnao label::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0; transition: opacity var(--transicao);
}
.opcoes-simnao label:hover { color: var(--texto); }
.opcoes-simnao label:has(input:checked) { background: var(--superficie); box-shadow: var(--sombra-suave); }
.opcoes-simnao label:has(input:checked)::before { opacity: .85; }
.opcoes-simnao label:has(input[value="sim"]:checked) { color: var(--verde); }
.opcoes-simnao label:has(input[value="nao"]:checked) { color: var(--vermelho); }
.opcoes-simnao label:has(input:focus-visible) { outline: 2px solid var(--acento); outline-offset: 2px; }

.acoes-rodape { margin-top: 1.2rem; }

/* ------------------------------------------------------------ Leitura */
.leitura-anamnese .par-leitura {
  display: flex; gap: 1rem;
  padding: .85rem 0; border-bottom: 1px solid var(--borda);
}
.leitura-anamnese .par-leitura:last-child { border-bottom: 0; }

.par-leitura.tipo-simnao { align-items: center; justify-content: flex-start; }
.par-leitura.tipo-texto { flex-direction: column; align-items: stretch; }

.par-leitura .texto-pergunta {
  margin-bottom: 0; font-weight: 500; color: var(--texto);
}
.par-leitura.tipo-texto .texto-pergunta { margin-bottom: .55rem; }

.resposta-leitura { font-weight: 600; }

.resposta-leitura.pilula {
  flex: none; text-align: center;
  padding: .32rem .9rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; letter-spacing: .01em;
  background: var(--fundo); color: var(--texto-suave);
}
.resposta-leitura.pilula.positiva { background: var(--verde-claro); color: var(--verde); }
.resposta-leitura.pilula.negativa { background: var(--vermelho-claro); color: var(--vermelho); }

.resposta-leitura.texto-resposta {
  font-weight: 400; line-height: 1.65; color: var(--texto);
  white-space: pre-wrap; width: 100%;
  background: var(--fundo); border-radius: var(--raio-peq);
  padding: .7rem .85rem;
}

.resposta-leitura.vazia {
  color: var(--texto-suave); font-weight: 400; font-style: italic;
}
.resposta-leitura.pilula.vazia { background: var(--fundo); color: var(--texto-suave); font-style: normal; }
.resposta-leitura.texto-resposta.vazia { background: none; padding: 0; }

@media (max-width: 560px) {
  .campo-pergunta { padding-left: 2.9rem; }
  .num-pergunta { width: 22px; height: 22px; font-size: .68rem; left: .85rem; top: .95rem; }
  .par-leitura.tipo-simnao { flex-wrap: wrap; row-gap: .5rem; }
}

/* ------------------------------------------------------------ Prévia de impressão */
/* Formatada como uma folha, sem cor/pílula — pensada pra ficar boa em papel. */
.modal.previa-impressao { width: min(720px, 100%); }

.folha-impressao {
  background: #fff; color: #1a1a1a;
  padding: .5rem .25rem 1.5rem; font-size: .95rem; line-height: 1.65;
}
.cabecalho-impressao {
  margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid #1a1a1a;
}
.cabecalho-impressao h1 { font-size: 1.4rem; color: #1a1a1a; margin-bottom: .35rem; }
.paciente-impressao { font-size: 1.05rem; font-weight: 700; margin: 0 0 .2rem; }
.meta-impressao { font-size: .82rem; color: #555; margin: 0; }

.item-impressao { margin-bottom: 1.1rem; break-inside: avoid; }
.pergunta-impressao { font-weight: 700; margin: 0 0 .3rem; }
.resposta-impressao { margin: 0; padding-left: .1rem; white-space: pre-wrap; }

@media print {
  body * { visibility: hidden; }
  .folha-impressao, .folha-impressao * { visibility: visible; }
  .folha-impressao { position: absolute; top: 0; left: 0; width: 100%; padding: 0; }
  .fundo-modal { position: static; background: none; inset: auto; }
  .modal.previa-impressao { box-shadow: none; border: 0; padding: 0; width: 100%; max-width: none; max-height: none; }
  .sem-impressao { display: none; }
}
