/* ============================================================
   Transparência Rio do Campo — tema visual
   ============================================================ */
:root {
  --orange: #FF6A13;
  --orange-soft: #FF8C42;
  --bg: #0B1118;
  --bg-2: #0F1620;
  --panel: #16202B;
  --panel-2: #1B2733;
  --text: #E7ECF2;
  --muted: #9AA7B4;
  --grid: #243240;
  --border: #22303C;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #14202c 0%, var(--bg) 60%);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 26px;
  background: rgba(11, 17, 24, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-link { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.brand-strong { color: var(--orange); }
.brand-light { color: var(--text); }
.brand-tag { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; margin-top: 2px; }

.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-link {
  padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  transition: all .15s ease; white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--panel); }
.nav-link.active { color: #fff; background: var(--orange); }

/* Botão hambúrguer — escondido no desktop, exibido no mobile via media query */
.nav-toggle {
  display: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  padding: 8px 13px;
  cursor: pointer;
}
.nav-toggle:hover { background: var(--panel-2); }

/* ---------- Layout ---------- */
.content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 26px 50px; }
.page-head { margin: 6px 0 22px; }
.page-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
.page-title .accent { color: var(--orange); }
.page-lead { color: var(--muted); font-size: 15px; max-width: 760px; margin: 0; }

.section-head { margin: 28px 0 12px; }
.section-title { font-size: 18px; font-weight: 700; margin: 0; }
.section-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 12px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 .card { margin-bottom: 0; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- KPI ---------- */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 8px;
}
@media (max-width: 860px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-row { grid-template-columns: 1fr; } }
.kpi-card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 12px; padding: 16px 18px;
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.kpi-value { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter { display: flex; flex-direction: column; gap: 5px; min-width: 180px; }
/* Largura real (não só um mínimo) — evita rótulo cortado tipo "Ordinária
   0015/2026 — 2…" quando o valor selecionado é mais longo que 260px. Cresce
   até 460px e depois para; em telas estreitas, a media query mobile abaixo
   volta para width:100% sem max-width. */
.filter-wide { min-width: 260px; width: 100%; max-width: 460px; }
.filter label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Paginador (ex.: Ranking por beneficiário) ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; }
.pager-btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.pager-btn:hover { background: var(--panel); border-color: var(--orange); color: var(--orange-soft); }
.pager-label { font-size: 12.5px; color: var(--muted); min-width: 200px; text-align: center; }

/* Dash dropdown (react-select) no tema escuro */
.Select-control, .is-focused:not(.is-open) > .Select-control { background: var(--panel-2) !important; border-color: var(--border) !important; color: var(--text) !important; border-radius: 10px !important; }
/* z-index explícito e !important: o CSS que o próprio dash-core-components
   injeta em runtime (.dash-dropdown .Select-menu-outer) tem 2 classes de
   especificidade contra a nossa 1, então uma regra simples aqui perderia a
   cascata mesmo carregando depois — !important garante que o menu aberto
   sempre fique acima do header (z-index 50) e de qualquer seção vizinha. */
.Select-menu-outer {
  background: var(--panel-2) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  z-index: 200 !important;
}
.Select-value-label, .Select-placeholder, .Select-input > input { color: var(--text) !important; }
/* Rótulo selecionado (dropdown fechado): uma linha só, com reticências se
   ainda assim não couber — nunca quebra em 2 linhas dentro da caixa. */
.Select-value-label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Opções do menu aberto: cada opção é uma linha de altura fixa (ver
   optionHeight=42 em dcc.Dropdown, pages/camara.py) — texto mais longo que a
   largura precisa de reticências, NUNCA quebrar em 2 linhas. Quebrar era o
   bug real: a opção só tem 35px de altura mas o texto de 2 linhas precisa de
   ~40px, e como o overflow não é cortado, a segunda linha vazava por cima da
   opção seguinte (mesma posição absoluta, sem espaçamento entre elas) —
   tornava o clique na opção certa pouco confiável perto da borda de cada
   linha. Com nowrap + ellipsis o texto sempre cabe na altura da caixa.
*/
.VirtualizedSelectOption {
  background: var(--panel-2) !important;
  color: var(--text) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 14px !important;
}
.VirtualizedSelectFocusedOption { background: var(--orange) !important; color: #fff !important; }
.Select.is-focused > .Select-control { box-shadow: 0 0 0 2px rgba(255,106,19,.35) !important; }

/* ---------- Tabelas (dash_table) ---------- */
.dash-table-container { font-size: 13.5px; }
.dash-spreadsheet-container .dash-spreadsheet-inner table { border-collapse: collapse; }

/* O dash_table define suas próprias CSS custom properties (--hover: #fdfdfd quase
   branco, --accent: hotpink, --selected-background: vermelho translúcido) na mesma
   selector chain usada aqui. Isso deixa a linha em hover com fundo claro e o texto
   claro do tema escuro some (ilegível). O <style> interno do dash_table é injetado
   pelo React DEPOIS do nosso <link rel="stylesheet">, então com especificidade igual
   a regra dele venceria a nossa — por isso o !important abaixo é necessário, não
   estético. Corrige hover/seleção/acento em TODAS as tabelas do site (theme.data_table
   é o único ponto de criação de DataTable — ver pages/*.py). */
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner table {
  --hover: rgba(255, 255, 255, 0.06) !important;
  --selected-background: rgba(255, 106, 19, 0.18) !important;
  --accent: var(--orange) !important;
  --text-color: var(--text) !important;
  --background-color-ellipses: var(--panel-2) !important;
}
/* Reforço direto na célula: fundo sutil + texto legível na linha em hover, e nas
   células focada/selecionada (navegação por teclado ou clique). */
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner tr:hover td {
  background-color: rgba(255, 255, 255, 0.06) !important;
  color: var(--text) !important;
}
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner td.focused,
.dash-table-container .dash-spreadsheet-container .dash-spreadsheet-inner td.cell--selected {
  background-color: rgba(255, 106, 19, 0.18) !important;
  color: var(--text) !important;
  box-shadow: inset 0 0 0 1px var(--orange) !important;
}

/* Tabela de sessões da Câmara: a linha inteira é clicável (abre o resumo/pauta da
   sessão em "cam-sessao-dd") — cursor de ponteiro comunica isso visualmente. */
#cam-sessoes-table .dash-spreadsheet-container .dash-spreadsheet-inner td {
  cursor: pointer;
}

/* ---------- Análises / relatórios ---------- */
.tabs { display: flex; gap: 8px; margin: 6px 0 20px; border-bottom: 1px solid var(--border); }
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.report-card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  transition: border-color .15s ease, transform .15s ease; cursor: pointer; height: 100%;
}
.report-card:hover { border-color: var(--orange); transform: translateY(-2px); }
.report-card .tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--orange); }
.report-card h3 { margin: 8px 0 6px; font-size: 16px; }
.report-card .meta { font-size: 12px; color: var(--muted); }
.report-card .resumo { font-size: 13.5px; color: var(--text); opacity: .85; margin-top: 8px; }

