/* =========================================================================
   Premium SaaS Design System — "Paper & Signal" — tokens v2.0
   Fonte única da verdade. Componentes consomem SOMENTE os tokens semânticos
   (seção 2 em diante); primitivos (seção 1) só são lidos por este arquivo.

   Fontes (coloque no <head>):
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">

   Adaptar a uma marca: troque apenas os primitivos --brand-* (seção 1b),
   rode scripts/contrast_check.py e ajuste até passar. Ver references/adaptation.md.
   ========================================================================= */

:root {
  /* ---------- 1a. Primitivos neutros (papel quente → tinta) ---------- */
  --paper-0: #ffffff;
  --paper-50: #f7f6f3;   /* canvas */
  --paper-100: #f0efea;  /* fundo sutil / rebaixado */
  --paper-150: #e9e7e1;  /* hover sutil */
  --paper-200: #e4e2db;  /* hairline */
  --paper-400: #a8a59c;  /* desabilitado */
  --paper-500: #8a877e;  /* borda de input (3:1) */
  --ink-600: #6d6a63;    /* texto terciário */
  --ink-700: #57554e;    /* texto secundário */
  --ink-900: #1a1915;    /* texto principal — nunca #000 */

  /* ---------- 1b. Primitivos de marca (único ponto de troca) ---------- */
  --brand-50: #f1fbe8;
  --brand-100: #e3f6d1;
  --brand-500: #58cc02;  /* verde da marca: só fill, com texto tinta */
  --brand-600: #4fb802;
  --brand-700: #46a302;
  --brand-text: #2f6f00; /* texto e links verdes */
  --brand-ring: #347a00; /* foco e contornos */

  /* ---------- 2. Superfícies ---------- */
  --bg-canvas: var(--paper-50);
  --bg-surface: var(--paper-0);
  --bg-subtle: var(--paper-100);
  --bg-hover: var(--paper-150);
  --bg-inverse: var(--ink-900);
  --bg-overlay: rgb(26 25 21 / 0.45);

  /* ---------- 3. Texto ---------- */
  --fg: var(--ink-900);
  --fg-secondary: var(--ink-700);
  --fg-tertiary: var(--ink-600);
  --fg-disabled: var(--paper-400);
  --fg-inverse: var(--paper-50);
  --fg-on-accent: var(--ink-900);
  --fg-accent: var(--brand-text);

  /* ---------- 4. Bordas ---------- */
  --border: var(--paper-200);         /* divisórias e contornos de card */
  --border-strong: var(--paper-500);  /* inputs, checkbox, controles (≥3:1) */

  /* ---------- 5. Acento (uma única cor cromática de ação) ---------- */
  --accent: var(--brand-500);
  --accent-hover: var(--brand-600);
  --accent-active: var(--brand-700);
  --accent-subtle: var(--brand-50);
  --accent-subtle-hover: var(--brand-100);
  --focus-ring: var(--brand-ring);
  --accent-border: var(--brand-ring);

  /* ---------- 6. Status (apenas para comunicar estado) ---------- */
  --success: #1e874b;  --success-fg: #17693b;  --success-subtle: #e6f4ea;
  --warning: #b86e00;  --warning-fg: #8a4b00;  --warning-subtle: #fcf0d9;
  --danger: #c4321f;   --danger-fg: #b42318;   --danger-subtle: #fdecea;
  --info: #2f6fd1;     --info-fg: #1b5fb8;     --info-subtle: #e8f0fc;
  --fg-on-danger: #ffffff;

  /* ---------- 7. Visualização de dados (máx. 6 séries) ---------- */
  --chart-1: var(--brand-500);
  --chart-2: #0e8a7e;
  --chart-3: #c98408;
  --chart-4: #d6573f;
  --chart-5: #3a7fd5;
  --chart-6: #8a877e;
  --chart-grid: var(--paper-200);

  /* ---------- 8. Tipografia ---------- */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-display: var(--font-sans); /* marca pode trocar (ex.: serif editorial) — só ≥ 30px */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* tamanho / altura de linha / tracking */
  --fs-caption: 12px;    --lh-caption: 16px;
  --fs-body-sm: 13px;    --lh-body-sm: 20px;
  --fs-body: 14px;       --lh-body: 20px;
  --fs-body-lg: 16px;    --lh-body-lg: 24px;
  --fs-heading-sm: 18px; --lh-heading-sm: 26px;
  --fs-heading: 20px;    --lh-heading: 28px;    --ls-heading: -0.01em;
  --fs-heading-lg: 24px; --lh-heading-lg: 32px; --ls-heading-lg: -0.015em;
  --fs-display-sm: 30px; --lh-display-sm: 36px; --ls-display-sm: -0.02em;
  --fs-display: 36px;    --lh-display: 40px;    --ls-display: -0.02em;
  --fs-display-lg: 48px; --lh-display-lg: 52px; --ls-display-lg: -0.025em;
  --fs-display-xl: 60px; --lh-display-xl: 64px; --ls-display-xl: -0.03em;
  --fs-display-2xl: 72px;--lh-display-2xl: 76px;--ls-display-2xl: -0.03em;
  --ls-eyebrow: 0.06em;

  /* ---------- 9. Espaçamento (base 4px) ---------- */
  --space-0-5: 2px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;

  /* ---------- 10. Raios (hierarquia: controle < card < painel) ---------- */
  --radius-none: 0;
  --radius-xs: 2px;     /* barras de gráfico */
  --radius-sm: 6px;     /* badges, checkbox, tooltip, kbd */
  --radius-md: 12px;    /* botões, inputs, selects, itens de nav/menu */
  --radius-lg: 16px;    /* cards, popovers, menus, toasts */
  --radius-xl: 24px;    /* modais, painéis de destaque, cards de marketing */
  --radius-full: 9999px;/* chips, pills, avatares, switches, progress */

  /* ---------- 11. Elevação (somente camadas flutuantes) ---------- */
  --shadow-xs: 0 1px 2px rgb(26 25 21 / 0.06);
  --shadow-md: 0 4px 12px rgb(26 25 21 / 0.08), 0 1px 3px rgb(26 25 21 / 0.06);
  --shadow-lg: 0 16px 48px rgb(26 25 21 / 0.14), 0 2px 8px rgb(26 25 21 / 0.06);

  /* ---------- 12. Movimento ---------- */
  --duration-fast: 120ms;  /* hover, press, cor */
  --duration-base: 200ms;  /* menus, popovers, toggles */
  --duration-slow: 300ms;  /* modais, drawers */
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---------- 13. Layout e controles ---------- */
  --container-marketing: 1200px;
  --container-app: 1440px;
  --container-content: 960px;
  --container-form: 640px;
  --container-prose: 680px;
  --sidebar-width: 248px;
  --sidebar-collapsed: 64px;
  --topbar-height: 56px;
  --gutter: 16px;            /* 24px ≥768, 32px ≥1280 (ver base abaixo) */
  --section-gap: 64px;       /* marketing: 96px ≥1024 */

  --control-sm: 32px;
  --control-md: 40px;
  --control-lg: 48px;
  --row-height: 44px;
  --card-padding: 24px;
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
  --border-width: 1px;
  --focus-width: 2px;

  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-overlay: 1200;
  --z-modal: 1300;
  --z-toast: 1400;
  --z-tooltip: 1500;

  color-scheme: light;
}

/* ---------- Densidade compacta (tabelas densas, back-office) ---------- */
[data-density="compact"] {
  --control-md: 36px;
  --row-height: 36px;
  --card-padding: 16px;
  --fs-body: 13px;
  --lh-body: 20px;
}


/* ---------- Base obrigatória ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  font-feature-settings: "kern", "cv11";
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, p, figure { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-weight: var(--fw-semibold); color: var(--fg); text-wrap: balance; }
p { text-wrap: pretty; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--fg-accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--fg); }

:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: 2px;
}

::selection { background: var(--accent-subtle-hover); color: var(--fg); }

.tabular { font-variant-numeric: tabular-nums; }

@media (min-width: 768px) { :root { --gutter: 24px; } }
@media (min-width: 1024px) { :root { --section-gap: 96px; } }
@media (min-width: 1280px) { :root { --gutter: 32px; } }

@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;
  }
}
