/* =================================================================
   CPF.CNPJ — Documentação API (custom.css)
   Refinamentos de layout, tipografia e ergonomia visual.
   Base: theDocs.all.min.css (template oficial)
   ================================================================= */

/* ---------- Variáveis de tema ---------- */
:root {
  --doc-accent: #2c8eff;
  --doc-accent-hover: #1f6fd8;
  --doc-array: #4a7eaf;
  --doc-object: #8d6cab;
  --doc-string: #2e7d32;
  --doc-int: #c62828;
  --doc-bool: #ef6c00;
  --doc-float: #ad1457;
  --doc-null: #757575;
  --doc-pkg-cpf: #2e7d32;
  --doc-pkg-cnpj: #1565c0;
  --doc-code-bg: #f6f8fa;
  --doc-code-border: #e1e4e8;
  --doc-table-header: #f3f5f7;
  --doc-table-stripe: #fafbfc;
  --doc-info-bg: #eef6ff;
  --doc-info-border: #2c8eff;
  --doc-warning-bg: #fff8e6;
  --doc-warning-border: #f0a500;
  --doc-success-bg: #effaf0;
  --doc-success-border: #2e7d32;
}

/* ---------- Tipografia geral ---------- */
.tdContent h2 {
  margin-top: 2.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid #e8eaee;
  letter-spacing: -0.01em;
  scroll-margin-top: 80px;
}

.tdContent h3,
.tdContent h4,
.tdContent h5 {
  margin-top: 2rem;
  scroll-margin-top: 80px;
  font-weight: 600;
}

.tdContent h5 {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  background: linear-gradient(180deg, #f6f8fa 0%, #eceff3 100%);
  border-left: 4px solid var(--doc-accent);
  border-radius: 0 6px 6px 0;
  font-size: 1.05rem;
  color: #2c3e50;
}

.tdContent h5[id^="array_"] {
  border-left-color: var(--doc-array);
}

.tdContent h5[id^="objeto_"] {
  border-left-color: var(--doc-object);
}

.tdContent h5 + p {
  margin-top: 0.6rem;
}

/* ---------- Code inline ---------- */
.tdContent code {
  padding: 2px 6px;
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.875em;
  background: var(--doc-code-bg);
  border: 1px solid var(--doc-code-border);
  border-radius: 4px;
  color: #24292e;
}

/* ---------- Bloco de código (JSON examples) ---------- */
.tdContent pre {
  position: relative;
  padding: 1rem 1.2rem;
  background: #1e1e2e;
  color: #cdd6f4;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

.tdContent pre code {
  padding: 0;
  background: transparent;
  border: none;
  color: inherit;
  font-size: inherit;
}

/* JSON syntax highlighting (manual, leve) */
.tdContent pre code.language-json {
  white-space: pre;
}

/* ---------- Tabelas ---------- */
.tdContent .table {
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e1e4e8;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.92rem;
}

.tdContent .table > thead > tr > th {
  padding: 0.7rem 0.9rem;
  background: var(--doc-table-header);
  border-bottom: 2px solid #d1d5da;
  font-weight: 600;
  color: #24292e;
  text-transform: none;
  letter-spacing: 0;
}

.tdContent .table > tbody > tr > td {
  padding: 0.7rem 0.9rem;
  border-top: 1px solid #ebedf0;
  vertical-align: top;
}

.tdContent .table-striped > tbody > tr:nth-of-type(odd) > td {
  background: var(--doc-table-stripe);
}

.tdContent .table > tbody > tr:hover > td {
  background: #f0f7ff !important;
  transition: background-color 0.15s ease;
}

/* Primeira coluna (nome do parâmetro) destacada */
.tdContent .table > tbody > tr > td:first-child {
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.88em;
  color: #24292e;
  white-space: nowrap;
  font-weight: 500;
}

/* Segunda coluna (tipo) com badges */
.tdContent .table > tbody > tr > td:nth-child(2) {
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.85em;
  color: #6a737d;
}

.tdContent .table > tbody > tr > td:nth-child(2) b {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.95em;
}

/* Cores por tipo */
.tdContent .table > tbody > tr > td:nth-child(2):has(a[href^="#array_"]) b {
  color: var(--doc-array);
  background: rgba(74, 126, 175, 0.1);
}

.tdContent .table > tbody > tr > td:nth-child(2):has(a[href^="#objeto_"]) b {
  color: var(--doc-object);
  background: rgba(141, 108, 171, 0.1);
}

/* ---------- Notas info/warning ---------- */
.tdContent p > small i.fa-info-circle {
  color: var(--doc-info-border);
  margin-right: 4px;
}

.tdContent p > small {
  display: inline-block;
  padding: 0.5rem 0.8rem;
  background: var(--doc-info-bg);
  border-left: 3px solid var(--doc-info-border);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  color: #444;
  width: 100%;
  margin: 0.4rem 0;
}

/* ---------- Sidenav melhorado ---------- */
.tdNav {
  scroll-behavior: smooth;
}

.tdNav ul li a {
  transition: background-color 0.12s ease, color 0.12s ease;
  border-left: 2px solid transparent;
}

.tdNav ul li a:hover {
  background: #f0f7ff;
  color: var(--doc-accent);
}

.tdNav ul li a.active,
.tdNav ul li.active > a {
  background: #e6f0ff;
  color: var(--doc-accent-hover);
  border-left-color: var(--doc-accent);
  font-weight: 600;
}

.tdNav ul ul li a {
  padding-left: 1.6rem;
  font-size: 0.92rem;
}

.tdNav ul ul ul li a {
  padding-left: 2.4rem;
  font-size: 0.86rem;
  color: #6a737d;
}

.tdNav ul ul ul li a span[data-wg-notranslate] {
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.92em;
}

/* ---------- Pacote IDs table ---------- */
#pacotes + table {
  font-size: 0.92rem;
}

#pacotes + table tr td:first-child {
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Badges para pacotes especiais ---------- */
.pkg-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75em;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 4px;
}

