/* ==========================================================================
   Componentes (T-031, revistos na T-043): botao, card, campo, tabela, chip,
   badge, cartao de indicador, lista de itens, painel lateral, modal, toast,
   spinner (logo girando), utilidades. Visual sobrio: sem brilho, sem vidro,
   raios moderados, azul so na acao principal.
   ========================================================================== */

/* ---------- Botoes ---------- */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  height: 2.25rem; padding: 0 .875rem;
  border: 1px solid transparent; border-radius: var(--raio-p);
  background: var(--cta); color: #fff;
  font-size: .8125rem; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background-color var(--transicao), border-color var(--transicao), opacity var(--transicao);
}
.botao:hover { background: var(--cta-hover); text-decoration: none; }
.botao:focus-visible { box-shadow: var(--anel-foco); }
.botao:disabled, .botao[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.botao--secundario { background: hsl(var(--card)); border-color: hsl(var(--borda-forte)); color: hsl(var(--texto)); }
.botao--secundario:hover { background: hsl(var(--card-alto)); }
.botao--fantasma { background: transparent; color: hsl(var(--texto-suave)); }
.botao--fantasma:hover { background: hsl(var(--card)); color: hsl(var(--texto)); }
.botao--perigo { background: hsl(var(--vermelho)); }
.botao--perigo:hover { background: hsl(var(--vermelho) / .85); }
.botao--pequeno { height: 1.875rem; padding: 0 .625rem; font-size: .75rem; }
.botao--icone { width: 2.25rem; padding: 0; }
.botao svg { width: 1rem; height: 1rem; flex: none; }
.botao--carregando { color: transparent; position: relative; }
.botao--carregando .spinner-logo { position: absolute; inset: 0; margin: auto; width: 1.25rem; height: 1.25rem; }

/* ---------- Card (superficie com borda fina; a variante "vidro" e mantida por compatibilidade) ---------- */
.card {
  padding: 1rem 1.125rem;
  border: 1px solid hsl(var(--borda)); border-radius: var(--raio);
  background: hsl(var(--superficie));
}
.card--vidro { background: hsl(var(--superficie)); }
.card__titulo { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card__titulo h2, .card__titulo h3 { margin: 0; }

/* ---------- Cartao de indicador (numero grande + rotulo + nota), como os numeros do site ---------- */
.stat { display: grid; gap: .125rem; padding: .875rem 1.125rem; border: 1px solid hsl(var(--borda)); border-radius: var(--raio); background: hsl(var(--superficie)); }
.stat__valor { font-family: var(--f-mono); font-size: 1.5rem; font-weight: 500; line-height: 1.15; color: hsl(var(--texto)); }
.stat__rotulo { font-size: .8125rem; color: hsl(var(--texto)); }
.stat__nota { font-size: .75rem; color: hsl(var(--texto-suave)); }
.stat__nota:empty { display: none; }

/* ---------- Campos ---------- */
.campo { display: flex; flex-direction: column; gap: .3rem; }
.campo__rotulo { font-size: .8125rem; font-weight: 500; color: hsl(var(--texto)); }
.campo__entrada, .campo input, .campo select, .campo textarea {
  width: 100%; min-height: 2.375rem; padding: .45rem .7rem;
  border: 1px solid hsl(var(--borda-forte)); border-radius: var(--raio-p);
  background: hsl(var(--card)); color: hsl(var(--texto));
  transition: border-color var(--transicao), box-shadow var(--transicao);
}
.campo textarea { min-height: 5.5rem; resize: vertical; }
.campo input:focus-visible, .campo select:focus-visible, .campo textarea:focus-visible, .campo__entrada:focus-visible {
  border-color: var(--cta); box-shadow: 0 0 0 3px rgb(37 99 235 / .25);
}
.campo--erro input, .campo--erro select, .campo--erro textarea { border-color: hsl(var(--vermelho)); }
.campo__erro { font-size: .75rem; color: hsl(var(--vermelho)); }
.campo__erro:empty { display: none; }
.campo__ajuda { font-size: .75rem; color: hsl(var(--texto-suave)); }
.campo input::placeholder, .campo textarea::placeholder { color: hsl(var(--texto-suave)); } /* sem alfa: 4,5:1 nos dois temas (T-055) */
.campo input[type="file"] { padding: .375rem; }
.campo--linha { flex-direction: row; align-items: center; gap: .5rem; }
/* botoes de opcao e caixas dentro de .campo no tamanho proprio, junto do rotulo (T-085, AG-28: herdavam a largura e a
   altura das entradas de texto) */
.campo input[type="radio"], .campo input[type="checkbox"] {
  width: 1rem; height: 1rem; min-height: 0; padding: 0; margin: 0; flex: none; accent-color: var(--cta);
}

/* ---------- Tabela ---------- */
.tabela-envolto { width: 100%; overflow-x: auto; border: 1px solid hsl(var(--borda)); border-radius: var(--raio); }
.tabela { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.tabela th, .tabela td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid hsl(var(--borda)); vertical-align: middle; }
/* a celula continua celula (T-081, AG-41): uma classe utilitaria de flex (.linha, .pilha) no td dava a ela altura e
   borda proprias e o separador ficava no meio da linha; o layout das acoes vai num div dentro dela */
.tabela td { display: table-cell; }
.tabela th { font-family: var(--f-mono); font-size: .625rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: hsl(var(--texto-suave)); background: hsl(var(--card)); }
.tabela tbody tr:hover { background: hsl(var(--card)); }
.tabela tbody tr:last-child td, .tabela tbody tr:last-child th { border-bottom: 0; }
.tabela--clicavel tbody tr { cursor: pointer; }
.tabela__num { font-family: var(--f-mono); text-align: right; }
.tabela td small { display: block; }

/* ---------- Chips e badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .375rem;
  padding: .2rem .5rem; border-radius: .25rem;
  border: 1px solid hsl(var(--borda-forte)); background: hsl(var(--card));
  font-size: .75rem; font-weight: 500; color: hsl(var(--texto-suave)); text-decoration: none;
}
a.chip:hover { color: hsl(var(--texto)); text-decoration: none; border-color: hsl(var(--texto-suave)); }
button.chip { cursor: pointer; }
.chip--ativo { border-color: var(--cta); color: hsl(var(--texto)); background: rgb(37 99 235 / .18); }
/* Badges discretos: texto cinza, borda fina, cantos retos; o estado aparece so num ponto pequeno
   de cor contida (pedido do usuario em 2026-09-07: nada de pilulas vibrantes). */
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .05rem .45rem; border-radius: .25rem;
  font-size: .6875rem; font-weight: 500; line-height: 1.5; letter-spacing: .01em;
  border: 1px solid hsl(var(--borda-forte)); color: hsl(var(--texto-suave)); background: transparent;
}
.badge::before { content: ""; width: .375rem; height: .375rem; border-radius: 50%; background: hsl(var(--texto-suave) / .6); }
.badge--verde::before { background: hsl(var(--verde) / .75); }
.badge--amarelo::before { background: hsl(var(--amarelo) / .75); }
.badge--vermelho::before { background: hsl(var(--vermelho) / .8); }
.badge--azul::before { background: hsl(var(--primaria) / .75); }
.badge--neutro::before { display: none; }

/* ---------- Lista de itens (painel lateral, listas compactas) ---------- */
.lista-itens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.lista-itens__item { display: grid; gap: .25rem; padding: .625rem .75rem; border: 1px solid hsl(var(--borda)); border-radius: var(--raio-p); background: hsl(var(--card)); cursor: pointer; }
.lista-itens__item:hover, .lista-itens__item:focus-visible { border-color: hsl(var(--borda-forte)); }
.lista-itens__titulo { font-weight: 500; font-size: .8125rem; }
.lista-itens__meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .75rem; color: hsl(var(--texto-suave)); }
.lista-itens__acoes { display: flex; gap: .375rem; }

