/**
 * Aparência do formulário renderizado.
 * Todas as cores vêm das variáveis --f-* geradas por shared/theme.js, então este
 * arquivo serve tanto a página pública quanto o preview dentro do editor.
 */

/* A página pública carrega só este arquivo — sem ele, `width: 100%` nos campos
   somaria padding e borda por cima e todo input estouraria a caixa do cartão. */
*, *::before, *::after { box-sizing: border-box; }

.fx-body {
  margin: 0;
  background: var(--f-bg);
  color: var(--f-text);
  font-family: var(--f-font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.fx-scope {
  background: var(--f-bg);
  color: var(--f-text);
  font-family: var(--f-font);
}

.fx-app { min-height: 100vh; }

/* Largura vem do tema (--f-width, ver LARGURAS em shared/theme.js). O 720px do
   fallback é o valor histórico, para o CSS continuar certo se o <style> do tema
   não carregar. */
.fx-wrap {
  max-width: var(--f-width, 720px);
  margin: 0 auto;
  padding: 28px 18px 120px;
}
.fx-wrap.centro { text-align: center; }
.fx-wrap.centro .fx-pergunta,
.fx-wrap.centro .fx-opcoes,
.fx-wrap.centro .fx-cabecalho { text-align: left; }
.fx-wrap.centro .fx-cabecalho-topo { align-items: center; text-align: center; }

/* --------------------------------------------------------------- capa */

.fx-capa {
  width: 100%;
  border-radius: var(--f-radius-block);
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--f-primary-soft);
}
.fx-capa img { display: block; width: 100%; height: 100%; object-fit: cover; }

.fx-logo {
  display: block;
  max-height: 60px;
  max-width: 220px;
  object-fit: contain;
  margin-bottom: 16px;
}
.fx-wrap.centro .fx-logo { margin-left: auto; margin-right: auto; }

/* ---------------------------------------------------------- cabeçalho */

.fx-cabecalho {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius-block);
  box-shadow: var(--f-shadow);
  padding: 26px 26px 24px;
  margin-bottom: 16px;
  border-top: 4px solid var(--f-primary);
}
.fx-titulo {
  margin: 0;
  font-size: clamp(22px, 4.6vw, 30px);
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.fx-descricao {
  margin: 10px 0 0;
  color: var(--f-text-muted);
  font-size: 15.5px;
  white-space: pre-wrap;
}
.fx-obrigatorias-nota {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--f-text-muted);
}
.fx-obrigatorias-nota b { color: var(--f-error); }

/* ---------------------------------------------------------- progresso */

