/* =========================================================
   BIA+ ENHANCEMENTS (2026-04-21)
   Melhorias visuais e funcionais aditivas para:
   - BIAplus.html
   - pages/participacoes.html
   - pages/recorrencia.html

   Aditivo: NÃO sobrescreve regras essenciais de biaplus.css,
   recorrencia.css, landing.css etc. Apenas complementa.
   ========================================================= */

/* ---------- Tokens locais (não conflitam com tokens.css) ---------- */
:root {
  --bia-enh-border: rgba(255, 255, 255, 0.08);
  --bia-enh-border-hover: rgba(56, 189, 248, 0.35);
  --bia-enh-chip-bg: rgba(56, 189, 248, 0.1);
  --bia-enh-chip-text: #cfe3ff;
  --bia-enh-danger: #ef4444;
  --bia-enh-soft-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

/* =========================================================
   1) Navbar: destaque da página ativa (elegante, não invasivo)
   ========================================================= */
.navbar__link.is-active,
.bia-nav__chip.is-active,
.navbar a[aria-current="page"] {
  color: #e5f1ff;
  opacity: 1;
  background: rgba(56, 189, 248, 0.1);
  box-shadow: inset 0 -2px 0 rgba(56, 189, 248, 0.9);
}

@media (max-width: 520px) {
  .navbar__link.is-active,
  .bia-nav__chip.is-active {
    box-shadow: inset 0 -2px 0 rgba(56, 189, 248, 0.75);
  }
}

/* =========================================================
   2) Cabeçalho do filtro + botão colapsar
   ========================================================= */
.filters-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 10px;
}

.filters-topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.filters-topbar__title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bia-muted, #9aa6bb);
  font-weight: 700;
  white-space: nowrap;
}

.filters-topbar__active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.filters-topbar__active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bia-enh-chip-bg);
  color: var(--bia-enh-chip-text);
  border: 1px solid var(--bia-enh-border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.filters-topbar__active-chip b {
  opacity: 0.65;
  font-weight: 500;
  margin-right: 2px;
}

.filters-topbar__right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.btn.filters-clear,
.btn.filters-toggle {
  appearance: none;
  border: 1px solid var(--bia-enh-border);
  background: transparent;
  color: var(--bia-muted, #9aa6bb);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: none;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}

.btn.filters-clear:hover,
.btn.filters-toggle:hover {
  border-color: var(--bia-enh-border-hover);
  color: #e5f1ff;
  background: rgba(56, 189, 248, 0.06);
}

.btn.filters-clear {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn.filters-clear:hover {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.08);
  color: #fecaca;
}

.filters-toggle__chev {
  display: inline-block;
  transition: transform 0.18s ease;
  font-size: 10px;
  line-height: 1;
}

.filters.is-collapsed .filters-body,
.filters.is-collapsed .chips-clubes,
.filters.is-collapsed #chips-pos-wrap,
.filters.is-collapsed #chips-pos,
.filters.is-collapsed .filters-clubes-header,
.filters.is-collapsed #status-badges,
.filters.is-collapsed #chips,
.filters.is-collapsed .filters-body > * {
  display: none !important;
}

.filters.is-collapsed .filters-toggle__chev {
  transform: rotate(-90deg);
}

/* A toolbar de cima (busca, sliders, cores) permanece visível mesmo colapsado */
.filters.is-collapsed .toolbar.space {
  margin-bottom: 0;
}

/* =========================================================
   3) Contador de linhas mais visível
   ========================================================= */
.table-meta,
.table-header .table-meta,
.page--biaplus .table-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.table-meta #count,
.table-header .table-meta #count {
  font-weight: 700;
  color: #e5f1ff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.table-meta__label {
  color: var(--bia-muted, #9aa6bb);
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* =========================================================
   4) Numerais tabulares (alinhamento de casas decimais)
   ========================================================= */
.page--biaplus #grid td.num,
.page--biaplus #grid td[data-num="1"],
.page--biaplus #grid thead th[data-num],
.page--recorrencia #grid td[data-num="1"],
.page--recorrencia #grid td.num {
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   5) Coluna ordenada com destaque sutil (só página Participações)
   ========================================================= */
.page--biaplus #grid th.sorted,
.page--biaplus #grid td.sorted {
  background-color: rgba(56, 189, 248, 0.035);
}

.page--biaplus #grid th.sorted {
  color: #e5f1ff;
  box-shadow: inset 0 -2px 0 rgba(56, 189, 248, 0.45);
}

