/* =====================================================================
   GARWIT — Design System
   =====================================================================
   CSS puro, sem build step e sem framework.

   POR QUÊ: a aplicação roda em hospedagem compartilhada, com deploy por
   FTP. Uma pipeline de build (Tailwind, Sass, bundler) adiciona um passo
   que precisa rodar em algum lugar antes do upload — e o primeiro deploy
   feito às pressas vai esquecer esse passo, subindo CSS desatualizado.
   Custom properties nativas resolvem tematização sem compilação.

   Tudo é derivado de tokens. Mudar a paleta é editar :root.
   ===================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  /* Cores de marca */
  --brand-500: #2563eb;
  --brand-600: #1d4ed8;
  --brand-700: #1e40af;
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;

  --accent-500: #8b5cf6;   /* IA / diferencial */
  --accent-50:  #f5f3ff;

  /* Semânticas — usadas por estado, nunca por gosto */
  --ok-500:   #10b981;
  --ok-50:    #ecfdf5;
  --warn-500: #f59e0b;
  --warn-50:  #fffbeb;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-50:  #fef2f2;
  --info-500: #0ea5e9;
  --info-50:  #f0f9ff;

  /* Neutros */
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;
  --surface: #ffffff;

  /* Tipografia */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;
  --text-4xl:  3rem;

  /* Espaçamento — escala de 4px */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.5rem;   --sp-6: 2rem;
  --sp-7: 3rem;     --sp-8: 4rem;     --sp-9: 6rem;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow:    0 4px 12px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 12px 32px rgb(15 23 42 / 0.12);

  --container: 1180px;
  --header-h: 64px;
}

/* Tema escuro por preferência do sistema. Os componentes não mudam:
   só os tokens. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink-900: #f8fafc;
    --ink-700: #cbd5e1;
    --ink-500: #94a3b8;
    --ink-400: #64748b;
    --ink-300: #475569;
    --ink-200: #334155;
    --ink-100: #1e293b;
    --ink-50:  #172033;
    --surface: #0f172a;
    --brand-50: #172554;
    --brand-100: #1e3a8a;
    --ok-50: #052e21;
    --warn-50: #3b2708;
    --danger-50: #3f1214;
    --info-50: #082f49;
    --accent-50: #2e1065;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow:    0 4px 12px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.55);
  }
}

/* ----------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink-900);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
p  { margin: 0 0 var(--sp-4); }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Foco visível em tudo que é interativo. Remover outline é a regressão
   de acessibilidade mais comum — e quebra a navegação por teclado. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute; left: -9999px;
  background: var(--brand-600); color: #fff;
  padding: var(--sp-3) var(--sp-4); z-index: 100;
}
.skip-link:focus { left: var(--sp-4); top: var(--sp-4); }

/* ------------------------------------------------------------- layout */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--sp-4); }
.stack > * + * { margin-top: var(--sp-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.between { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; }

.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.section { padding-block: var(--sp-8); }
.muted { color: var(--ink-500); }
.small { font-size: var(--text-sm); }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.9em; }
.right { text-align: right; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* `.sr-only` é alias, não estilo novo: duas telas de apontamento de
   horas já usavam esse nome e, sem a regra, o rótulo "Selecionar" que
   deveria existir só para o leitor de tela aparecia escrito na coluna
   da caixa de seleção. */
.visually-hidden,
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* -------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ink-200);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5); }

.logo { font-weight: 800; font-size: var(--text-lg); letter-spacing: -0.03em; color: var(--ink-900); }
.logo:hover { text-decoration: none; }
.logo span { color: var(--brand-600); }

.nav { display: flex; gap: var(--sp-5); align-items: center; }
.nav a { color: var(--ink-700); font-size: var(--text-sm); font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--brand-600); text-decoration: none; }

