/* Estilos do FormSurvey. Um único arquivo, sem framework CSS. As cores ficam
   em variáveis (:root) e "color-scheme: light dark" faz a página acompanhar
   o tema claro/escuro do aparelho. O layout é pensado primeiro para celular,
   que é como a maior parte dos participantes acessa. */
:root {
  color-scheme: light dark;
  --accent: #1a6b3c;
  --accent-dark: #0f4326;
  --danger: #a5342a;
  --border: #d8dce0;
  --card-bg: canvas;
  --muted: #6b7280;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  margin: 0;
  background: light-dark(#f4f6f5, #14181a);
  color: canvastext;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.subtitle { opacity: 0.75; margin-top: 0; }
.muted { color: var(--muted); }

/* --- animações de entrada --- */
.fade-in {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: calc(var(--delay, 0) * 70ms);
}
.fade-in.in-view { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .fade-in { opacity: 1; transform: none; transition: none; }
}

/* --- cartões genéricos --- */
.card, .hero {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}
.hero { text-align: center; border: none; background: transparent; padding: 8px 0 0; }

/* --- indicador de etapas --- */
.stepper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin: 4px 0 28px;
  flex-wrap: wrap;
}
.stepper-item { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; }
.stepper-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600;
  color: var(--muted);
  background: var(--card-bg);
}
.stepper-label { font-size: 0.72rem; color: var(--muted); text-align: center; }
.stepper-item.is-active .stepper-dot { border-color: var(--accent); color: var(--accent); }
.stepper-item.is-active .stepper-label { color: var(--accent); font-weight: 600; }
.stepper-item.is-done .stepper-dot { border-color: var(--accent); background: var(--accent); color: #fff; }
.stepper-line { flex: 1; height: 2px; background: var(--border); margin: 13px 4px 0; min-width: 16px; }
.stepper-line.is-done { background: var(--accent); }

/* --- termos: cabeçalho + seções --- */
.term-header { text-align: center; margin-bottom: 20px; }
.term-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 12px;
}
.term-section p { margin: 8px 0; }
.term-section p:first-of-type { margin-top: 0; }
.term-icon { font-size: 1.1rem; margin-right: 4px; }

.greeting { font-size: 1.3rem; text-align: center; margin-bottom: 18px; }

/* --- TALE: pagina do menor, tratamento ludico tipo "livrinho" --- */
.tale-page { --tale-a: #f2b705; --tale-b: #3a86c8; --tale-c: #e8635f; --tale-d: var(--accent); }

.mascot-bubble {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px;
}
.mascot-avatar {
  flex: none;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tale-a), var(--tale-c));
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.mascot-speech {
  position: relative;
  background: var(--card-bg);
  border: 2px solid var(--tale-b);
  border-radius: 18px;
  padding: 12px 18px;
  font-size: 1.05rem;
}
.mascot-speech::before {
  content: "";
  position: absolute; left: -9px; top: 18px;
  width: 16px; height: 16px;
  background: var(--card-bg);
  border-left: 2px solid var(--tale-b);
  border-bottom: 2px solid var(--tale-b);
  transform: rotate(45deg);
}

.tale-page .term-header h1 { font-size: 1.5rem; }

.term-section-playful {
  border-radius: 20px;
  border-width: 1px;
  padding: 20px 22px;
  border-top-width: 6px;
}
.term-section-playful:nth-of-type(4n+1) { border-top-color: var(--tale-a); }
.term-section-playful:nth-of-type(4n+2) { border-top-color: var(--tale-b); }
.term-section-playful:nth-of-type(4n+3) { border-top-color: var(--tale-c); }
.term-section-playful:nth-of-type(4n+4) { border-top-color: var(--tale-d); }
.term-section-playful h2 { font-size: 1.05rem; }
.term-section-playful .term-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  font-size: 1.15rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--tale-a) 18%, transparent);
  margin-right: 6px;
}