/* =========================================================
   6) BIAplus — Seletor de colunas (dropdown)
   ========================================================= */
.col-picker-wrap {
  position: relative;
  display: inline-flex;
}

.col-picker {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 220px;
  max-height: 380px;
  overflow-y: auto;
  background: linear-gradient(180deg, #0f1721, #0b111b);
  border: 1px solid var(--bia-enh-border);
  border-radius: 14px;
  padding: 8px 6px;
  box-shadow: var(--bia-enh-soft-shadow), 0 14px 40px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.col-picker.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.col-picker__title {
  padding: 8px 12px 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bia-muted, #9aa6bb);
  font-weight: 700;
  border-bottom: 1px solid var(--bia-enh-border);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.col-picker__reset {
  font-size: 10px;
  color: var(--bia-accent, #38bdf8);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 600;
}

.col-picker__reset:hover {
  text-decoration: underline;
}

.col-picker__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: #cfe3ff;
  font-size: 12.5px;
  user-select: none;
  transition: background 0.12s ease;
}

.col-picker__item:hover {
  background: rgba(56, 189, 248, 0.06);
}

.col-picker__item input[type="checkbox"] {
  accent-color: #38bdf8;
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.col-picker__item.is-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================================
   7) BIAplus — Pílulas de filtro por Tendência
   ========================================================= */
.trend-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #111a28;
  color: #cfd6e3;
  border: 1px solid #253349;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.trend-chip:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.trend-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.trend-chip[data-trend="FORTE"] {
  color: #86efac;
}
.trend-chip[data-trend="MÉDIO"] {
  color: #fde68a;
}
.trend-chip[data-trend="NEUTRO"] {
  color: #fdba74;
}
.trend-chip[data-trend="FRACO"] {
  color: #fca5a5;
}

.trend-chip.active[data-trend="FORTE"] {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.65);
}
.trend-chip.active[data-trend="MÉDIO"] {
  background: rgba(250, 204, 21, 0.18);
  border-color: rgba(250, 204, 21, 0.6);
}
.trend-chip.active[data-trend="NEUTRO"] {
  background: rgba(251, 146, 60, 0.18);
  border-color: rgba(251, 146, 60, 0.6);
}
.trend-chip.active[data-trend="FRACO"] {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.6);
}

/* =========================================================
   8) Recorrência — Toggle Mandante/Visitante
   ========================================================= */
.mando-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--bia-enh-border);
  padding: 3px;
  border-radius: 999px;
  gap: 2px;
}

.mando-toggle__btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--bia-muted, #9aa6bb);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.mando-toggle__btn:hover {
  color: #e5f1ff;
}

.mando-toggle__btn.is-active {
  background: linear-gradient(180deg, #1a2535, #101824);
  color: #e5f1ff;
  box-shadow:
    inset 0 0 0 1px rgba(56, 189, 248, 0.45),
    0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Esconder colunas conforme toggle */
.page--recorrencia body.mando-only-home #grid th.col-away,
.page--recorrencia body.mando-only-home #grid td.col-away,
body.mando-only-home #grid th.col-away,
body.mando-only-home #grid td.col-away,
body.mando-only-home #grid .group-away {
  display: none !important;
}

.page--recorrencia body.mando-only-away #grid th.col-home,
.page--recorrencia body.mando-only-away #grid td.col-home,
body.mando-only-away #grid th.col-home,
body.mando-only-away #grid td.col-home,
body.mando-only-away #grid .group-home {
  display: none !important;
}

