/* ==========================================================================
   APTA — design system (tema branco moderno, white-label via --brand*)
   ========================================================================== */
:root {
  --brand: #2D6A4F;
  --brand-dark: #1B4332;
  --brand-light: #52B788;
  --brand-accent: #B7E4C7;
  --brand-rgb: 45, 106, 79;

  --surface: #FFFFFF;
  --bg: #F4F6F8;
  --text: #0F172A;
  --text-muted: #64748B;
  --border: #EAECEF;
  --border-strong: #E2E5E9;

  --danger: #DC2626;
  --warning: #D97706;
  --success: #16A34A;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04);
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 6px 20px rgba(16,24,40,.08);
  --shadow-lg: 0 18px 40px rgba(16,24,40,.12);
}

body { background: var(--bg); color: var(--text); }
[x-cloak] { display: none !important; }

/* Tipografia display para títulos e wordmark */
h1, h2, .display, .apta-wordmark {
  font-family: 'Sora', 'Inter', sans-serif; letter-spacing: -.02em;
}

.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  line-height: 1; vertical-align: middle;
}

/* ---- Mapeia utilitários "forest-*" para a marca (white-label) ---- */
.text-forest-700 { color: var(--brand-dark) !important; }
.text-forest-600, .text-forest-500 { color: var(--brand) !important; }
.text-forest-300 { color: var(--brand-light) !important; }
.bg-forest-700 { background-color: var(--brand-dark) !important; }
.bg-forest-600, .bg-forest-500 { background-color: var(--brand) !important; }
.bg-forest-100 { background-color: rgba(var(--brand-rgb), .12) !important; }
.bg-forest-50  { background-color: rgba(var(--brand-rgb), .06) !important; }
.border-forest-200 { border-color: var(--border-strong) !important; }
.border-forest-100 { border-color: var(--border) !important; }
.hover\:bg-forest-700:hover { background-color: var(--brand-dark) !important; }
.hover\:text-forest-600:hover, .hover\:text-forest-700:hover { color: var(--brand) !important; }
.ring-forest-300 { --tw-ring-color: rgba(var(--brand-rgb), .25) !important; }
.focus\:border-forest-500:focus { border-color: var(--brand) !important; }
.divide-forest-50 > * + * { border-color: var(--border) !important; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
a.card:hover, .card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }

/* ---- Métrica cards (ícone vira chip colorido automaticamente) ---- */
.metric-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem; transition: box-shadow .2s ease, transform .2s ease;
  display: flex; flex-direction: column;
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.metric-card > .material-symbols-rounded {
  width: 46px; height: 46px; border-radius: 13px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 24px;
  background: rgba(var(--brand-rgb), .10); color: var(--brand) !important; margin-bottom: .85rem;
}
.metric-card .metric-value {
  font-family: 'Sora', sans-serif; font-size: 1.9rem; font-weight: 700;
  color: var(--brand-dark); line-height: 1; letter-spacing: -.02em;
}
.metric-card .metric-label { font-size: .82rem; color: var(--text-muted); margin-top: .4rem; font-weight: 500; }

/* ---- Page header ---- */
.page-title { font-size: 1.65rem; font-weight: 700; color: var(--text); }
.page-subtitle { color: var(--text-muted); margin-top: .15rem; }

/* ---- Tabelas ---- */
.apta-table { width: 100%; border-collapse: collapse; background: #fff; }
.apta-table thead th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); background: transparent; padding: .65rem 1rem; border-bottom: 1px solid var(--border);
}
.apta-table tbody td { padding: .9rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.apta-table tbody tr:last-child td { border-bottom: none; }
.apta-table tbody tr { transition: background .12s ease; }
.apta-table tbody tr:hover { background: rgba(var(--brand-rgb), .04); }

/* ---- Botões ---- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem; border-radius: var(--radius-sm);
  padding: .62rem 1.15rem; font-weight: 600; font-size: .9rem; transition: all .15s ease;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(var(--brand-rgb), .30); }
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 14px rgba(var(--brand-rgb), .38); transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--brand-dark); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: #FAFBFC; border-color: rgba(var(--brand-rgb), .35); }
.btn-danger { background: var(--danger); color: #fff; }

/* ---- Form ---- */
.field-label { display: block; font-size: .8rem; font-weight: 600; color: var(--brand-dark); margin-bottom: .4rem; }
.field-error { color: var(--danger); font-size: .78rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=date], select, textarea {
  background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .15);
}