.card-playful { border-radius: 20px; border-top: 6px solid var(--tale-b); }

.decision-panel-playful {
  border-radius: 20px;
  border: 2px solid var(--tale-d);
  background: color-mix(in srgb, var(--tale-a) 6%, transparent);
}
.btn-playful { border-radius: 999px; padding: 15px 26px; font-size: 1.05rem; }

/* --- painel de decisão --- */
.decision-panel {
  text-align: center;
  padding: 24px;
  border: 2px dashed var(--accent);
  border-radius: 12px;
  margin-top: 20px;
}
.decision-question { font-size: 1.1rem; font-weight: 600; margin-top: 0; }
.decision-declaration { font-size: 0.95rem; margin-top: 0; }
.decision-note { font-size: 0.78rem; color: var(--muted); margin-bottom: 0; }
.decision-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.decision-inline { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.decision-inline label { display: block; font-weight: normal; margin: 4px 0; }

/* --- formulários --- */
.field { margin: 16px 0; }
.field label { display: block; margin-bottom: 4px; font-weight: 500; }
.field input[type=text], .field input[type=email], .field select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: inherit;
  font-size: 1rem;
  box-sizing: border-box;
}
.field input:disabled { opacity: 0.65; }
.code-input { letter-spacing: 0.15em; font-weight: 600; text-align: center; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-size: 0.85rem; }
.copy-row .btn { margin: 0; white-space: nowrap; }

/* --- botões --- */
.btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 13px 22px;
  border-radius: 10px;
  text-decoration: none;
  margin: 8px 8px 0 0;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-secondary:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.btn-agree { background: var(--accent); }
.btn-disagree { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-disagree:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn-block { display: block; width: 100%; text-align: center; font-size: 1.05rem; padding: 16px; }

.choices { display: flex; flex-direction: column; gap: 8px; margin: 24px 0; }
.choices .btn { text-align: center; margin: 0; }

/* --- diagrama de fluxo (index) --- */
.flow-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0 8px;
}
.flow-step { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.flow-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.flow-arrow { color: var(--border); font-size: 1.3rem; }

/* --- código gerado --- */
.code-box {
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  word-break: break-all;
  text-align: center;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  padding: 18px;
  margin: 16px 0;
}

/* --- questionário --- */
.questionnaire-block { margin-bottom: 28px; }
.likert-legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  font-size: 0.78rem; color: var(--muted);
  margin-bottom: 14px;
}
.likert-legend strong { color: canvastext; }
.likert-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.likert-text { flex: 1 1 260px; margin: 0; }
.likert-scale { display: flex; gap: 6px; }
.likert-scale input[type=radio] {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.likert-scale label {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.likert-scale input:checked + label { background: var(--accent); border-color: var(--accent); color: #fff; }
.likert-scale input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- estados finais --- */
.celebrate h1 { font-size: 2rem; }

.flash {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffe69c;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* --- painel administrativo --- */
.admin-nav {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.admin-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
}
.admin-nav a.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 600; }
.admin-nav-logout { margin-left: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-tile {
  display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px;
  font-size: 0.85rem;
}
.stat-tile strong { font-size: 1rem; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar-label { flex: 0 0 220px; font-size: 0.85rem; }
.bar-track { flex: 1; height: 10px; background: color-mix(in srgb, var(--border) 60%, transparent); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.bar-fill-alt { background: #5b8ac0; }
.bar-value { flex: 0 0 90px; font-size: 0.8rem; color: var(--muted); text-align: right; }
@media (max-width: 600px) {
  .bar-label { flex-basis: 140px; font-size: 0.78rem; }
  .bar-value { flex-basis: 70px; }
}

/* --- declaração de maioridade (RCLE) --- */
.check-row { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 16px; font-weight: 600; cursor: pointer; }
.check-row input { margin-top: 4px; }

/* --- tabelas do painel (rolam na horizontal em telas estreitas) --- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; white-space: normal; }