.fx-progresso {
  position: sticky;
  top: 0;
  z-index: 12;
  padding: 10px 0 14px;
  background: linear-gradient(var(--f-bg) 72%, transparent);
}
.fx-progresso-trilha {
  height: 6px;
  border-radius: 999px;
  background: var(--f-border);
  overflow: hidden;
}
.fx-progresso-barra {
  height: 100%;
  width: 0%;
  background: var(--f-primary);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.fx-progresso-texto {
  margin: 7px 0 0;
  font-size: 12.5px;
  color: var(--f-text-muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* -------------------------------------------------------------- seção */

.fx-secao-cabeca {
  margin: 26px 0 12px;
  padding: 0 4px;
}
.fx-secao-titulo {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.fx-secao-desc {
  margin: 5px 0 0;
  color: var(--f-text-muted);
  font-size: 14.5px;
  white-space: pre-wrap;
}

/* ------------------------------------------------------------ pergunta */

.fx-pergunta {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius-block);
  box-shadow: var(--f-shadow);
  padding: 22px 24px;
  margin-bottom: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  animation: fx-entrada 0.28s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes fx-entrada {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.fx-pergunta.com-erro { border-color: var(--f-error); }

.fx-pergunta-cabeca { margin-bottom: 14px; }

.fx-pergunta-titulo {
  display: block;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}
.fx-obrig { color: var(--f-error); margin-left: 4px; font-weight: 700; }

.fx-pergunta-desc,
.fx-pergunta-dica {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--f-text-muted);
  white-space: pre-wrap;
}
.fx-pergunta-dica { font-style: italic; }

.fx-pergunta-erro {
  margin: 9px 0 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--f-error);
  min-height: 0;
}
.fx-pergunta-erro:empty { display: none; }

/* -------------------------------------------------------------- campos */

.fx-input {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: var(--f-text);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.fx-input::placeholder { color: var(--f-text-muted); opacity: 0.85; }
.fx-input:focus { box-shadow: 0 0 0 3px var(--f-primary-soft); }
.fx-input:disabled { opacity: 0.65; cursor: not-allowed; }
textarea.fx-input { resize: vertical; min-height: 92px; }

.fx-select { appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.fx-com-unidade { display: flex; align-items: center; gap: 10px; }
.fx-com-unidade .fx-input { flex: 1; }
.fx-unidade { color: var(--f-text-muted); font-size: 14.5px; white-space: nowrap; }

/* ------------------------------------------------------------- opções */

.fx-opcoes { display: grid; gap: 8px; }

/* Disposição escolhida por pergunta no editor (config.layout).
   "Lado a lado" mede cada opção pelo próprio texto e quebra sozinho; as de
   coluna fixa mantêm todas do mesmo tamanho. Em telas estreitas todas voltam a
   uma por linha — vide a consulta de mídia mais abaixo. */
.fx-opcoes-linha { display: flex; flex-wrap: wrap; }
.fx-opcoes-linha .fx-opcao { flex: 0 1 auto; }
.fx-opcoes-col2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fx-opcoes-col3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fx-opcoes-col4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* "Tudo em uma linha": uma coluna por opção (--fx-cols vem do render.js), todas
   do mesmo tamanho e sem quebrar. Para caber 1 a 10 numa linha só, a bolinha de
   marcação sai — quem mostra a seleção é o próprio cartão, que muda de cor. É a
   disposição para rótulos curtos: notas, P/M/G, sim/talvez/não. */
.fx-opcoes-unica {
  grid-template-columns: repeat(var(--fx-cols, 5), minmax(0, 1fr));
  gap: 6px;
}
.fx-opcoes-unica .fx-opcao {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0;
  padding: 12px 4px;
  min-width: 0;
}
.fx-opcoes-unica .fx-marca { display: none; }
.fx-opcoes-unica .fx-opcao-texto {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.fx-opcoes-unica .fx-opcao-outro { grid-column: 1 / -1; }

/* O "Outro" traz um campo de texto junto: ocupa a linha toda em qualquer
   disposição, senão o input fica espremido numa coluna. */
.fx-opcoes-col2 .fx-opcao-outro,
.fx-opcoes-col3 .fx-opcao-outro,
.fx-opcoes-col4 .fx-opcao-outro { grid-column: 1 / -1; }
.fx-opcoes-linha .fx-opcao-outro { flex: 1 0 100%; }

.fx-opcao {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 14px;
  border: 1px solid var(--f-border-strong);
  border-radius: var(--f-radius);
  background: var(--f-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.fx-opcao:hover { border-color: var(--f-primary); background: var(--f-primary-soft); }
.fx-opcao input { position: absolute; opacity: 0; width: 0; height: 0; }

.fx-marca {
  flex: none;
  width: 19px;
  height: 19px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--f-border-strong);
  background: var(--f-surface);
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.fx-marca-quadrada { border-radius: max(4px, calc(var(--f-radius) / 3)); }

.fx-marca::after {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--f-primary);
  transform: scale(0);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fx-marca-quadrada::after {
  width: 11px; height: 11px;
  border-radius: 0;
  background: transparent;
  border-left: 2.4px solid var(--f-on-primary);
  border-bottom: 2.4px solid var(--f-on-primary);
  transform: rotate(-45deg) scale(0);
  margin-top: -3px;
}

.fx-opcao:has(input:checked) { border-color: var(--f-primary); background: var(--f-primary-soft); }
.fx-opcao:has(input:checked) .fx-marca { border-color: var(--f-primary); }
.fx-opcao:has(input:checked) .fx-marca-quadrada { background: var(--f-primary); }
.fx-opcao:has(input:checked) .fx-marca::after { transform: scale(1); }
.fx-opcao:has(input:checked) .fx-marca-quadrada::after { transform: rotate(-45deg) scale(1); }
.fx-opcao:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--f-primary-soft); }

.fx-opcao-texto { font-size: 15px; }

.fx-outro-campo {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
  padding-left: 30px;
}
.fx-outro-campo.aberto { grid-template-rows: 1fr; padding-top: 8px; }
.fx-outro-campo > div { overflow: hidden; min-height: 0; }
/* Folga interna para o anel de foco do campo não ser cortado pelo overflow. */
.fx-outro-campo > div > .fx-input { margin: 3px; width: calc(100% - 6px); }
.fx-opcao-outro:has(input:checked) .fx-outro-campo { grid-template-rows: 1fr; padding-top: 8px; }

/* ------------------------------------------------------------ sim/não */

.fx-simnao { display: flex; gap: 10px; flex-wrap: wrap; }
.fx-simnao-item {
  flex: 1 1 130px;
  display: flex;
  justify-content: center;
  padding: 13px 18px;
  border: 1px solid var(--f-border-strong);
  border-radius: var(--f-radius);
  background: var(--f-surface);
  cursor: pointer;
  font-weight: 550;
  transition: all 0.15s ease;
}
.fx-simnao-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.fx-simnao-item:hover { border-color: var(--f-primary); }
.fx-simnao-item:has(input:checked) {
  border-color: var(--f-primary);
  background: var(--f-primary);
  color: var(--f-on-primary);
}
.fx-simnao-item:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--f-primary-soft); }

/* ------------------------------------------------------------- escala */

.fx-escala-rotulos {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  color: var(--f-text-muted);
  margin-bottom: 9px;
}
.fx-escala-linha { display: flex; gap: 8px; flex-wrap: wrap; }
.fx-escala-ponto { flex: 1 1 44px; cursor: pointer; }
.fx-escala-ponto input { position: absolute; opacity: 0; width: 0; height: 0; }
.fx-escala-bolha {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 46px;
  border: 1px solid var(--f-border-strong);
  border-radius: var(--f-radius);
  background: var(--f-surface);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
}
.fx-escala-ponto:hover .fx-escala-bolha { border-color: var(--f-primary); }
.fx-escala-ponto:has(input:checked) .fx-escala-bolha {
  background: var(--f-primary);
  color: var(--f-on-primary);
  border-color: var(--f-primary);
  transform: translateY(-2px);
}
.fx-escala-ponto:has(input:focus-visible) .fx-escala-bolha { box-shadow: 0 0 0 3px var(--f-primary-soft); }

/* ----------------------------------------------------------- estrelas */

.fx-estrelas { display: flex; align-items: center; gap: 4px; }
.fx-estrela {
  background: none;
  border: 0;
  padding: 3px;
  cursor: pointer;
  color: var(--f-border-strong);
  transition: color 0.12s ease, transform 0.12s ease;
  line-height: 0;
}
.fx-estrela:hover { transform: scale(1.12); }
.fx-estrela.cheia { color: var(--f-primary); }
.fx-estrela.cheia .ic { fill: currentColor; }
.fx-estrela:disabled { cursor: not-allowed; }
.fx-estrela:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--f-primary-soft); border-radius: 6px; }
.fx-estrelas-valor {
  margin-left: 10px;
  font-size: 13.5px;
  color: var(--f-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ arquivo */

.fx-arquivo-input { position: absolute; opacity: 0; width: 0; height: 0; }

.fx-upload-alvo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 1.5px dashed var(--f-border-strong);
  border-radius: var(--f-radius);
  background: var(--f-surface-alt);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  color: var(--f-text);
}
.fx-upload-alvo:hover { border-color: var(--f-primary); background: var(--f-primary-soft); }
.fx-upload-alvo strong { font-weight: 600; font-size: 14.5px; }
.fx-upload-dica { display: block; font-size: 12.5px; color: var(--f-text-muted); }

.fx-arquivos { display: grid; gap: 7px; margin-top: 10px; }
.fx-arquivo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius);
  background: var(--f-surface-alt);
  font-size: 13.5px;
}
.fx-arquivo-nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-arquivo-tam { color: var(--f-text-muted); font-size: 12.5px; white-space: nowrap; }
.fx-arquivo-x {
  background: none; border: 0; cursor: pointer; color: var(--f-text-muted);
  padding: 3px; border-radius: 6px; line-height: 0;
}
.fx-arquivo-x:hover { color: var(--f-error); background: var(--f-error-soft); }

.fx-arquivo-status { margin: 8px 0 0; font-size: 13px; color: var(--f-text-muted); }
.fx-arquivo-status.erro { color: var(--f-error); }

/* ---------------------------------------------------------- identidade */

.fx-identidade { display: grid; gap: 14px; }
.fx-campo-rotulo {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* -------------------------------------------------------------- botões */

.fx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--f-radius);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
}
.fx-btn:active { transform: translateY(1px); }
.fx-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.fx-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--f-primary-soft); }

