/* ============================================================
   busca-militar.css — a busca de militares do topo (busca-militar.js):
   cartão do militar achado e "Você quis dizer…"; centra a busca na barra.
   ============================================================ */

/* ---------------- Barra do topo: busca no centro ----------------
   Três colunas: marca | busca | relógios, tema e conta. A da marca tem no mínimo a largura da
   da direita (--topo-lado, medida por busca-militar.js; 380px até medir): as duas laterais
   ficam iguais e a busca, no meio da barra, encolhe (até 240px) antes de sair do centro. Só
   numa janela estreita demais para isso a coluna da marca cede (276px = a busca mínima e os
   dois vãos de 18px), sem nada sair da barra. */
.topbar {
  --topo-lado: 380px;
  display: grid;
  grid-template-columns:
    minmax(min(var(--topo-lado), calc(100% - var(--topo-lado) - 276px)), 1fr)
    minmax(240px, 560px)
    minmax(max-content, 1fr);
}
.topbar > .brand { justify-self: start; }
.topbar > .search { width: 100%; max-width: none; justify-self: stretch; }
.topbar-dir { display: flex; align-items: center; gap: 14px; justify-self: end; min-width: 0; }

/* Telemóvel e tablet: sem a grade, vale a fila de painel.css */
@media (max-width: 900px), (pointer: coarse) and (max-width: 1080px) {
  .topbar { display: flex; }
  .topbar-dir { display: contents; }
  .topbar .top-actions { display:flex;margin-left:0; }
  .top-skulls { gap:4px;padding:0 2px; }
}

