/* ApolloRisk — Mapa de Inteligência Regulatória
   VPS deploy — assets/style.css
   MF03C-7C.1 — Tema institucional ApolloRisk/BBA
   Dados: publicações reais do Radar ApolloRisk
*/

/* ── Tokens de design ── */
:root {
  --bg-page:      #f0f4f8;
  --bg-surface:   #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-header:    #0f2040;
  --bg-canvas:    #eef2f7;
  --blue-900:     #0f2040;
  --blue-700:     #1B3A6B;
  --blue-500:     #2563EB;
  --blue-400:     #3b82f6;
  --blue-200:     #bfdbfe;
  --red:          #dc2626;
  --orange:       #d97706;
  --green:        #16a34a;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --border:         #e2e8f0;
  --border-strong:  #cbd5e1;
  --canvas-text:    #1e293b;
  --canvas-muted:   #475569;
  --canvas-border:  #dde4f0;
}

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

body {
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ── */
#header {
  background: var(--bg-header);
  border-bottom: 1px solid #1e3a5f;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#header .brand      { color: #fbbf24; font-weight: bold; font-size: 15px; letter-spacing: 0.01em; }
#header .breadcrumb { color: #93c5fd; font-size: 12px; }
#header .proto-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.08);
  color: #93c5fd;
  border: 1px solid #2563EB;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
}

/* ── Seção de busca e trending ── */
#search-section {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
#search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#search-input {
  flex: 1;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: 5px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
#search-input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
#search-input::placeholder { color: var(--text-muted); }
#search-btn, #clear-btn {
  background: var(--blue-500);
  border: 1px solid var(--blue-500);
  color: #fff;
  border-radius: 6px;
  font-family: inherit;
  font-size: 11px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
#search-btn:hover { background: var(--blue-400); border-color: var(--blue-400); }
#clear-btn {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}
#clear-btn:hover { border-color: var(--red); color: var(--red); }

/* Trending row */
#trending-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.trending-label {
  color: var(--blue-700);
  font-size: 10px;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
}
#chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.chip-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--blue-700);
  border-radius: 12px;
  font-family: inherit;
  font-size: 10px;
  padding: 2px 9px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip-btn:hover {
  background: #dbeafe;
  border-color: var(--blue-500);
  color: var(--blue-500);
}

/* Slice group */
#slice-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.slice-label {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
}
.slice-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  font-family: inherit;
  font-size: 9px;
  padding: 2px 7px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.slice-btn:hover { border-color: var(--blue-500); color: var(--blue-500); }
.slice-btn.active { background: #eff6ff; border-color: var(--blue-500); color: var(--blue-500); font-weight: bold; }

/* ── Filtros ── */
#filter-bar {
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
#filter-bar .label { color: var(--text-muted); font-size: 11px; margin-right: 4px; }
.filter-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--blue-500); color: var(--blue-500); }
.filter-btn.active { background: var(--blue-500); border-color: var(--blue-500); color: #fff; font-weight: bold; }
.filter-btn.type-tema.active  { background: #1B3A6B; border-color: #1B3A6B; color: #fff; }
.filter-btn.type-orgao.active { background: #d97706; border-color: #d97706; color: #fff; }
.filter-btn.type-norma.active { background: #16a34a; border-color: #16a34a; color: #fff; }
.filter-btn.type-fonte.active { background: #7c3aed; border-color: #7c3aed; color: #fff; }
.filter-btn.type-sinal.active { background: var(--red); border-color: var(--red); color: #fff; }
#btn-reset {
  margin-left: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
#btn-reset:hover { border-color: var(--blue-500); color: var(--blue-500); }

/* ── Nota contextual de filtro ── */
#filter-note {
  display: none;
  background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  padding: 6px 16px;
  font-size: 10px;
  color: #92400e;
  flex-shrink: 0;
}
#filter-note .fn-icon { margin-right: 6px; }
#filter-note .fn-link {
  color: var(--blue-500);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}

/* ── Layout principal ── */
#main { display: flex; flex: 1; overflow: hidden; }

/* ── Área do grafo (canvas azul-cinza muito claro, institucional) ── */
#cy-container {
  flex: 1;
  position: relative;
  background: var(--bg-canvas);
  border-right: 1px solid var(--canvas-border);
  border-top: 1px solid var(--canvas-border);
}
#cy { width: 100%; height: 100%; }

/* Dica no grafo (modo guiado) — estilo claro para canvas claro */
#guided-hint {
  display: none;
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--blue-400);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--blue-700);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}

/* Tooltip de hover */
#tooltip {
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--blue-500);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  pointer-events: none;
  display: none;
  max-width: 220px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
#tooltip .t-label { color: var(--blue-500); font-weight: bold; margin-bottom: 3px; }
#tooltip .t-type  { color: var(--text-muted); font-size: 10px; margin-bottom: 2px; }
#tooltip .t-count { color: var(--text-secondary); font-size: 10px; }
#tooltip .t-demo  { display: none; }

/* Erro de carregamento */
#load-error {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-surface);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 20px 24px;
  text-align: center;
  color: var(--red);
  font-size: 12px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* ── Painel lateral ── */
#side-panel {
  width: 290px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
