/* ==========================================================================
   SaaS Premium UI · base.css
   Acabamentos globais que funcionam com qualquer direção visual.
   Requer os tokens da direção (references/direcoes-visuais.md) definidos antes.

   Escala do corpo: este arquivo NÃO fixa o tamanho do texto. Ele lê
   --text-body (e --leading-body, se existir) da direção. As direções de
   consumidor definem --text-body: 16px; as de ferramenta não definem, e o
   corpo cai no padrão de 14px. Assim, carregar este arquivo depois dos
   tokens não desfaz a escala de celular.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-body, 14px);   /* consumidor: 16px vem da direção */
  line-height: var(--leading-body, 1.5);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Títulos: tracking negativo cresce com o tamanho */
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); text-wrap: balance; }
h1 { letter-spacing: -0.025em; line-height: 1.2; }
h2 { letter-spacing: -0.02em;  line-height: 1.25; }
h3, h4 { letter-spacing: -0.01em; line-height: 1.35; }
p { margin: 0; text-wrap: pretty; }

/* Números que se alinham: tabelas, KPIs, valores, timers */
.tabular, table, [data-numeric] { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.92em; letter-spacing: -0.01em; }

/* Seleção de texto com a cor da marca */
::selection { background: var(--accent-subtle); color: var(--text); }

/* Foco: visível no teclado, invisível no clique.
   Sem border-radius aqui: o contorno já acompanha o raio do próprio elemento,
   e mudar o raio no foco deforma o componente (um chip em pílula vira
   retângulo arredondado só enquanto está focado). */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }

/* Scrollbars finas e discretas */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--text-tertiary); }
::-webkit-scrollbar-track { background: transparent; }

/* Atalhos de teclado */
kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500; line-height: 1;
  color: var(--text-secondary);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-bottom-width: 1.5px;
  border-radius: 4px;
}

/* Linha fina (divisor) */
.hairline { height: 1px; background: var(--border); border: 0; margin: 0; }

/* Skeleton: mesma forma do conteúdo final */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--surface-active), transparent);
  animation: skeleton-shimmer 1.6s var(--ease-in-out) infinite;
}
@keyframes skeleton-shimmer { to { transform: translateX(100%); } }

/* Indicador "ao vivo" */
.live-dot { position: relative; width: 6px; height: 6px; border-radius: 999px; background: var(--success); }
.live-dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit;
  background: var(--success); opacity: 0.35;
  animation: live-pulse 2s var(--ease-out) infinite;
}
@keyframes live-pulse { 0% { transform: scale(0.6); opacity: 0.5; } 100% { transform: scale(2); opacity: 0; } }

/* Transições padrão para elementos interativos */
a, button, [role="button"], input, select, textarea, .interactive {
  transition-property: color, background-color, border-color, box-shadow, opacity, transform, translate;
  transition-duration: var(--dur-1);
  transition-timing-function: var(--ease-out);
}
/* Pressionar afunda meio pixel. Usa a propriedade translate, e não transform,
   para somar ao transform que o componente já usa para se posicionar (botão
   centralizado com translate(-50%), ícone girado) em vez de apagá-lo. */
button:active:not(:disabled), [role="button"]:active { translate: 0 0.5px; }

/* Imagens e mídia */
img, svg, video { display: block; max-width: 100%; }

/* Acessibilidade: respeite quem pediu menos movimento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Só para leitores de tela */
.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;
}
