/* ============================================================================
   CultBR Gestão · Portal de Documentação Técnica
   Identidade visual derivada dos tokens reais do produto (globals.css --ds-*).
   Zero dependências de build. Light theme, WCAG 2.2 AA.
   ============================================================================ */

/* ---------- 1. Tokens ---------- */
:root {
  /* Marca */
  --brand:        #006fee;   /* Brand/Primary Main (Figma) */
  --brand-dark:   #0052b3;
  --brand-darker: #02326a;
  --brand-soft:   #e6f1fe;
  --brand-bg:     #f3f8ff;
  --gov:          #32529f;   /* Gov.br institucional */
  --accent:       #fecf43;   /* Amarelo Aldir Blanc */
  --accent-dark:  #d4a82a;

  /* Semânticas — foregrounds escurecidos p/ WCAG 2.2 AA (texto ≥4.5:1) */
  --ok:        #15803d;  --ok-bg:    #f0fdf4;  --ok-bd:   #bbf7d0;
  --warn:      #b45309;  --warn-bg:  #fffbeb;  --warn-bd: #fde68a;
  --info:      #0e7490;  --info-bg:  #ecfeff;  --info-bd: #a5f3fc;
  --danger:    #b91c1c;  --danger-bg:#fef2f2;  --danger-bd:#fecaca;
  --draft:     #6d28d9;  --draft-bg: #f5f3ff;  --draft-bd:#ddd6fe;

  /* Neutros */
  --ink:      #0f1729;
  --ink-2:    #33415c;
  --ink-3:    #5b6b8c;
  --line:     #e3e8f0;
  --line-2:   #eef1f6;
  --surface:  #ffffff;
  --surface-2:#f7f9fc;
  --surface-3:#eef2f8;

  /* Tipografia — Poppins espelha a UI do produto (globals.css --font-poppins) */
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Forma */
  --r-sm: 4px; --r: 8px; --r-lg: 12px; --r-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(13,13,13,.04);
  --shadow:    0 1px 3px rgba(13,13,13,.06), 0 1px 2px rgba(13,13,13,.04);
  --shadow-lg: 0 12px 32px -14px rgba(15,23,41,.16);
  --table-head: #f3f4f6;

  /* Layout */
  --sidebar: 252px;
  --toc: 232px;
  --maxw: 1640px;
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { color: var(--ink); line-height: 1.25; letter-spacing: -.012em; font-weight: 680; margin: 0; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- 3. App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0,1fr); min-height: 100vh; }

/* gov.br bar */
.govbar { display: flex; align-items: center; gap: 12px; padding: 6px 22px; background: #fff; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--ink-3); }
.govbar img { height: 15px; width: auto; display: block; }
.govbar__sep { width: 1px; height: 13px; background: var(--line); flex: none; }
.govbar__org { font-weight: 600; color: var(--ink-2); }
.govbar__spacer { flex: 1; }
.govbar__env { font-size: 11.5px; }
@media (max-width: 860px) { .govbar__env { display: none; } }

/* Sidebar -------------------------------------------------------------- */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  background: #ffffff;
  color: var(--ink-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.sidebar__brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--line); }
.sidebar__brand a { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; color: var(--ink); text-decoration: none; }
.sidebar__logo { height: 30px; width: auto; display: block; }
.sidebar__mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: var(--accent); color: #06122a;
  display: grid; place-items: center; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 14px rgba(254,207,67,.35);
}
.sidebar__title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; color: var(--ink); }
.sidebar__sub { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }

.nav { padding: 14px 12px 24px; }
.nav__label { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3); padding: 14px 12px 7px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 1px 0; border-radius: 9px;
  color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--brand-bg); color: var(--brand-dark); }