/* --------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-title { font-size: var(--text-base); font-weight: 600; margin: 0; }

.stat { background: var(--surface); border: 1px solid var(--ink-200); border-radius: var(--radius); padding: var(--sp-4); }
.stat-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-500); font-weight: 600; }
.stat-value { font-size: var(--text-2xl); font-weight: 700; margin-top: var(--sp-1); font-variant-numeric: tabular-nums; }
.stat-hint  { font-size: var(--text-xs); color: var(--ink-500); margin-top: var(--sp-1); }
.stat--ok    { border-left: 3px solid var(--ok-500); }
.stat--warn  { border-left: 3px solid var(--warn-500); }
.stat--danger{ border-left: 3px solid var(--danger-500); }

/* ------------------------------------------------------------- botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  font: inherit; font-size: var(--text-sm); font-weight: 600;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { background: transparent; color: var(--ink-700); border-color: var(--ink-300); }
.btn-ghost:hover { background: var(--ink-100); }
.btn-danger { background: var(--danger-600); color: #fff; }
.btn-danger:hover { background: var(--danger-500); }
.btn-sm { padding: var(--sp-2) var(--sp-3); font-size: var(--text-xs); }
.btn-block { width: 100%; }

/* --------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2);
  font-size: var(--text-xs); font-weight: 600; line-height: 1.5;
  border-radius: var(--radius-full);
  background: var(--ink-100); color: var(--ink-700);
  white-space: nowrap;
}
.badge--ok     { background: var(--ok-50);     color: var(--ok-500); }
.badge--warn   { background: var(--warn-50);   color: #b45309; }
.badge--danger { background: var(--danger-50); color: var(--danger-600); }
.badge--info   { background: var(--info-50);   color: #0369a1; }
.badge--brand  { background: var(--brand-50);  color: var(--brand-700); }
.badge--accent { background: var(--accent-50); color: var(--accent-500); }

/* --------------------------------------------------------------- flash */
.flash {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-4); margin-bottom: var(--sp-4);
  border-radius: var(--radius); border-left: 4px solid;
  font-size: var(--text-sm);
}
.flash--success { background: var(--ok-50);     border-color: var(--ok-500); }
.flash--error   { background: var(--danger-50); border-color: var(--danger-500); }
.flash--warning { background: var(--warn-50);   border-color: var(--warn-500); }
.flash--info    { background: var(--info-50);   border-color: var(--info-500); }
.flash ul { margin: var(--sp-1) 0 0; padding-left: var(--sp-5); }

/* ------------------------------------------------------------ formulários */
.field { margin-bottom: var(--sp-4); }
.label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--sp-2); }
.label .req { color: var(--danger-500); }

.input, .select, .textarea {
  width: 100%; padding: var(--sp-3);
  font: inherit; font-size: var(--text-sm); color: var(--ink-900);
  background: var(--surface);
  border: 1px solid var(--ink-300); border-radius: var(--radius-sm);
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-500); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger-500);
}
.textarea { min-height: 120px; resize: vertical; }
.hint  { font-size: var(--text-xs); color: var(--ink-500); margin-top: var(--sp-1); }
.error { font-size: var(--text-xs); color: var(--danger-600); margin-top: var(--sp-1); font-weight: 500; }

.check { display: flex; gap: var(--sp-3); align-items: flex-start; font-size: var(--text-sm); }
.check input { margin-top: 3px; flex-shrink: 0; }

/* --------------------------------------------------------------- tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--ink-200); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--ink-200); }
.table th {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-500); font-weight: 600; background: var(--ink-50);
  position: sticky; top: 0;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--ink-50); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: var(--sp-7) var(--sp-4); text-align: center; color: var(--ink-500); }
.empty strong { display: block; color: var(--ink-700); margin-bottom: var(--sp-1); }

/* --------------------------------------------------------------- kanban */
.board { display: flex; gap: var(--sp-4); overflow-x: auto; padding-bottom: var(--sp-4); }
.board-col { flex: 0 0 300px; background: var(--ink-100); border-radius: var(--radius); padding: var(--sp-3); }
.board-col header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.board-col h3 { font-size: var(--text-sm); margin: 0; display: flex; align-items: center; gap: var(--sp-2); }
.board-col .dot { width: 8px; height: 8px; border-radius: var(--radius-full); flex-shrink: 0; }
.board-card {
  background: var(--surface); border: 1px solid var(--ink-200); border-radius: var(--radius-sm);
  padding: var(--sp-3); margin-bottom: var(--sp-2); box-shadow: var(--shadow-sm);
}
.board-card .code { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-500); }
.board-card .title { font-size: var(--text-sm); font-weight: 500; margin: var(--sp-1) 0 var(--sp-2); }
.board-card.is-late { border-left: 3px solid var(--danger-500); }