/* Divisor mais forte entre MANDANTE e VISITANTE */
#grid thead .group-away,
#grid thead th.group-away,
#grid thead .head-cols th.col-away[data-first-away="1"] {
  border-left: 2px solid rgba(255, 255, 255, 0.16) !important;
}

body.mando-both #grid td.col-away[data-first-away="1"] {
  border-left: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* =========================================================
   9) Recorrência — Micro-barras em células de %
   ========================================================= */
.rec-pct-cell {
  position: relative;
  min-width: 70px;
  padding-right: 12px !important;
  padding-left: 12px !important;
}

.rec-pct-cell .rec-pct-bar {
  display: block;
  height: 3px;
  margin-top: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.rec-pct-cell .rec-pct-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width 0.28s ease;
  min-width: 2px;
}

body.heat-on .rec-pct-cell .rec-pct-bar {
  background: rgba(255, 255, 255, 0.12);
}

/* =========================================================
   10) Recorrência — Filtro de % mínima (range discreto)
   ========================================================= */
.rec-minpct {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #0b1118;
  border: 1px solid var(--bia-border, #1f2937);
  min-height: 40px;
}

.rec-minpct span {
  color: var(--bia-muted, #9aa6bb);
  font-size: 12px;
}

.rec-minpct input[type="range"] {
  width: 140px;
  max-width: 100%;
}

.rec-minpct .rec-minpct-val {
  font-variant-numeric: tabular-nums;
  color: #e5f1ff;
  font-weight: 700;
  font-size: 12px;
  min-width: 32px;
  text-align: right;
}

/* =========================================================
   11) Participações — control de G+A mínimo (pill)
   ========================================================= */
.participa-minga {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #0b1118;
  border: 1px solid var(--bia-border, #1f2937);
  min-height: 40px;
}

.participa-minga span {
  color: var(--bia-muted, #9aa6bb);
  font-size: 12px;
  white-space: nowrap;
}

.participa-minga input[type="range"] {
  width: 130px;
  max-width: 100%;
}

.participa-minga .participa-minga-val {
  font-variant-numeric: tabular-nums;
  color: #e5f1ff;
  font-weight: 700;
  font-size: 12px;
  min-width: 22px;
  text-align: right;
}

/* =========================================================
   12) Padronização de casing dos labels
   (Apenas enforce de "sentence case" visual; não mexe
   no conteúdo em JS que é fonte de dados)
   ========================================================= */
.page--biaplus .filters-label,
.page--biaplus label[for="chips"],
.page--biaplus label[for="chips-pos"],
.page--biaplus label[for="status-badges"],
.page--biaplus .filters-clubes-header label,
.page--recorrencia .filters-label,
.page--recorrencia .filters-clubes-header label {
  text-transform: none !important;
  letter-spacing: 0.01em !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--bia-muted, #9aa6bb);
}

/* =========================================================
   13) Softening de estados "ativo" ruidosos
   Reduz o halo externo em chips/badges inativos — mantém intenso só no ativo.
   ========================================================= */
.page--biaplus .chip:not(.active),
.page--biaplus .badge:not(.active) {
  box-shadow: none;
}

.page--biaplus .chip:not(.active):hover {
  box-shadow: inset 0 0 0 1px var(--bia-enh-border-hover);
}

/* =========================================================
   14) Responsivo — mobile da topbar de filtros e toggles
   ========================================================= */
@media (max-width: 640px) {
  .filters-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filters-topbar__left {
    order: 2;
    flex-wrap: wrap;
  }

  .filters-topbar__right {
    order: 1;
    justify-content: flex-end;
  }

  .filters-topbar__active-chips {
    width: 100%;
  }

  .mando-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .mando-toggle__btn {
    flex: 1 1 0;
    padding: 8px 0;
    font-size: 10.5px;
  }

  .rec-minpct,
  .participa-minga {
    width: 100%;
  }

  .rec-minpct input[type="range"],
  .participa-minga input[type="range"] {
    flex: 1 1 auto;
    width: auto;
  }

  .trend-filter-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .trend-filter-row::-webkit-scrollbar {
    display: none;
  }
  .trend-chip {
    flex: 0 0 auto;
  }

  .col-picker {
    right: auto;
    left: 0;
    min-width: min(280px, 90vw);
  }
}

/* =========================================================
   15) Dropdown coluna: tirar em telas muito estreitas (evita quebra)
   ========================================================= */
@media (max-width: 360px) {
  #btn-cols {
    display: none !important;
  }
}

/* =========================================================
   16) Zebra aprimorada (sutil)
   Já existe zebra em biaplus.css; aqui só normaliza o alfa
   para que heatmap e sorted não fiquem poluídos.
   ========================================================= */
.page--biaplus tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.008);
}

.page--biaplus tbody tr:nth-child(odd) {
  background-color: transparent;
}

/* =========================================================
   17) Sort-hint e indicador de ordenação elegante (recorrência)
   ========================================================= */
.page--recorrencia #grid thead th.sorted {
  color: #e5f1ff;
  box-shadow: inset 0 -2px 0 rgba(56, 189, 248, 0.45);
}