#side-panel .panel-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--blue-700);
  font-size: 12px;
  font-weight: bold;
  background: var(--bg-surface-2);
}
#side-panel .panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}
#side-panel .panel-body::-webkit-scrollbar { width: 4px; }
#side-panel .panel-body::-webkit-scrollbar-track { background: var(--bg-surface-2); }
#side-panel .panel-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.panel-empty {
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  padding: 40px 10px;
  line-height: 1.6;
}

/* Node card */
.node-card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.node-card .nc-label   { font-size: 13px; font-weight: bold; color: var(--text-primary); margin-bottom: 2px; }
.node-card .nc-type    { font-size: 10px; color: var(--text-muted); margin-bottom: 6px; }
.node-card .nc-summary { font-size: 11px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.node-card .nc-count   { font-size: 11px; color: var(--text-secondary); }
.node-card .nc-count span { color: var(--blue-500); }

/* Maturity box */
.maturity-box {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
.maturity-box .mb-title { color: var(--orange); font-size: 10px; font-weight: bold; margin-bottom: 4px; }
.maturity-box .mb-line  { color: #78350f; font-size: 10px; line-height: 1.5; }

/* Conexões */
.connections-title {
  color: var(--blue-700);
  font-size: 11px;
  font-weight: bold;
  margin-bottom: 8px;
}
.connection-item {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.connection-item .ci-target  { font-size: 11px; font-weight: bold; color: var(--text-primary); margin-bottom: 3px; }
.connection-item .ci-explain { font-size: 10px; color: var(--text-secondary); line-height: 1.4; margin-bottom: 3px; }
.connection-item .ci-weight  { font-size: 9px; color: var(--orange); }

/* Legenda */
.legend-section {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}
.legend-title { color: var(--blue-700); font-size: 11px; font-weight: bold; margin-bottom: 8px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 10px;
  color: var(--text-secondary);
}
.legend-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid transparent;
}
.legend-diamond {
  width: 10px; height: 10px;
  flex-shrink: 0;
  border: 2px solid var(--green);
  transform: rotate(45deg);
  background: rgba(22,163,74,0.1);
}

/* ── Rodapé ── */
#footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-muted);
  gap: 12px;
  flex-wrap: wrap;
}
#footer .footer-left  { display: flex; gap: 16px; flex-wrap: wrap; }
#footer .footer-item  { display: flex; gap: 4px; }
#footer .footer-item .fi-label { color: var(--text-muted); }
#footer .footer-item .fi-val   { color: var(--text-secondary); }
#footer .footer-right { color: var(--blue-700); font-size: 9px; font-weight: 600; }

/* ── Lista de publicações ── */
.pub-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.pub-item:last-of-type { border-bottom: none; }
.pub-impact {
  font-size: 9px;
  font-weight: bold;
  border: 1px solid;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.pub-content { flex: 1; min-width: 0; }
.pub-title {
  display: block;
  color: var(--blue-500);
  font-size: 11px;
  line-height: 1.4;
  text-decoration: none;
  word-break: break-word;
}
.pub-title:hover { text-decoration: underline; color: var(--blue-700); }
.pub-title-nolink {
  display: block;
  color: var(--text-primary);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}
.pub-meta {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}
.pub-temas {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}
.pub-tema-tag {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--blue-700);
  border-radius: 3px;
  font-size: 9px;
  padding: 1px 5px;
}
.pub-link-btn {
  color: var(--blue-500);
  font-size: 10px;
  text-decoration: none;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 2px 7px;
  background: #eff6ff;
  transition: all 0.15s;
}
.pub-link-btn:hover { background: #dbeafe; border-color: var(--blue-500); }
.pub-warning {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  color: #92400e;
  font-size: 10px;
  padding: 6px 8px;
  margin-bottom: 8px;
}
.pub-noresult {
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  padding: 30px 10px;
  line-height: 1.6;
}

/*
  forced-color-adjust: none restrito aos controles interativos.
  Justificativa: em Windows High Contrast (forced-colors: active) o OS substitui
  as cores de botões/inputs pela paleta do sistema, tornando os tokens institucionais
  invisíveis. Aplicar apenas nos componentes de UI que dependem da paleta BBA.
  O canvas do grafo (#cy-container) NÃO recebe este ajuste — arestas e nós claros
  funcionam bem sob forced-colors.
*/
/*
  #cy-container incluído: o fundo claro institucional (#eef2f7) é fundamental
  para legibilidade dos nós — sem ele, o canvas fica preto em HC mode e os
  nós com borda clara ficam ilegíveis.
*/
#search-section,
#filter-bar,
#side-panel,
#footer,
#cy-container,
.chip-btn,
.filter-btn,
.slice-btn,
#search-btn,
#clear-btn,
#btn-reset {
  forced-color-adjust: none;
}

/* Acessibilidade */
.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;
}

/* Banner de maturidade (não usado, preservado) */
#maturity-banner {
  background: var(--bg-surface-2);
  border-bottom: 1px solid #fcd34d;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#maturity-banner .icon { color: var(--orange); font-size: 14px; }
#maturity-banner .text { color: var(--text-primary); font-size: 11px; line-height: 1.4; }
#maturity-banner .text strong { color: var(--orange); }
#maturity-banner .bar-track {
  width: 80px; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
#maturity-banner .bar-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Responsivo básico */
@media (max-width: 768px) {
  #side-panel { display: none; }
  #filter-bar { gap: 4px; }
  #slice-group { display: none; }
  #trending-row { flex-wrap: wrap; }
}