.nav a.is-active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; box-shadow: none; }
.nav a.is-active .nav__num { background: var(--brand); color:#fff; }
.nav__num {
  width: 22px; height: 22px; flex: none; border-radius: 6px;
  background: var(--surface-3); color: var(--ink-3);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; font-family: var(--mono);
}
.sidebar__foot { margin-top: auto; padding: 16px 20px 22px; font-size: 11.5px; color: var(--ink-3); border-top: 1px solid var(--line); }

/* Main ----------------------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 13px 30px; background: rgba(255,255,255,.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs { font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-3); font-weight: 500; }
.crumbs a:hover { color: var(--brand-dark); }
.crumbs .sep { color: var(--line); }
.crumbs b { color: var(--ink); font-weight: 600; }
.topbar__spacer { flex: 1; }
.topbar__tag { font-size: 11.5px; font-weight: 600; color: var(--ink-3); padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }

.menu-btn { display: none; }

.content { display: grid; grid-template-columns: minmax(0,1fr) var(--toc); gap: 44px; max-width: var(--maxw); width: 100%; margin: 0 auto; padding: 40px 44px 80px; }
.doc { min-width: 0; }

/* ---------- 4. Hero ---------- */
.hero { margin-bottom: 34px; }
.hero__eyebrow { display:inline-flex; align-items:center; gap:8px; font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-dark); margin-bottom: 14px; }
.hero__eyebrow::before { content:""; width: 26px; height: 3px; border-radius: 2px; background: var(--accent); }
.hero h1 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 720; }
.hero__lead { font-size: 17.5px; line-height: 1.6; color: var(--ink-2); max-width: 70ch; margin-top: 14px; }
.hero--home { padding: 40px 42px 30px; border-radius: var(--r-xl); color: var(--ink-2); background: linear-gradient(180deg, #f3f8ff 0%, #ffffff 72%); border: 1px solid var(--line); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.hero--home::before { content:""; position:absolute; left:0; top:0; bottom:0; width:5px; background: linear-gradient(180deg, var(--brand) 0%, var(--gov) 100%); }
.hero--home h1 { color: var(--ink); font-size: clamp(30px, 3.8vw, 44px); }
.hero--home .hero__lead { color: var(--ink-2); max-width: 66ch; }
.hero--home .hero__eyebrow { color: var(--brand-dark); }
.hero__lockup { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.hero__lockup span { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.hero__lockup img { height: 30px; width: auto; opacity: .92; }

/* ---------- 5. Sections ---------- */
.doc section { scroll-margin-top: 84px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin: 46px 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.sec-head h2 { font-size: 23px; font-weight: 700; }
.sec-head__no { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--brand-dark); }
.doc h3 { font-size: 17.5px; margin: 30px 0 12px; }
.doc p { margin: 0 0 14px; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 22px; }
.doc li { margin: 5px 0; }
.lead-p { font-size: 16.5px; color: var(--ink-2); }

/* ---------- 6. Cards ---------- */
.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-sm); }

/* Module cards (home) */
.mod-card {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 24px; text-decoration: none; color: inherit; position: relative;
  box-shadow: var(--shadow-sm); transition: transform .16s ease, box-shadow .16s ease, border-color .16s;
  overflow: hidden;
}
.mod-card::before { content:""; position:absolute; inset:0 auto 0 0; width: 4px; background: var(--brand); opacity: .85; }
.mod-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #cfe0fb; text-decoration: none; }
.mod-card__top { display: flex; align-items: center; gap: 13px; }
.mod-card__ic { width: 44px; height: 44px; flex: none; border-radius: 11px; background: var(--brand-bg); display: grid; place-items: center; }
.mod-card__ic img { width: 23px; height: 23px; }
.mod-card__no { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--brand-dark); letter-spacing: .04em; }
.mod-card h3 { font-size: 18px; margin: 0; }
.mod-card p { font-size: 14px; color: var(--ink-3); margin: 0; line-height: 1.55; }
.mod-card__meta { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }

/* Stat / metric */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin: 6px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 18px 16px; box-shadow: var(--shadow-sm); }
.stat__n { font-size: 30px; font-weight: 760; color: var(--ink); letter-spacing: -.02em; font-family: var(--mono); }
.stat__l { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* ---------- 7. Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px; border: 1px solid; line-height: 1.5; white-space: nowrap; }
.badge::before { content:""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--ok    { color: var(--ok);     background: var(--ok-bg);     border-color: var(--ok-bd); }
.badge--warn  { color: var(--warn);   background: var(--warn-bg);   border-color: var(--warn-bd); }
.badge--info  { color: var(--info);   background: var(--info-bg);   border-color: var(--info-bd); }
.badge--danger{ color: var(--danger); background: var(--danger-bg); border-color: var(--danger-bd); }
.badge--draft { color: var(--draft);  background: var(--draft-bg);  border-color: var(--draft-bd); }
.badge--gov   { color: var(--gov);    background: #eef1fb;          border-color: #d3dcf4; }
.badge--lg { font-size: 12.5px; padding: 5px 12px; }

/* Status legend (3 states) */
.legend { display: flex; flex-wrap: wrap; gap: 18px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
/* Forma distinta por estado (não depende só de cor — WCAG 1.4.1): círculo / quadrado / losango */
.dot { width: 10px; height: 10px; flex: none; border-radius: 50%; }
.dot--ok   { background: var(--ok);   border-radius: 50%; }                          /* círculo */
.dot--warn { background: var(--warn); border-radius: 2px; }                          /* quadrado */
.dot--info { background: var(--info); border-radius: 1px; transform: rotate(45deg); } /* losango */

/* ID chip (RN-001, RB-FORM-03...) */
.id { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--brand-dark); background: var(--brand-soft); padding: 1px 7px; border-radius: 5px; white-space: nowrap; }
.kbd { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 7px; border-radius: 5px; color: var(--ink); }

/* ---------- 8. Tables ---------- */
.tw { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; overflow-x: auto; box-shadow: var(--shadow-sm); margin: 0 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { background: var(--table-head); text-align: left; font-weight: 680; color: var(--ink); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12.5px; letter-spacing: .01em; }
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
table .id { font-size: 11.5px; }
.t-center { text-align: center; }
/* sim/não com glyph + texto (não depende só de cor; contraste AA) */
.yes { color: var(--ok); font-weight: 700; }
.yes::before { content: "✓ "; }
.no  { color: var(--ink-3); font-weight: 600; }
.no::before { content: "✕ "; }

/* ---------- 9. Callouts ---------- */
.callout { display: flex; gap: 14px; padding: 16px 18px; border-radius: var(--r); border: 1px solid; margin: 4px 0 20px; font-size: 14px; }
.callout__ic { flex: none; width: 22px; height: 22px; }
.callout__bd { min-width: 0; }
.callout__bd strong { color: var(--ink); }
.callout--info  { background: var(--brand-bg); border-color: #cfe0fb; }
.callout--warn  { background: var(--warn-bg);  border-color: var(--warn-bd); }
.callout--diverge { background: var(--info-bg); border-color: var(--info-bd); }

/* Doc canônica / Drive */
.docref { background: linear-gradient(180deg,#fff, var(--surface-2)); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; margin: 26px 0 8px; box-shadow: var(--shadow-sm); }
.docref h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 12px; }
.docref__paths { font-family: var(--mono); font-size: 12px; color: var(--ink-2); line-height: 1.9; }
.docref__paths span { display:block; }
.btn-drive { display: inline-flex; align-items: center; gap: 9px; margin-top: 14px; padding: 10px 16px; background: var(--brand); color: #fff; font-weight: 600; font-size: 14px; border-radius: 9px; box-shadow: 0 6px 16px -6px rgba(0,111,238,.6); transition: background .15s; }
.btn-drive:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }

/* ---------- 10. State machine ---------- */
.fsm { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 26px 24px; margin: 6px 0 20px; box-shadow: var(--shadow-sm); overflow-x: auto; }
.fsm__flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.state {
  display: inline-flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 11px 15px; border-radius: 11px; border: 1.5px solid var(--line);
  background: var(--surface-2); min-width: 120px;
}
.state__t { font-weight: 680; font-size: 14px; color: var(--ink); }
.state__d { font-size: 12.5px; color: var(--ink-3); }
.state--start { border-color: #bcd3f7; background: var(--brand-bg); }
.state--start .state__t { color: var(--brand-dark); }
.state--end   { border-color: var(--ok-bd); background: var(--ok-bg); }
.state--end .state__t { color: var(--ok); }
.state--alt   { border-color: var(--danger-bd); background: var(--danger-bg); }
.state--alt .state__t { color: var(--danger); }
.state--mid   { border-color: var(--warn-bd); background: var(--warn-bg); }
.arrow { display: inline-flex; flex-direction: column; align-items: center; color: var(--ink-3); min-width: 56px; }
.arrow__l { font-size: 12px; font-weight: 600; color: var(--ink-3); text-align: center; line-height: 1.25; margin-bottom: 1px; }
.arrow__line { display: flex; align-items: center; color: var(--brand); }
.arrow__line::before { content:""; height: 2px; width: 38px; background: currentColor; border-radius: 2px; }
.arrow__line::after { content:"▶"; font-size: 10px; margin-left: -2px; }
.fsm__note { font-size: 12.5px; color: var(--ink-3); margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* vertical fsm rows */
.fsm-rows { display: flex; flex-direction: column; gap: 0; }

/* ---------- 11. Definition list / glossary ---------- */
.gloss { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 12px; }
.gloss div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 16px; box-shadow: var(--shadow-sm); }
.gloss dt { font-weight: 700; color: var(--ink); font-size: 14px; }
.gloss dd { margin: 3px 0 0; font-size: 13px; color: var(--ink-3); line-height: 1.5; }

/* pill list of actions */
.pills { display: flex; flex-wrap: wrap; gap: 7px; margin: 4px 0 16px; }
.pill { font-family: var(--mono); font-size: 12px; padding: 4px 10px; border-radius: 7px; background: var(--surface-3); border: 1px solid var(--line); color: var(--ink-2); }

/* ---------- 12. TOC ---------- */
.toc { position: sticky; top: 84px; align-self: start; height: max-content; font-size: 13px; }
.toc__t { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; margin-bottom: 12px; }
.toc a { display: block; padding: 5px 12px; color: var(--ink-3); border-left: 2px solid var(--line); transition: color .15s, border-color .15s; }
.toc a:hover { color: var(--brand-dark); text-decoration: none; border-color: #bcd3f7; }
.toc a.is-active { color: var(--brand-dark); font-weight: 600; border-color: var(--brand); }

/* ---------- 13. Footer ---------- */
.foot { border-top: 1px solid var(--line); padding: 26px 44px; color: var(--ink-3); font-size: 13px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; max-width: var(--maxw); margin: 0 auto; width: 100%; }
.foot img { height: 26px; opacity: .82; }
.foot__logos { display: flex; align-items: center; gap: 18px; }

/* prev/next */
.pager { display: flex; gap: 14px; margin-top: 40px; }
.pager a { flex: 1; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s; }
.pager a:hover { border-color: #cfe0fb; transform: translateY(-2px); text-decoration: none; }
.pager small { color: var(--ink-3); font-size: 12px; }
.pager b { display: block; color: var(--ink); font-size: 15px; margin-top: 2px; }
.pager .next { text-align: right; }

/* ---------- 14. Responsive ---------- */
@media (max-width: 1180px) {
  .content { grid-template-columns: minmax(0,1fr); }
  .toc { display: none; }
}
@media (max-width: 980px) {
  .grid--3, .grid--2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  :root { --sidebar: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: 280px; transform: translateX(-100%); transition: transform .25s ease; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content:""; position: fixed; inset:0; background: rgba(6,18,42,.5); z-index: 50; }
  .menu-btn { display: inline-grid; place-items:center; width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
  .menu-btn span, .menu-btn span::before, .menu-btn span::after { content:""; display:block; width: 17px; height: 2px; background: var(--ink); border-radius: 2px; position: relative; }
  .menu-btn span::before { position:absolute; top:-5px; } .menu-btn span::after { position:absolute; top:5px; }
  .content { padding: 26px 20px 64px; }
  .topbar { padding: 11px 18px; }
  .foot { padding: 22px 20px; }
}

/* print */
@media print {
  .sidebar, .toc, .topbar, .pager, .menu-btn { display: none !important; }
  .app, .content { display: block; }
  .card, .fsm, .tw { box-shadow: none; break-inside: avoid; }
}