.page--recorrencia #grid thead th.sort-hint {
  color: var(--bia-muted);
}

/* =========================================================
   18) Oculta botão toggle se filtro não tiver body
   ========================================================= */
.filters:not(:has(.filters-body, #chips, #chips-pos, #status-badges))
  .btn.filters-toggle {
  display: none;
}

/* =========================================================
   19) BIA+ table polish (2026-04-23)
   Aditivo sobre biaplus.css:
   - zebra striping mais legível (ficou sutil/quase imperceptível)
   - separador vertical entre grupos (Identidade | Volume | Cartola
     | FBref Avançada | Tendência)
   - tabular-nums em todas as células para alinhamento de dígitos
   - nome do jogador com peso maior
   - célula vazia FBref com affordance visual e cursor 'help'
   ========================================================= */

/* zebra striping reforçado — encaixa na paleta existente */
.page--biaplus #grid tbody tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.045);
}
.page--biaplus #grid tbody tr:nth-child(odd) {
  background: transparent;
}
.page--biaplus #grid tbody tr:hover {
  background: rgba(56, 189, 248, 0.08);
}

/* alinhamento numérico e fonte de números — estende o que já existe
   em #grid td.num pra TODAS as células, inclusive texto */
.page--biaplus #grid thead th,
.page--biaplus #grid tbody td {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* nome do jogador ganha presença */
.page--biaplus #grid tbody td[data-k="Nome"] .link-like {
  font-weight: 600;
  letter-spacing: 0.005em;
}

/* === Separadores verticais de grupo =====================
   A classe .col-group-start é adicionada pelo JS às th/td que
   iniciam um novo bloco lógico. A borda é discreta e só aparece
   quando existe coluna à esquerda. */
.page--biaplus #grid thead th.col-group-start,
.page--biaplus #grid tbody td.col-group-start {
  border-left: 1px solid rgba(148, 163, 184, 0.14);
  box-shadow: inset 1px 0 0 rgba(56, 189, 248, 0.05);
}

/* === Célula vazia de origem FBref =======================
   Mostra cursor 'help' e uma opacidade mais baixa no '—',
   reforçando que o dado está faltante por falta de vínculo. */
.page--biaplus #grid tbody td.cell-missing-fbref {
  cursor: help;
  color: rgba(185, 198, 218, 0.45);
  position: relative;
}
.page--biaplus #grid tbody td.cell-missing-fbref::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.55);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.page--biaplus #grid tbody td.cell-missing-fbref:hover::after {
  opacity: 1;
}

/* Header sticky já existe em biaplus.css (position:sticky em thead th).
   Reforço apenas o z-index pra ficar acima de badges/heatmap bg. */
.page--biaplus #grid thead th {
  z-index: 3;
}
