/* =====================================================================
   ui2 - MODAL DE FILTROS POR CATEGORIA (peca da fundacao)
   ---------------------------------------------------------------------
   Markup: ui2/components/filtros.php. Comportamento: ui2/js/filtros.js.
   So entra na pagina que pede a peca: 'css' => [ ..., 'filtros' ].

   Desktop: dialogo de duas colunas (topos com estado misto a esquerda,
   subcategorias por letra a direita, regua A a Z), fichas do que esta
   marcado e rodape com o numero no botao. Ate 720 px: folha de baixo para
   cima em tela cheia, os topos viram abas que rolam de lado.
   Cor, raio e sombra saem dos tokens; movimento some com reduced-motion.
   ===================================================================== */

/* ------------------------------------------------- botao que abre */
.fx-abrir {
  display: inline-flex; align-items: center; gap: 9px; height: 44px; padding: 0 14px 0 16px; max-width: 100%;
  border: var(--bd); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink);
  font: 600 var(--fs-sm)/1 var(--font-body); cursor: pointer; white-space: nowrap;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.fx-abrir:hover { border-color: var(--ink); }
.fx-abrir > .i { width: 17px; height: 17px; color: var(--accent); }
.fx-abrir-r { min-width: 0; max-width: 190px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--muted); }
.fx-abrir-n {
  min-width: 22px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center;
  border-radius: var(--r-pill); background: var(--accent); color: var(--on-dark); font-size: 11.5px;
}
.fx-abrir .fx-abrir-c { width: 14px; height: 14px; color: var(--muted); }
.fx-abrir.is-on { border-color: var(--accent); background: var(--accent-soft); }
.fx-abrir.is-on .fx-abrir-r { color: var(--accent-ink); }

/* ------------------------------------- filtro atual na pagina (sem JS) */
.fx-fichas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fx-fichas-t { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.fx-ficha { gap: 6px; transition: background-color .2s ease, color .2s ease; }
.fx-ficha .i { width: 12px; height: 12px; }
a.fx-ficha:hover, button.fx-ficha:hover { background: var(--accent); color: var(--on-dark); }
.fx-limpar { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); }
.fx-limpar .i { width: 12px; height: 12px; }
.fx-limpar:hover { color: var(--accent-ink); text-decoration: underline; }