.fx-btn-secundario {
  background: var(--f-surface);
  color: var(--f-text);
  border-color: var(--f-border-strong);
}
.fx-btn-secundario:hover { border-color: var(--f-text-muted); background: var(--f-surface-alt); }

.fx-acoes {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.fx-acoes .fx-espaco { flex: 1; }
.fx-acoes .fx-btn-primary { min-width: 160px; }

@media (max-width: 480px) {
  .fx-acoes { flex-direction: column-reverse; align-items: stretch; }
  .fx-acoes .fx-btn { width: 100%; }
  .fx-pergunta { padding: 18px 16px; }
  .fx-cabecalho { padding: 22px 18px 20px; }
  .fx-wrap { padding: 20px 14px 100px; }

  /* No celular 3 ou 4 colunas viram tiras ilegíveis: cai para 2. O "lado a
     lado" continua valendo — ele já quebra sozinho conforme o texto. */
  .fx-opcoes-col3,
  .fx-opcoes-col4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* "Tudo em uma linha" continua em uma linha só no celular (é o motivo de
     existir): aperta o cartão em vez de quebrar a escala em duas fileiras. */
  .fx-opcoes-unica { gap: 4px; }
  .fx-opcoes-unica .fx-opcao { padding: 10px 2px; }
  .fx-opcoes-unica .fx-opcao-texto { font-size: 14px; }
}

/* -------------------------------------------------------------- avisos */

.fx-aviso {
  padding: 13px 16px;
  border-radius: var(--f-radius);
  font-size: 14.5px;
  border: 1px solid;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.fx-aviso .ic { flex: none; margin-top: 2px; }
.fx-aviso-erro { background: var(--f-error-soft); border-color: var(--f-error); color: var(--f-error); }
.fx-aviso-info { background: var(--f-primary-soft); border-color: transparent; color: var(--f-primary-text); }

/* ------------------------------------------------------------ conclusão */

.fx-final {
  background: var(--f-surface);
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius-block);
  box-shadow: var(--f-shadow);
  padding: 54px 30px;
  text-align: center;
  animation: fx-entrada 0.3s ease both;
}
.fx-final-icone {
  width: 62px;
  height: 62px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--f-success-soft);
  color: var(--f-success);
  display: grid;
  place-items: center;
}
.fx-final-icone.neutro { background: var(--f-primary-soft); color: var(--f-primary-text); }
.fx-final h2 { margin: 0; font-size: 22px; font-weight: 650; }
.fx-final p {
  margin: 12px auto 0;
  max-width: 46ch;
  color: var(--f-text-muted);
  white-space: pre-wrap;
}
.fx-final-acoes { margin-top: 26px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.fx-rodape {
  margin-top: 26px;
  text-align: center;
  font-size: 12.5px;
  color: var(--f-text-muted);
}
.fx-rodape a { color: inherit; }

/* ----------------------------------------------------------- esqueleto */

.fx-esqueleto {
  height: 110px;
  border-radius: var(--f-radius-block);
  margin-bottom: 14px;
  background: linear-gradient(90deg, var(--f-surface) 25%, var(--f-surface-alt) 37%, var(--f-surface) 63%);
  background-size: 400% 100%;
  animation: fx-brilho 1.4s ease infinite;
}
@keyframes fx-brilho {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

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

/* Faixa da pré-visualização do criador (a página real nunca a exibe). */
.fx-faixa-preview {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 9px 14px;
  border-radius: var(--f-radius);
  background: var(--f-primary-soft);
  color: var(--f-primary-text);
  font-size: 13px;
}
.fx-faixa-preview strong { font-weight: 700; }