.report-body {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 28px; line-height: 1.65; box-shadow: var(--shadow);
}
.report-body h1 { font-size: 26px; border-bottom: 2px solid var(--orange); padding-bottom: 8px; }
.report-body h2 { font-size: 20px; margin-top: 26px; color: var(--orange-soft); }
.report-body h3 { font-size: 16px; margin-top: 18px; }
.report-body table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 14px; }
.report-body th, .report-body td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.report-body th { background: var(--panel-2); }
.report-body blockquote { border-left: 3px solid var(--orange); margin: 12px 0; padding: 4px 14px; color: var(--muted); background: var(--bg-2); }
.report-body code { background: var(--bg-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--orange); font-weight: 600; }
.empty-state { text-align: center; color: var(--muted); padding: 50px 20px; }

/* ---------- Selo de conteúdo gerado por IA (avaliações e resumos de sessão) ---------- */
.ia-badge {
  display: inline-block;
  background: rgba(255, 106, 19, 0.12);
  border: 1px solid var(--orange);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--orange-soft);
  margin: 4px 0 10px;
}

/* ---------- Itens de pauta (painel de sessão) ---------- */
.pauta-lista { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.pauta-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--bg-2); }
.pauta-item-titulo { font-weight: 600; color: var(--orange-soft); margin-bottom: 4px; }
.pauta-item-texto { font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.pauta-item-resultado { margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--orange-soft); }
.pauta-item-resultado.muted { color: var(--muted); font-weight: 500; }