/* ------------------------------------------------------- o dialogo */
html.fx-aberto { overflow: hidden; }
.fx {
  width: min(1100px, calc(100vw - 48px)); max-width: none;
  height: min(800px, calc(100vh - 48px)); max-height: none;
  padding: 0; border: 0; border-radius: var(--r-card); overflow: hidden;
  background: var(--surface); color: var(--text); box-shadow: var(--sh-pop);
  font: 400 var(--fs-body)/1.5 var(--font-body);
}
/* o ::backdrop nao herda variavel antes do Chrome 122: o valor e o --plum a 55% */
.fx::backdrop { background: rgba(25, 28, 43, .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.fx[open] { animation: fx-entra .22s ease; }
.fx[open]::backdrop { animation: fx-fundo .22s ease; }
.fx--sem-modal { position: fixed; inset: 0; margin: auto; z-index: 1000; box-shadow: 0 0 0 100vmax rgba(25, 28, 43, .55), var(--sh-pop); }
@keyframes fx-entra { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fx-fundo { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-sobe { from { transform: translateY(100%); } to { transform: none; } }

.fx-box { position: relative; display: flex; flex-direction: column; height: 100%; }
.fx-box::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--grad-brand); }

/* cabecalho */
.fx-hd { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 24px 26px 16px; }
.fx-hd-ico {
  width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center;
  background: var(--grad-brand); color: var(--on-dark); box-shadow: var(--sh-card);
}
.fx-hd-ico .i { width: 22px; height: 22px; }
.fx-hd h2 { font-size: 1.4rem; }
.fx-hd p { margin-top: 3px; font-size: var(--fs-sm); color: var(--muted); }
.fx-hd-nota { display: inline-block; margin-left: 4px; padding: 1px 9px; border-radius: var(--r-pill); background: var(--amber-soft); color: var(--amber); font-size: var(--fs-xs); font-weight: 600; }
.fx-hd h2:focus { outline: none; }
.fx-x {
  width: 42px; height: 42px; display: grid; place-items: center; border: var(--bd); border-radius: 50%;
  background: var(--surface); color: var(--ink); cursor: pointer; transition: background .2s ease, border-color .2s ease;
}
.fx-x:hover { background: var(--surface-2); border-color: var(--ink); }
.fx-x .i { width: 18px; height: 18px; }

/* busca + marcar tudo + contagem */
.fx-tools { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; padding: 0 26px 14px; }
.fx-q { position: relative; flex: 1 1 380px; min-width: 0; }
.fx-q > .i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.fx-q .input { height: 48px; padding-left: 46px; background: var(--surface-2); }
.fx-q .input:focus { background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.fx-acoes { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; }
.fx-lk {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 4px; border: 0; background: none; cursor: pointer;
  font: 600 var(--fs-xs)/1 var(--font-body); color: var(--accent); border-radius: var(--r-sm);
}
.fx-lk .i { width: 14px; height: 14px; }
.fx-lk:hover { color: var(--accent-ink); text-decoration: underline; }
.fx-conta { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fx-meter { width: 84px; height: 6px; }
.fx-meter > i { background: var(--grad-brand); width: var(--v, 100%); transition: width .2s ease; }

/* fichas do que esta marcado */
.fx-sel { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 26px 14px; max-height: 96px; overflow: auto; }
.fx-sel:empty { display: none; }
.fx-sel .fx-ficha { border: 0; cursor: pointer; font-family: var(--font-body); }
.fx-ficha-tudo .i { width: 12px; height: 12px; }
.fx-ficha-mais { border: 0; background: none; padding: 3px 6px; cursor: pointer; font: 600 11.5px/1.45 var(--font-body); color: var(--accent); }
.fx-ficha-mais:hover { text-decoration: underline; }

/* corpo: topos | subcategorias */
.fx-corpo { flex: 1; min-height: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); border-top: 1px solid var(--line-soft); }

.fx-tops { display: flex; flex-direction: column; gap: 6px; padding: 14px 12px 14px 14px; overflow: auto; background: var(--surface-2); border-right: 1px solid var(--line-soft); overscroll-behavior: contain; }
.fx-top {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex: none;
  border: 1px solid transparent; border-radius: 16px; transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.fx-top:hover { background: var(--surface); }
.fx-top.is-on { background: var(--surface); border-color: var(--line); box-shadow: var(--sh-card); }
.fx-top.is-on::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--grad-brand); }
.fx-top--grupo { margin-left: 18px; }
.fx-top--grupo::after {
  content: ""; position: absolute; left: -11px; top: -8px; width: 9px; height: calc(50% + 8px);
  border-left: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); border-bottom-left-radius: 9px;
}
.fx-top-b {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 0; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit;
}
.fx-top-b:focus-visible { outline-offset: 6px; border-radius: 10px; }
.fx-top-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.fx-top-ico .i { width: 20px; height: 20px; }
[data-fx-top="plugin"] .fx-top-ico, [data-fx-pai="plugin"] .fx-top-ico { background: var(--surface-3); color: var(--brand-slate); }
[data-fx-top="1extras"] .fx-top-ico, [data-fx-pai="1extras"] .fx-top-ico { background: var(--amber-soft); color: var(--amber); }
.fx-top--grupo .fx-top-ico { width: 32px; height: 32px; border-radius: 10px; }
.fx-top-tx { min-width: 0; }
.fx-top-nm { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 var(--fs-sm)/1.3 var(--font-display); color: var(--ink); }
.fx-top-tx small { display: block; margin-top: 1px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.fx-top-n { padding: 3px 8px; border-radius: var(--r-pill); background: var(--surface); border: var(--bd); font-size: var(--fs-xs); font-weight: 600; color: var(--text); }
.fx-top.is-on .fx-top-n { background: var(--surface-2); }
.fx-top-n.is-zero, .fx-f.is-zero .fx-nm, .fx-f.is-zero .fx-c { opacity: .55; }
.fx-top-hit {
  position: absolute; right: 8px; top: -7px; min-width: 20px; height: 20px; padding: 0 6px; display: grid; place-items: center;
  border-radius: var(--r-pill); background: var(--amber); color: var(--on-dark); font: 700 11px/1 var(--font-body);
}
.fx-top.is-vazio .fx-top-nm { color: var(--muted); }

/* caixa de marcar com estado misto (a de topo e a de folha) */
.fx-cb {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; display: grid; place-items: center;
  width: 20px; height: 20px; margin: 0; border: 1.5px solid var(--muted); border-radius: 6px;
  background: var(--surface); cursor: pointer; transition: background-color .2s ease, border-color .2s ease;
}
.fx-cb::before {
  content: ""; width: 11px; height: 11px; transform: scale(0); transition: transform .2s ease;
  background: var(--on-dark); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.fx-cb:hover { border-color: var(--accent); }
.fx-cb:checked, .fx-cb:indeterminate { background: var(--accent); border-color: var(--accent); }
.fx-cb:checked::before { transform: scale(1); }
.fx-cb:indeterminate::before { transform: scale(1); width: 10px; height: 2.5px; border-radius: 2px; clip-path: none; }
.fx-cb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* painel da direita */
.fx-panes { min-width: 0; min-height: 0; display: flex; }
.fx-pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.fx-pane[hidden] { display: none; }
.fx-pane-hd { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 18px 24px 10px; }
.fx-pane-hd h3 { font-size: 1.15rem; }
.fx-pane-meta { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.fx-pane-ac { display: flex; gap: 8px; }
.fx-pane-ac .btn { height: 34px; }
.fx-az { display: flex; flex-wrap: wrap; gap: 2px; padding: 0 22px 12px; border-bottom: 1px solid var(--line-soft); }
.fx-az-l {
  min-width: 26px; height: 26px; padding: 0 4px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  font: 700 12px/1 var(--font-display); color: var(--ink); transition: background .2s ease, color .2s ease;
}
.fx-az-l:hover { background: var(--accent-soft); color: var(--accent-ink); }
.fx-az-l:disabled { color: var(--muted); opacity: .4; cursor: default; background: none; }
.fx-lista { flex: 1; min-height: 0; overflow: auto; padding: 12px 24px 24px; overscroll-behavior: contain; }
.fx-lista:focus { outline: none; }

/* atalho para o grupo (Themeforest dentro de Temas) */
.fx-atalho {
  width: 100%; display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; padding: 12px 14px;
  border: 1px dashed var(--line); border-radius: 16px; background: var(--surface-2); color: var(--ink);
  text-align: left; cursor: pointer; font: inherit; transition: border-color .2s ease, background .2s ease;
}
.fx-atalho:hover { border-color: var(--accent); background: var(--accent-soft); }
.fx-atalho .fx-top-ico { width: 34px; height: 34px; }
.fx-atalho-tx { flex: 1; min-width: 0; }
.fx-atalho-tx b { display: block; font: 700 var(--fs-sm)/1.3 var(--font-display); }
.fx-atalho-tx small { display: block; font-size: var(--fs-xs); color: var(--muted); }
.fx-atalho > .i { width: 18px; height: 18px; color: var(--accent); }

/* folhas por letra, tres colunas */
.fx-grp { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 0 12px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.fx-grp:first-child { border-top: 0; }
.fx-grp:nth-child(1 of :not([hidden])) { border-top: 0; } /* na busca, o primeiro grupo que sobrou */
.fx-grp[hidden] { display: none; }
.fx-grp-l {
  padding-top: 5px; font: 800 1.15rem/1.2 var(--font-display); letter-spacing: -.02em;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent;
  scroll-margin-top: 8px;
}
.fx-grp-l:focus { outline: none; }
.fx-grp-l:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.fx-grp-ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 12px; }
.fx-f[hidden] { display: none; }
.fx-f label {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); line-height: 1.3; color: var(--text); cursor: pointer; transition: background .2s ease, color .2s ease;
}
.fx-f label:hover { background: var(--surface-2); color: var(--ink); }
.fx-f input:checked ~ .fx-nm { color: var(--ink); font-weight: 500; }
.fx-nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fx-c { flex: none; font-size: var(--fs-xs); font-weight: 500; color: var(--muted); }
.fx mark { background: var(--amber-soft); color: var(--ink); border-radius: 4px; padding: 0 1px; }
.fx-vazio { padding: 28px 0; text-align: center; font-size: var(--fs-sm); color: var(--muted); }

/* rodape */
.fx-ft { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 14px 26px; border-top: 1px solid var(--line-soft); background: var(--surface); }
.fx-reset { font-size: var(--fs-sm); }
.fx-min { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--amber); }
.fx-min[hidden] { display: none; }
.fx-min .i { width: 15px; height: 15px; }
.fx-ft-bt { margin-left: auto; display: flex; gap: 10px; }
.fx-aplicar { min-width: 150px; }
.fx-aplicar-n { min-width: 26px; height: 24px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: var(--r-pill); background: var(--nav-line); font-size: 12px; }
.fx-aplicar:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.fx-aplicar.is-indo { cursor: progress; }

/* ------------------------------------------------------------ tablet */
@media (max-width: 980px) {
  .fx { width: calc(100vw - 32px); height: calc(100vh - 32px); }
  .fx-corpo { grid-template-columns: 260px minmax(0, 1fr); }
  .fx-grp-ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-top-n { display: none; }
  .fx-top-b { grid-template-columns: 34px minmax(0, 1fr); } /* sem a coluna do numero, o nome do grupo cabe */
  .fx-top-ico { width: 34px; height: 34px; }
}

/* ------------------------------------- celular: folha em tela cheia */
@media (max-width: 720px) {
  .fx, .fx--sem-modal {
    inset: 0; margin: 0; width: 100%; height: 100%; height: 100dvh; max-width: 100%; max-height: 100%;
    border-radius: 0;
  }
  .fx[open] { animation: fx-sobe .28s cubic-bezier(.2, .8, .2, 1); }
  .fx-hd { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 16px 16px 10px; }
  .fx-hd-ico { display: none; }
  .fx-hd h2 { font-size: 1.12rem; }
  .fx-hd p { font-size: var(--fs-xs); line-height: 1.45; }
  .fx-hd-nota { display: inline; margin: 0; padding: 0; background: none; font-weight: 600; }
  .fx-x { width: 38px; height: 38px; }
  .fx-tools { gap: 2px 12px; padding: 0 16px 8px; }
  .fx-q { flex-basis: 100%; }
  .fx-q .input { height: 44px; }
  .fx-acoes { width: 100%; gap: 4px 16px; }
  .fx-acoes .fx-lk .i { display: none; }
  .fx-conta, .fx-meter { display: none; }
  .fx-sel { flex-wrap: nowrap; overflow-x: auto; max-height: none; padding: 0 16px 10px; scrollbar-width: none; }
  .fx-sel::-webkit-scrollbar { display: none; }
  .fx-corpo { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  /* os topos viram abas */
  .fx-tops {
    flex-direction: row; gap: 8px; padding: 10px 16px; overflow-x: auto; overflow-y: hidden;
    background: var(--surface); border-right: 0; border-bottom: 1px solid var(--line-soft); scrollbar-width: none;
  }
  .fx-tops::-webkit-scrollbar { display: none; }
  .fx-top { padding: 6px 12px 6px 8px; gap: 8px; border: var(--bd); border-radius: var(--r-pill); }
  .fx-top--grupo { margin-left: 0; }
  .fx-top--grupo::after, .fx-top.is-on::before { content: none; }
  .fx-top.is-on { border-color: var(--accent); background: var(--accent-soft); box-shadow: none; }
  .fx-top-b { display: flex; gap: 6px; }
  .fx-top-ico, .fx-top-n { display: none; }
  .fx-top-tx { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
  .fx-top-nm { font-size: 13px; }
  .fx-top-tx small { margin: 0; font-size: 11.5px; }
  .fx-top-hit { right: -4px; top: -6px; }
  .fx-cb { width: 19px; height: 19px; }
  .fx-pane-hd { flex-wrap: nowrap; padding: 12px 16px 8px; align-items: center; }
  .fx-pane-hd > div:first-child { min-width: 0; }
  .fx-pane-hd h3 { font-size: 1.02rem; }
  .fx-pane-ac { flex: none; gap: 6px; }
  .fx-pane-ac .btn { height: 32px; padding: 0 11px; }
  .fx-az { flex-wrap: nowrap; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
  .fx-az::-webkit-scrollbar { display: none; }
  .fx-az-l { flex: none; min-width: 30px; height: 30px; }
  .fx-lista { padding: 6px 16px 16px; }
  .fx-grp { grid-template-columns: 26px minmax(0, 1fr); gap: 0 8px; }
  .fx-grp-ul { grid-template-columns: minmax(0, 1fr); }
  .fx-f label { padding: 9px 6px; }
  .fx-ft { flex-wrap: nowrap; gap: 8px; padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  /* restaurar vira so o icone (o nome continua para o leitor de tela) */
  .fx-reset { flex: none; width: 46px; height: 46px; justify-content: center; border: var(--bd); border-radius: 50%; }
  .fx-reset .i { width: 18px; height: 18px; }
  .fx-reset-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fx-min { position: absolute; left: 16px; right: 16px; bottom: calc(100% + 6px); justify-content: center; padding: 6px 10px; border-radius: var(--r-pill); background: var(--amber-soft); }
  .fx-ft { position: relative; }
  .fx-ft-bt { flex: 1; min-width: 0; margin-left: 0; }
  .fx-ft-bt .btn { height: 46px; padding: 0 14px; }
  .fx-ft-bt .btn--ghost { flex: 1; }
  .fx-aplicar { flex: 1.5; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .fx[open], .fx[open]::backdrop { animation: none; }
  .fx-cb::before, .fx-meter > i { transition: none; }
}

/* ---- grupos alem da categoria (arg 'grupos', 12/10/2026): Desenvolvedor, Segmento, Tags,
   Mais baixados. Sem caixa de marcar no topo: o resumo diz "Todos" ou "N marcados". */
.fx-tops-sep { margin: 12px 4px 2px; font: 700 11px/1.2 var(--font-display); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.fx-top--extra .fx-top-b { grid-template-columns: 38px minmax(0, 1fr); }
.fx-top--extra .fx-top-ico { background: var(--surface-3); color: var(--brand-slate); }
.fx-top--extra.is-com .fx-top-ico { background: var(--accent-soft); color: var(--accent); }
.fx-top--extra.is-com small { color: var(--accent-ink); font-weight: 600; }
.fx-pane--extra .fx-lista { padding-top: 6px; }
.fx-gul { list-style: none; margin: 0; padding: 0; }
.fx-gul--unico { grid-template-columns: minmax(0, 1fr); max-width: 360px; }
.fx-cb.fx-rd { border-radius: 50%; }
.fx-cb.fx-rd::before { width: 8px; height: 8px; border-radius: 50%; clip-path: none; background: #fff; }
@media (max-width: 720px) {
  .fx-tops-sep { display: none; }
  .fx-gul { grid-template-columns: minmax(0, 1fr); }
}