/* ------------------------------------------------------------- progresso */
.progress { height: 6px; background: var(--ink-200); border-radius: var(--radius-full); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-500); border-radius: inherit; }
.progress--ok   > span { background: var(--ok-500); }
.progress--warn > span { background: var(--warn-500); }
.progress--danger > span { background: var(--danger-500); }

/* --------------------------------------------------------------- painel */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--ink-200);
  padding: var(--sp-5) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-5);
}
.sidebar nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.sidebar nav a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  color: var(--ink-700); font-size: var(--text-sm); font-weight: 500;
}
.sidebar nav a:hover { background: var(--ink-100); text-decoration: none; }
.sidebar nav a[aria-current="page"] { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.sidebar .group-label {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-400); font-weight: 700; padding: var(--sp-3) var(--sp-3) var(--sp-1);
}
.main { padding: var(--sp-5); min-width: 0; }
.page-header { margin-bottom: var(--sp-5); }
.page-header h1 { margin-bottom: var(--sp-1); }

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--ink-200); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .nav { display: none; }
}

/* ------------------------------------------------------------------ hero */
.hero { padding-block: var(--sp-9) var(--sp-8); text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, var(--text-4xl)); max-width: 22ch; margin-inline: auto; }
.hero p { font-size: var(--text-lg); color: var(--ink-500); max-width: 60ch; margin-inline: auto; }
.eyebrow {
  display: inline-block; font-size: var(--text-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent-500); background: var(--accent-50);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-full);
  margin-bottom: var(--sp-4);
}

.case-card { overflow: hidden; padding: 0; }
.case-card img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: var(--ink-100); }
.case-card .body { padding: var(--sp-4); }

/* --------------------------------------------------------------- rodapé */
.site-footer {
  border-top: 1px solid var(--ink-200); background: var(--surface);
  padding-block: var(--sp-6); margin-top: var(--sp-8);
  font-size: var(--text-sm); color: var(--ink-500);
}

/* ------------------------------------------------------------ impressão */
@media print {
  .site-header, .sidebar, .site-footer, .btn, .flash { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .card, .table-wrap { border: 1px solid #000; box-shadow: none; }
  body { background: #fff; }
}

/* Respeita quem pediu menos movimento. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* Arrastar-e-soltar no quadro de tarefas.
   Estados visuais do arrasto; sem JavaScript nenhum deles é aplicado e o
   quadro continua legível exatamente como antes. */
.board-card[draggable="true"] { cursor: grab; }
.board-card.is-dragging { opacity: .45; cursor: grabbing; }
.board-card.is-saving { opacity: .6; }
.board-col.is-drop-target { outline: 2px dashed var(--brand-500); outline-offset: 2px; }
.board-card .code a,
.board-card .title a { color: inherit; text-decoration: none; }
.board-card .title a:hover,
.board-card .code a:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .board-card { transition: none; }
}

/* -------------------------------------------------- busca na sidebar */
/* A barra de busca fica acima do menu do painel. `width:100%` no input
   porque a sidebar é estreita e o padrão do `.input` é auto. */
.sidebar-search { margin-bottom: var(--sp-4); }
.sidebar-search .input { width: 100%; font-size: var(--text-sm); }

/* ---------------------------------------------------------------------
   O ATRIBUTO `hidden` SÓ VALE ENQUANTO NINGUÉM DECLARAR `display`.
   A folha do navegador traz `[hidden] { display: none }` com a menor
   precedência que existe, e qualquer regra de autor a derruba — `.btn`
   declara `display: inline-flex`, `.nav` e `.passos` declaram `flex`.
   O resultado é elemento com `hidden` continuando à vista, sem erro em
   lugar nenhum: JavaScript escondeu, CSS mostrou, ninguém avisou.

   Medido em 16/09/2026 no formulário de contato: o botão "Enviar" com
   `hidden = true` seguia ocupando 48px de altura ao lado do "Continuar".
   O `public.css` já tinha um remendo para `.nav[hidden]` — sinal de que
   alguém bateu nisso antes e resolveu só o caso da vez.

   `!important` aqui é o uso correto e é o que o normalize.css faz: a
   regra não é estética, é a semântica do atributo.
   --------------------------------------------------------------------- */
[hidden] { display: none !important; }
