/*
 * Barra de navegação inferior estilo app (celular e tablet). Par de assets/js/barra-navegacao.js e de
 * Views/Shared/_BarraNavegacaoMobile.cshtml. IDÊNTICO no SITE.Leilao e no SITE.Caixa (o DuplicacaoToolbarTests
 * confere); as cores vêm dos tokens --bn-* definidos na partial de cada site.
 *
 * Mesma linguagem visual da barra da pesquisa (filtros-barra.css, pílula azul-marinho), com um aro claro de 1 px
 * para descolar do fundo quase preto da primeira tela da Home (veredito do dono, 18/11/2026). Prefixo próprio
 * (bn-, html.bn-on): o filtros-barra.css dirige o painel #menu-direita e não pode ser reaproveitado aqui.
 *
 * Camadas: barra 1030, abaixo do modal do Bootstrap (1050). Some enquanto o modal de alertas do painel (1000) está
 * aberto (html.bn-oculta, ligado pelo JS) e enquanto o menu lateral do cabeçalho está aberto.
 */

.bn { display: none; }
.bn .bn-so-logado { display: none; }
html.bn-logado .bn .bn-so-logado { display: inline; }
html.bn-logado .bn .bn-so-visitante { display: none; }

@media (max-width: 991.98px) {
    html.bn-on {
        --bn-altura: 64px;
        --bn-margem: 10px;
        --bn-seguro: env(safe-area-inset-bottom, 0px);
        /* espaço que a barra ocupa a partir da borda inferior da tela */
        --bn-ocupa: calc(var(--bn-altura) + var(--bn-margem) + var(--bn-seguro));
    }
    html.bn-on .bn { display: block; }
    html.bn-on body { padding-bottom: calc(var(--bn-ocupa) + 16px); }
    html.bn-oculta .bn,
    html:has(.Offcanvas_menu_wrapper.active) .bn { display: none; }

    /* ---------- flutuantes do site ---------- */
    /* Voltar ao topo: some, como na pesquisa. O painel tem dois (o do plugin e um estático, com estilo em linha). */
    html.bn-on #scrollUp { display: none !important; }
    /* Chat do SendPulse (Núcleo) sobe para cima da barra. */
    html.bn-on sp-live-chat { display: block; position: relative; transform: translateY(calc(-1 * (var(--bn-ocupa) - 12px))); }
    /* Barra escondida pelo modal de alertas: o chat ficaria por cima do rodapé do modal. */
    html.bn-oculta sp-live-chat,
    html.bn-oculta .nl-chat-anel { display: none !important; }
    html.bn-on .pa-toast { bottom: calc(var(--bn-ocupa) + 12px); }
    html.bn-on #chat-whatsapp { bottom: calc(var(--bn-ocupa) + 8px); }
    html.bn-on .hkn-ball-button { bottom: calc(var(--bn-ocupa) + 8px) !important; }
    /* Caixa: quando a barra já tem o ícone do WhatsApp, o botão flutuante seria repetido. */
    html.bn-on.bn-tem-whatsapp #chat-whatsapp { display: none !important; }

    /* ---------- páginas com o funil de assessoria (_AssessoriaFunil) ---------- */
    /* A barra assume o papel da faixa "Começar": o item Assessoria aciona o próprio [data-asr-comecar]. O
       assessoria-funil.js também não liga a faixa com html.bn-on; esta regra cobre o quadro antes de ele rodar. */
    html.bn-on .asr-faixa { display: none !important; }
    /* Caixa: o funil esconde o WhatsApp flutuante até 899 px (atendimento só depois das respostas). Com a barra,
       vale até onde ela vai. */
    html.bn-on.asr-tem #chat-whatsapp { display: none !important; }

    /* ---------- folha de busca de cidade ---------- */
    .bn-fundo {
        position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1064; background: rgba(8, 18, 43, .5);
        opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
    }
    .bn-folha {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1065; display: flex; flex-direction: column;
        height: 88vh; max-height: 88vh; background: #fff; color: var(--bn-tinta); border-radius: 22px 22px 0 0;
        box-shadow: 0 -12px 32px rgba(8, 18, 43, .2); outline: 0; font-family: Montserrat, system-ui, sans-serif;
        transform: translateY(100%); visibility: hidden;
        transition: transform .26s cubic-bezier(.2, .8, .2, 1), visibility .26s;
    }
    html.bn-folha-aberta .bn-fundo { opacity: 1; visibility: visible; }
    html.bn-folha-aberta .bn-folha { transform: none; visibility: visible; }
    html.bn-folha-aberta body { overflow: hidden; }
    html.bn-folha-aberta sp-live-chat,
    html.bn-folha-aberta .nl-chat-anel { display: none !important; }

    .bn-alca { flex: 0 0 auto; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 4px; background: #d5dae3; }
    .bn-folha-topo { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 4px 20px; }
    .bn-folha-topo h2 { margin: 0; padding: 0; font-size: 18px; font-weight: 700; line-height: 1.3; color: var(--bn-tinta); text-transform: none; }
    .bn-x { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin: 0; padding: 0; border: 0; background: none; color: #5b6475; cursor: pointer; }
    .bn-x svg { width: 20px; height: 20px; }
    .bn-folha-corpo { flex: 1 1 auto; min-height: 0; padding: 4px 20px calc(16px + var(--bn-seguro)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
    .bn-campo { margin: 0 0 12px; }
    .bn-campo label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--bn-tinta); }
    .bn-campo input {
        display: block; width: 100%; height: 52px; margin: 0; padding: 0 12px; border: 1px solid #c9d0db; border-radius: 12px;
        background: #fff; color: var(--bn-tinta); font-size: 16px; /* 16 px: o iOS não dá zoom ao focar */
        box-shadow: none; -webkit-appearance: none; appearance: none;
    }
    .bn-ufs { display: flex; gap: 6px; margin: 0 -20px 8px; padding: 2px 20px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .bn-ufs::-webkit-scrollbar { display: none; }
    .bn-ufs:empty { display: none; }
    .bn-uf {
        flex: 0 0 auto; min-width: 48px; min-height: 44px; margin: 0; padding: 0 12px; border: 1px solid #c9d0db; border-radius: 999px;
        background: #fff; color: var(--bn-tinta); font-size: 14px; font-weight: 700; cursor: pointer;
    }
    .bn-uf[aria-pressed="true"] { border-color: var(--bn-marca); background: var(--bn-marca); color: #fff; }
    .bn-folha-aviso { margin: 8px 0; color: #5b6475; font-size: 14px; line-height: 1.5; }
    .bn-folha-aviso:empty { display: none; }
    .bn-tentar {
        min-height: 48px; margin: 0 0 8px; padding: 0 18px; border: 1px solid var(--bn-tinta); border-radius: 12px;
        background: #fff; color: var(--bn-tinta); font-size: 14px; font-weight: 700; cursor: pointer;
    }
    .bn-tentar[hidden] { display: none; }
    .bn-lista { list-style: none; margin: 0; padding: 0; }
    .bn-lista li { margin: 0; padding: 0; }
    .bn-lista a,
    .bn-lista a:hover,
    .bn-lista a:visited {
        display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 4px;
        border-bottom: 1px solid #e3e7ee; color: var(--bn-tinta); font-size: 15px; font-weight: 600; line-height: 1.3; text-decoration: none;
    }
    .bn-lista a:active { background: #f6f7f9; }
    .bn-lista small { flex: 0 0 auto; color: #5b6475; font-size: 12px; font-weight: 700; }
    .bn-folha button:focus-visible, .bn-folha input:focus-visible, .bn-folha a:focus-visible { outline: 3px solid #1d6ff2; outline-offset: 2px; }

    /* ---------- barra ---------- */
    .bn-barra {
        position: fixed; left: 12px; right: 12px; bottom: calc(var(--bn-margem) + var(--bn-seguro)); z-index: 1030;
        display: flex; align-items: stretch; height: var(--bn-altura); margin: 0; padding: 0 6px;
        border: 1px solid rgba(255, 255, 255, .16); border-radius: 22px; background: var(--bn-tinta); color: #fff;
        box-shadow: 0 10px 28px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
        font-family: Montserrat, system-ui, sans-serif;
    }
    .bn-barra .bn-item,
    .bn-barra .bn-item:hover,
    .bn-barra .bn-item:focus,
    .bn-barra .bn-item:visited {
        flex: 1 1 0; min-width: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 4px; margin: 0; padding: 0 2px; border: 0; background: none; color: #fff; text-decoration: none;
        cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .12s ease;
    }
    .bn-barra .bn-item:active { transform: scale(.94); }
    .bn-barra .bn-item:focus-visible { outline: 3px solid #6aa5ff; outline-offset: 2px; border-radius: 12px; }
    .bn-ic {
        display: inline-flex; align-items: center; justify-content: center;
        width: 34px; height: 34px; border: 2px solid rgba(255, 255, 255, .3); border-radius: 50%;
    }
    .bn-ic svg { width: 17px; height: 17px; }
    .bn-item--destaque .bn-ic { border-color: var(--bn-marca); background: var(--bn-marca); }
    .bn-rot { font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap; }
}

/* Telas muito estreitas: os rótulos encolhem antes de quebrar a barra. */
@media (max-width: 359.98px) {
    .bn-rot { font-size: 10px; }
    .bn-ic { width: 30px; height: 30px; }
}

/* Tablet: a barra fica centralizada, como a da pesquisa. */
@media (min-width: 768px) and (max-width: 991.98px) {
    .bn-barra { left: 50%; right: auto; width: 460px; margin-left: -230px; }
    .bn-folha { left: 50%; right: auto; width: 520px; margin-left: -260px; }
}

@media (prefers-reduced-motion: reduce) {
    .bn-barra .bn-item, .bn-folha, .bn-fundo { transition: none; }
}