/* ---------- Painel lateral (direita) ---------- */
.painel-lateral {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(24rem, 100%); padding: 1rem 1.125rem; overflow-y: auto;
  border-left: 1px solid hsl(var(--borda)); background: hsl(var(--superficie));
  box-shadow: var(--sombra-lateral);
  transform: translateX(100%); transition: transform .2s ease-out;
}
.painel-lateral--aberto { transform: none; }
.painel-lateral__topo { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.painel-lateral__topo h2 { font-size: .9375rem; }
.painel-lateral__fundo { position: fixed; inset: 0; z-index: 49; background: rgb(0 0 0 / .45); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 1rem; background: rgb(0 0 0 / .6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.modal__caixa { width: 100%; max-width: 32rem; max-height: 90vh; overflow-y: auto; animation: modal-entra .15s ease-out; }
.modal__acoes { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
@keyframes modal-entra { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Toasts ---------- */
/* so texto: nao capturam clique, entao nunca tapam o botao que esta embaixo (a barra de salvar da T-056 fica no mesmo canto) */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 80; display: flex; flex-direction: column; gap: .5rem; max-width: min(24rem, calc(100% - 2rem)); pointer-events: none; }
.toast {
  padding: .625rem .875rem; border-radius: var(--raio-p);
  border: 1px solid hsl(var(--borda-forte)); background: hsl(var(--superficie)); color: hsl(var(--texto));
  box-shadow: var(--sombra-flutuante); font-size: .8125rem;
  animation: toast-entra .15s ease-out;
}
.toast--erro { border-color: hsl(var(--vermelho) / .6); }
.toast--ok { border-color: hsl(var(--verde) / .6); }
.toast--aviso { border-color: hsl(var(--amarelo) / .6); }
@keyframes toast-entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Spinner: a logo girando devagar (8 s por volta) ---------- */
.spinner-logo { width: 2.5rem; height: 2.5rem; display: block; animation: girar 8s linear infinite; }
.spinner-logo--grande { width: 4rem; height: 4rem; }
@keyframes girar { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.overlay-carregando { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem; background: var(--veu-carregando); }
.overlay-carregando__texto { font-size: .8125rem; color: hsl(var(--texto-suave)); }
@media (prefers-reduced-motion: reduce) { .spinner-logo { animation: none; } }

/* ---------- Utilidades ---------- */
.linha { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; }
.linha--entre { justify-content: space-between; }
.grade { display: grid; gap: .875rem; }
.grade--2 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grade--4 { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); }
/* itens de grade/flex nao podem forcar a pagina a alargar (heatmap de 53 semanas rola dentro do card) (T-041) */
.grade > *, .linha > *, .card { min-width: 0; }
.pilha { display: flex; flex-direction: column; gap: .75rem; }
.separador { height: 1px; background: hsl(var(--borda)); margin: 1rem 0; }
.fio-marca { height: 1px; background: hsl(var(--borda)); }
.vazio { padding: 1.75rem 1rem; text-align: center; font-size: .8125rem; color: hsl(var(--texto-suave)); border: 1px dashed hsl(var(--borda-forte)); border-radius: var(--raio); }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