.pkg-badge-cpf { background: #e8f5e9; color: var(--doc-pkg-cpf); }
.pkg-badge-cnpj { background: #e3f2fd; color: var(--doc-pkg-cnpj); }
.pkg-badge-realtime { background: #fff3e0; color: #e65100; }
.pkg-badge-new { background: #fce4ec; color: #c2185b; }

/* ---------- URL examples ---------- */
.tdContent code[data-wg-notranslate] {
  word-break: break-all;
}

/* ---------- Anchor links em h2-h5 ---------- */
.tdContent h2[id]:hover::after,
.tdContent h3[id]:hover::after,
.tdContent h4[id]:hover::after,
.tdContent h5[id]:hover::after {
  content: " #";
  color: var(--doc-accent);
  opacity: 0.5;
  font-weight: 400;
}

/* ---------- Responsivo ---------- */
@media (max-width: 768px) {
  .tdContent .table {
    font-size: 0.84rem;
  }
  .tdContent .table > tbody > tr > td,
  .tdContent .table > thead > tr > th {
    padding: 0.5rem 0.6rem;
  }
  .tdContent pre {
    font-size: 0.75rem;
    padding: 0.7rem;
  }
}

/* ---------- Scrollbar fina ---------- */
.tdContent pre::-webkit-scrollbar {
  height: 8px;
}
.tdContent pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.tdContent pre::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ---------- Headers de seção exemplos ---------- */
#exemplos_respostas + p + h4 {
  margin-top: 1.2rem;
}

.tdContent h4[id^="exemplo_pacote_"] {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  background: linear-gradient(135deg, #2c8eff 0%, #1f6fd8 100%);
  color: #fff;
  border-radius: 6px;
  font-size: 1rem;
  margin-top: 1.5rem;
  box-shadow: 0 2px 6px rgba(44, 142, 255, 0.25);
}

.tdContent h4[id^="exemplo_pacote_24"],
.tdContent h4[id^="exemplo_pacote_27"] {
  background: linear-gradient(135deg, #c2185b 0%, #880e4f 100%);
  box-shadow: 0 2px 6px rgba(194, 24, 91, 0.25);
}

/* ---------- Print ---------- */
@media print {
  .tdNav, .tdHeader, .tdFooter { display: none !important; }
  .tdContent { width: 100% !important; padding: 0 !important; }
  .tdContent pre { background: #f6f8fa !important; color: #24292e !important; border: 1px solid #ddd !important; }
  .tdContent a { color: #24292e !important; text-decoration: underline; }
}

/* ---------- Lista PPE/programas com ícones ---------- */
.tdContent ul.tdLi {
  list-style: none;
  padding-left: 0;
}

.tdContent ul.tdLi li::before {
  content: "▸ ";
  color: var(--doc-accent);
  font-weight: bold;
  margin-right: 4px;
}

/* ---------- TOC fixo no topo ao scrollar (já existe no template) ---------- */
.tdContent section {
  margin-bottom: 3rem;
  padding-top: 1rem;
}

/* ---------- Visual upgrade do botão "ver no idioma X" ---------- */
.tdContent a[target="_blank"]::after {
  content: " ↗";
  font-size: 0.85em;
  opacity: 0.6;
}