/* ---------- Bloco recolhível "Como esta análise foi feita" ---------- */
.details-metodologia {
  margin: 10px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--bg-2);
}
.details-metodologia summary { cursor: pointer; font-weight: 600; color: var(--orange-soft); }
.details-metodologia ul { margin: 10px 0 4px; padding-left: 20px; }
.details-metodologia li { margin-bottom: 4px; }

/* ---------- Ficha do candidato (página Votos) ---------- */
.ficha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.ficha-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ficha-k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.ficha-v { font-size: 14.5px; font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 22px 26px 30px;
  max-width: 1180px; margin: 0 auto; width: 100%;
  display: flex; flex-direction: column; gap: 6px; font-size: 13.5px;
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; opacity: .8; }
.dot { color: var(--orange); }

/* ============================================================
   MOBILE — o público acessa majoritariamente pelo celular
   ============================================================ */
@media (max-width: 768px) {
  .site-header { padding: 11px 15px; }
  .brand-link { font-size: 18px; }
  .brand-tag { display: none; }            /* economiza espaço no topo */

  .nav-toggle { display: block; }          /* mostra o hambúrguer */

  /* menu vira dropdown sob o cabeçalho */
  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: rgba(11, 17, 24, 0.98);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .site-header.nav-open .nav { display: flex; }
  .nav-link {
    width: 100%;
    border-radius: 8px;
    padding: 14px 16px;                    /* alvo de toque confortável */
    font-size: 16px;
  }

  .content { padding: 16px 14px 36px; }
  .page-title { font-size: 22px; }
  .page-lead { font-size: 14px; }
  .section-title { font-size: 16px; }
  .section-head { margin: 20px 0 10px; }

  .card { padding: 14px 12px 8px; }
  .kpi-value { font-size: 22px; }
  .kpi-card { padding: 14px 14px; }

  /* filtros (dropdowns) em largura cheia, empilhados */
  .filters { gap: 10px; }
  .filter { min-width: 0; width: 100%; }

  /* relatórios em 1 coluna */
  .report-list { grid-template-columns: 1fr; }
  .report-body { padding: 18px 15px; }
  .report-body h1 { font-size: 21px; }
  .report-body h2 { font-size: 17px; }
  .report-body table { font-size: 12.5px; }
  .report-body th, .report-body td { padding: 6px 8px; }

  .site-footer { padding: 18px 15px 28px; }
}

/* telas bem estreitas */
@media (max-width: 380px) {
  .page-title { font-size: 20px; }
  .kpi-value { font-size: 20px; }
}

/* ===== TOOLTIPS DIDÁTICOS (glossario.py) ===== */
.with-info { display: inline-flex; align-items: center; gap: .35rem; }
.info-icon {
  cursor: help; position: relative; font-size: .85em; opacity: .65;
  outline: none;
}
.info-icon:hover, .info-icon:focus { opacity: 1; }
.info-icon::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: 130%; transform: translateX(-50%);
  width: max-content; max-width: 270px; padding: .6rem .75rem;
  background: #1c2333; color: #e8ecf4; border: 1px solid #3a4661;
  border-radius: 8px; font-size: .8rem; line-height: 1.35; text-align: left;
  white-space: normal; z-index: 999;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .15s ease;
}
.info-icon:hover::after, .info-icon:focus::after { opacity: 1; visibility: visible; }
@media (max-width: 640px) {
  .info-icon::after { left: auto; right: -8px; transform: none; max-width: 82vw; }
}