/* ---- Sidebar (moderna, branca) ---- */
.apta-sidebar { background: var(--surface); border-right: 1px solid var(--border); }
.apta-wordmark { font-weight: 800; }
.apta-nav-section { font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; color: #94A3B8; padding: .5rem .75rem .25rem; font-weight: 700; }
.apta-nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: var(--radius-sm);
  color: #475569; font-size: .9rem; font-weight: 500; transition: all .14s ease; position: relative;
}
.apta-nav-item .material-symbols-rounded { font-size: 21px; color: #94A3B8; transition: color .14s ease; }
.apta-nav-item:hover { background: rgba(var(--brand-rgb), .06); color: var(--brand-dark); }
.apta-nav-item:hover .material-symbols-rounded { color: var(--brand); }
.apta-nav-item.active {
  background: rgba(var(--brand-rgb), .11); color: var(--brand-dark); font-weight: 600;
}
.apta-nav-item.active .material-symbols-rounded { color: var(--brand); }
.apta-nav-item.active::before {
  content: ""; position: absolute; left: -.75rem; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: var(--brand);
}

/* ---- Topbar ---- */
.apta-topbar { background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border); }

/* ---- Badges / pills ---- */
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: .15rem .6rem; font-size: .72rem; font-weight: 600; }

/* ---- Wizard / Likert ---- */
/* Mobile-first: opções empilhadas em linha cheia, com área de toque grande. */
.likert { display: flex; flex-direction: column; gap: .5rem; }
.likert-option { cursor: pointer; }
.likert-option input { position: absolute; opacity: 0; }
.likert-btn {
  display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
  gap: .75rem; padding: .95rem 1rem; border-radius: var(--radius-sm); border: 2px solid transparent;
  text-align: left; font-size: .95rem; font-weight: 500; color: #1f2937;
  transition: transform .12s ease, box-shadow .12s ease; min-height: 56px;
}
.likert-option:nth-child(1) .likert-btn { background: #FEE2E2; }
.likert-option:nth-child(2) .likert-btn { background: #FEF3C7; }
.likert-option:nth-child(3) .likert-btn { background: #F1F5F9; }
.likert-option:nth-child(4) .likert-btn { background: #DCFCE7; }
.likert-option:nth-child(5) .likert-btn { background: #BBF7D0; }
.likert-option input:checked + .likert-btn {
  border-color: var(--brand); box-shadow: 0 6px 16px rgba(var(--brand-rgb), .25);
}
.likert-num {
  font-size: 1.1rem; font-weight: 700; font-family: 'Sora', sans-serif;
  width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.6); border-radius: 999px; flex-shrink: 0;
}
/* A partir de telas médias: grade de 5 colunas (layout original). */
@media (min-width: 640px) {
  .likert { display: grid; grid-template-columns: repeat(5, 1fr); gap: .55rem; }
  .likert-btn {
    flex-direction: column; align-items: center; justify-content: center;
    gap: .35rem; padding: 1.05rem .5rem; text-align: center; font-size: .8rem; height: 100%;
  }
  .likert-num { background: transparent; width: auto; height: auto; font-size: 1.25rem; }
}

/* ---- Controles de formulário (padrão em todos os CRUDs) ---- */
.apta-form input:not([type=checkbox]):not([type=radio]):not([type=file]),
.apta-form select,
.apta-form textarea {
  width: 100%;
  border: 1px solid #E2E8F0;
  border-radius: .75rem;
  padding: .62rem .85rem;
  font-size: .95rem;
  color: #1f2937;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.apta-form input:focus,
.apta-form select:focus,
.apta-form textarea:focus {
  outline: none;
  border-color: var(--brand, #2D6A4F);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb, 45,106,79), .15);
}
.apta-form textarea { min-height: 96px; resize: vertical; }
.apta-form input[type=file] { font-size: .9rem; color: #64748b; }

/* ============================================================
   Acessibilidade (WCAG 2.1 AA) — Fase 0
   ============================================================ */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -56px; z-index: 200;
  background: var(--brand, #2D6A4F); color: #fff; padding: .6rem 1rem;
  border-radius: .5rem; font-weight: 600; transition: top .15s ease;
}
.skip-link:focus { top: 8px; outline: 3px solid #fff; }

/* Foco visível por teclado (restaura o que o reset de outline removia) */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #1B4332 !important; outline-offset: 2px;
}
.likert-option input:focus-visible + .likert-btn {
  outline: 3px solid #1B4332; outline-offset: 2px;
}
.likert-option input:checked + .likert-btn::after {
  content: "✓"; margin-left: .35rem; font-weight: 700;
}
fieldset.q-field { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Respeita "reduzir movimento" do sistema operacional */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* Botões de ação por ícone (substituem links-texto em listas) */
.icon-btn { display:inline-flex; align-items:center; justify-content:center; width:2.25rem; height:2.25rem; border-radius:.625rem; color:#64748b; background:transparent; border:0; cursor:pointer; transition:background .15s, color .15s; }
.icon-btn:hover { background:#f1f5f9; color:#1B4332; }
.icon-btn .material-symbols-rounded { font-size:1.25rem; }
.icon-btn-primary:hover { background:#E8F3EC; color:#1B4332; }
.icon-btn-danger:hover { background:#FEF2F2; color:#DC2626; }
.icon-btn-sm { width:1.875rem; height:1.875rem; border-radius:.5rem; }
.icon-btn-sm .material-symbols-rounded { font-size:1.05rem; }

/* Barra de acessibilidade + leitura por voz */
.a11y-item { display:flex; align-items:center; gap:.5rem; padding:.5rem .75rem; border-radius:.625rem; font-size:.875rem; color:#374151; text-align:left; width:100%; background:transparent; border:0; cursor:pointer; }
.a11y-item:hover { background:#f1f5f9; }
.a11y-item .material-symbols-rounded { font-size:1.25rem; color:#2D6A4F; }
.a11y-speak { display:inline-flex; align-items:center; justify-content:center; width:1.9rem; height:1.9rem; border-radius:9999px; color:#2D6A4F; background:#E8F3EC; border:0; cursor:pointer; vertical-align:middle; margin-left:.4rem; }
.a11y-speak:hover { background:#2D6A4F; color:#fff; }
.a11y-speak .material-symbols-rounded { font-size:1.05rem; }
/* Alto contraste */
html.a11y-contrast { filter: contrast(1.25) saturate(1.2); }
html.a11y-contrast .text-gray-400, html.a11y-contrast .text-gray-300 { color:#374151 !important; }
html.a11y-contrast ::placeholder { color:#4b5563 !important; }

/* ---------------------------------------------------------------------------
   Upload de arquivo — botão "Escolher arquivo" estilizado (todas as telas).
   Estiliza o botão nativo via ::file-selector-button; não afeta inputs .hidden
   (que já têm UI própria). Combinado com file-upload.js (trava o submit).
--------------------------------------------------------------------------- */
input[type="file"]:not(.hidden) {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  max-width: 100%;
  font-size: .85rem;
  color: #64748B;
  background: #fff;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: .75rem;
  padding: .35rem .5rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
input[type="file"]:not(.hidden):hover { border-color: var(--brand, #2D6A4F); }
input[type="file"]:not(.hidden):focus-visible {
  outline: none;
  border-color: var(--brand, #2D6A4F);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb, 45,106,79), .15);
}
input[type="file"]:not(.hidden)::file-selector-button {
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand, #2D6A4F);
  border: 0;
  border-radius: .55rem;
  padding: .5rem .95rem;
  margin-right: .1rem;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
input[type="file"]:not(.hidden)::file-selector-button:hover {
  background: var(--brand-dark, #1B4332);
}
input[type="file"]:not(.hidden)::file-selector-button:active { transform: translateY(1px); }
/* Estado "com arquivo": borda verde discreta (via JS: data-has-file). */
input[type="file"][data-has-file="1"]:not(.hidden) {
  border-color: var(--brand, #2D6A4F);
  color: #1B4332;
}

/* ===========================================================================
   Estilo editorial das telas públicas (login, cadastros, canal de denúncias,
   vagas). Título tipográfico, campo em linha com rótulo flutuante e botão
   escuro. Nasceu no login e foi extraído aqui para não repetir em cada tela.
   Exige a fonte Outfit no <head> da página que usar .apta-title.
   =========================================================================== */
.apta-title {
  font-family: 'Outfit', sans-serif; font-weight: 700;
  letter-spacing: -.02em; line-height: 1.05; color: #0D2B1D;
}
.apta-eyebrow {
  display: inline-flex; align-items: center; gap: .6rem;
  font-size: .6875rem; font-weight: 700; letter-spacing: .18em;
  text-transform: uppercase; color: #40916C;
}
.apta-eyebrow::before { content: ""; width: 1.75rem; height: 2px; background: #40916C; border-radius: 2px; }

/* Campo em linha. Precisa de `input.wz-input`: o seletor `input[type=text]`
   acima tem especificidade maior que uma classe sozinha. */
.wz-field { position: relative; padding-top: 1.15rem; }
input.wz-input {
  width: 100%; border: 0; border-bottom: 1.5px solid #DDE5E1; border-radius: 0;
  background: transparent; box-shadow: none;
  padding: .35rem 0 .6rem; font-size: 1rem; color: #0D2B1D;
  transition: border-color .2s, box-shadow .2s;
}
input.wz-input::placeholder { color: transparent; }       /* o rótulo faz o papel do placeholder… */
input.wz-input:focus::placeholder { color: #C7CFCB; }     /* …e o formato aparece ao focar */
input.wz-input:focus, input.wz-input:focus-visible {
  outline: none !important; border-bottom-color: #2D6A4F; box-shadow: 0 1px 0 0 #2D6A4F;
}
.wz-label {
  position: absolute; left: 0; top: 1.5rem; font-size: 1rem; color: #9CA3AF;
  pointer-events: none; transform-origin: 0 0; transition: transform .18s ease, color .18s ease;
}
/* :has/:focus-within em vez de irmão adjacente — o script do olho de senha
   embrulha o input num <div> e quebraria `input + label`. */
.wz-field:focus-within .wz-label,
.wz-field:has(input.wz-input:not(:placeholder-shown)) .wz-label {
  transform: translateY(-1.5rem) scale(.72);
  color: #2D6A4F; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}

.apta-submit {
  display: inline-flex; align-items: center; gap: .75rem;
  background: #0D2B1D; color: #fff; font-weight: 600; font-family: 'Outfit', sans-serif;
  border-radius: .35rem; padding: .95rem 1.35rem;
  transition: background .18s ease;
}
.apta-submit:hover { background: #1B4332; }
.apta-submit-full { width: 100%; justify-content: space-between; }
.apta-submit .apta-arrow { transition: transform .18s ease; }
.apta-submit:hover .apta-arrow { transform: translateX(4px); }

.apta-back {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .875rem; font-weight: 500; color: #9CA3AF; transition: color .15s;
}
.apta-back:hover { color: #1B4332; }

/* ---- Conversa do canal de suporte: rolagem própria e estilizada ---- */
.support-thread {
  max-height: 420px;
  overflow-y: auto;
  padding-right: .25rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--brand-rgb), .35) transparent;
}
.support-thread::-webkit-scrollbar { width: 8px; }
.support-thread::-webkit-scrollbar-track { background: transparent; }
.support-thread::-webkit-scrollbar-thumb {
  background-color: rgba(var(--brand-rgb), .35);
  border-radius: 999px;
}
.support-thread::-webkit-scrollbar-thumb:hover {
  background-color: rgba(var(--brand-rgb), .55);
}