/* ---------------- Campo ---------------- */
.busca-militar input[type="search"]::-webkit-search-cancel-button { display: none; }
.bm-limpar {
  display: grid; place-items: center;
  width: 24px; height: 24px; flex: 0 0 auto;
  padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.bm-limpar .ico { width: 13px; height: 13px; }
.bm-limpar:hover { background: var(--surface-2); color: var(--text); }
.bm-limpar[hidden] { display: none; }
.bm-anuncio {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- Painel de resultado ---------------- */
.busca-sugestoes {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: max(100%, 460px);
  max-width: calc(100vw - 16px);
  max-height: min(72vh, 560px);
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  color: var(--text-primary);
  text-align: left;
}
.busca-sugestoes.aberta { display: block; animation: bmAbrir .14s ease-out; }
@keyframes bmAbrir { from { opacity: 0; transform: translate(-50%, -4px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Estados: buscando, nada achado, erro */
.bm-estado {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px;
  font-size: 13px; color: var(--text-muted);
}
.bm-estado .ico { width: 18px; height: 18px; flex: 0 0 auto; }
.bm-estado--erro { color: var(--danger-text); }
.bm-estado a { color: var(--accent-text); font-weight: 600; }
/* O nick registrado difere do digitado nos símbolos: aviso acima do cartão */
.bm-grafia {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0; padding: 10px 14px;
  background: var(--warning-soft); color: var(--warning-text);
  border-bottom: 1px solid var(--warning-border);
  font-size: 12.5px; line-height: 1.45;
}
.bm-grafia .ico { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 1px; }
.bm-grafia b { color: var(--text-primary); font-weight: 700; overflow-wrap: anywhere; }
/* "+N parecidos": há mais do que a lista mostra */
.bm-mais { margin: 0; padding: 4px 14px 12px; font-size: 12px; color: var(--text-muted); }
.bm-girar {
  width: 16px; height: 16px; flex: 0 0 auto;
  border: 2px solid var(--border-color); border-top-color: var(--accent);
  border-radius: 50%;
  animation: bmGirar .7s linear infinite;
}
@keyframes bmGirar { to { transform: rotate(360deg); } }

/* ---------------- Cartão do militar achado ----------------
   O boneco inteiro, de frente, num painel da altura do cartão; ao lado, tudo centrado: nick,
   patente e listagem, a situação (selos e o detalhe), a TAG que se copia com um clique, dois
   fatos e o perfil. Na imagem do Habbo (128x220) o boneco fica entre y 42 e 215: a faixa y
   34..218 ocupa 92% da altura do painel (a imagem tem 110% dela), com folga em cima para chapéus
   altos e sem cortar os pés; numa coluna estreita a altura cede para o corpo (73 px de 128) caber
   com 4px de folga de cada lado (--bm-lado é a largura da coluna). */
.bm-cartao {
  --bm-lado: 112px;
  display: grid;
  grid-template-columns: var(--bm-lado) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}
.bm-boneco {
  position: relative;
  min-height: 214px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--portrait-bg);
}
.bm-boneco img {
  position: absolute; top: 50%; left: 50%;
  width: auto; height: min(110%, calc((var(--bm-lado) - 8px) * 220 / 73)); max-width: none;
  /* centra o desenho, não a imagem: o corpo fica em x 30-103 de 128 (centro em 51,95%) e em
     y 42-215 de 220 (centro em 58,4%) */
  transform: translate(-51.95%, -58.4%);
  image-rendering: pixelated;
}
.bm-boneco img[data-fbk] { top: 50%; width: 60%; height: auto; transform: translate(-50%, -50%); image-rendering: auto; }
.bm-corpo {
  min-width: 0;
  display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; gap: 8px;
  text-align: center;
}
.bm-ident { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; }
.bm-nick { font-size: 17px; font-weight: 700; line-height: 1.2; color: var(--text-primary); overflow-wrap: anywhere; }
.bm-patente { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--accent-text); overflow-wrap: anywhere; }
.bm-listagem {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  margin-top: 1px;
  font-size: 11.5px; line-height: 1.3; color: var(--text-muted);
}
.bm-listagem .ico { flex: none; width: 13px; height: 13px; }
.bm-selos { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.bm-selo {
  display: inline-flex; align-items: center; gap: 4px;
  height: var(--selo-h, 24px); padding: 0 10px;
  border: 1px solid var(--border-color); border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
}
.bm-selo .ico { width: 12px; height: 12px; }
.bm-selo--ok { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.bm-selo--info { background: var(--info-soft); color: var(--info-text); border-color: var(--info-border); }
.bm-selo--aviso { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.bm-selo--perigo { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.bm-selo--ouro { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.bm-detalhe { margin: -2px 0 0; font-size: 11.5px; font-weight: 500; line-height: 1.35; color: var(--text-secondary); overflow-wrap: anywhere; }
.bm-detalhe--perigo { color: var(--danger-text); }
.bm-detalhe--info { color: var(--info-text); }
/* A TAG: o campo inteiro é o botão de copiar */
.bm-copiar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 40px; padding: 6px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border-color)); border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text-primary);
  font: inherit; cursor: copy;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
.bm-copiar:hover { border-color: var(--accent); }
.bm-copiar:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.bm-copiar-rotulo { font-size: 10.5px; font-weight: 600; letter-spacing: .1em; color: var(--text-muted); }
.bm-copiar-valor { font-size: 15px; font-weight: 700; letter-spacing: .03em; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.bm-copiar-fim { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); }
.bm-copiar-fim .ico { width: 14px; height: 14px; }
.bm-copiar.bm-copiado { border-color: var(--success-border); background: var(--success-soft); }
.bm-copiar.bm-copiado .bm-copiar-fim { color: var(--success-text); }
.bm-copiar.bm-falhou .bm-copiar-fim { color: var(--danger-text); }
.bm-copiar--vazio { cursor: default; background: var(--surface-2); border-color: var(--border-color); }
.bm-copiar--vazio .bm-copiar-valor { font-size: 12.5px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
/* Dois fatos lado a lado, do mesmo tamanho */
.bm-fatos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; }
.bm-fato { min-width: 0; padding: 5px 6px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--surface-2); }
.bm-fato dt { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.bm-fato dd { margin: 1px 0 0; font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--text-secondary); overflow-wrap: anywhere; }
.bm-perfil { justify-content: center; width: 100%; }

/* Selo de status (o mesmo selo de 24px do cartão) e TAG */
.bm-status {
  display: inline-flex; align-items: center;
  height: var(--selo-h, 24px); padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; line-height: 1;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}
.bm-status--ativo { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.bm-status--exonerado { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.bm-tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .03em;
  background: var(--accent-soft); color: var(--accent-text);
}

/* ---------------- "Você quis dizer…" ---------------- */
.bm-cabeca {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 14px 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-muted);
}
.bm-cabeca .ico { width: 14px; height: 14px; color: var(--accent-text); }
.bm-lista { list-style: none; margin: 0; padding: 0 6px 6px; }
.bm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
}
.bm-item:hover, .bm-item.ativa { background: var(--surface-2); text-decoration: none; }
.bm-item.ativa { outline: 2px solid var(--accent); outline-offset: -2px; }
.bm-item.is-top { background: var(--accent-soft); }
.bm-item.is-top:hover, .bm-item.is-top.ativa { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.bm-cab { --habbo-tam: var(--habbo-lista, 40px); }
.bm-principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bm-item-nick { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-item-meta { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-nota {
  flex: 0 0 auto;
  min-width: 40px;
  font-size: 11px; font-weight: 800; text-align: right;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.bm-item.is-top .bm-nota { color: var(--accent-text); }

/* ---------------- Telemóvel ---------------- */
@media (max-width: 767px) {
  /* Acima da barra de abas: a altura vem da janela visível (dvh), sem a barra do navegador */
  .busca-sugestoes {
    position: fixed;
    left: 8px; right: 8px; top: 64px;
    width: auto; max-width: none;
    transform: none;
    max-height: calc(100vh - 140px - env(safe-area-inset-bottom));
    max-height: calc(100dvh - 140px - env(safe-area-inset-bottom));
  }
  .busca-sugestoes.aberta { animation: none; }
  .bm-cartao { --bm-lado: 100px; gap: 10px; padding: 12px; }
  .bm-boneco { min-height: 200px; }
  .bm-item { padding: 9px 8px; }
  /* Os dois fatos em linhas da largura toda: rótulo à esquerda e o valor inteiro à direita */
  .bm-fatos { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .bm-fato { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 8px; }
  .bm-fato dt { flex: none; letter-spacing: .04em; }
  .bm-fato dd { margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Letra mínima de 12 no celular */
  .bm-fato dt, .bm-copiar-rotulo, .bm-cabeca, .bm-nota, .bm-listagem, .bm-detalhe, .bm-item-meta, .bm-copiar-fim { font-size: 12px; }
}
/* Alvos de toque de 44px (celular e tablet de toque, também em paisagem): a TAG, o perfil (vence
   o .btn.sm por vir depois) e o X de limpar (do tamanho da caixa da busca) */
@media (max-width: 767px), (pointer: coarse) {
  .btn.bm-perfil, .bm-copiar { min-height: 44px; }
  .bm-limpar { width: 44px; height: 44px; margin-right: -10px; }
  .bm-limpar .ico { width: 16px; height: 16px; }
}
/* Celular estreito: coluna do boneco menor; o rótulo do fato em cima e o valor embaixo, sem corte */
@media (max-width: 389px) {
  .bm-cartao { --bm-lado: 92px; }
  .bm-fato { display: block; }
  .bm-fato dd { margin-top: 1px; white-space: normal; }
}

/* Tema claro: o verde e o vermelho dos selos escurecem sobre o fundo tingido (contraste AA) */
[data-theme="light"] .bm-status--ativo { color: #155f30; }
[data-theme="light"] .bm-status--exonerado { color: #8f1d22; }
