/*
 * Topo do site — o <header> de redesign/front/layout/navbar.blade.php
 * (home, página do município e /paineis). Carregado em layout/header.blade.php,
 * depois do style.css/custom.css do template, que continuam valendo para o
 * Layout::app (navbar-others). Por isso tudo aqui é preso a .site-topo.
 *
 * Três jeitos:
 *  - sobre a foto do hero (página com #hero): transparente, com um degradê
 *    escuro atrás da marca e dos links; ao rolar (functions.js põe .sticky no
 *    <header>), vira azul sólido;
 *  - sem hero: azul sólido desde o início, ocupando o próprio espaço;
 *  - .site-topo--claro (logo de município/empresa, ?to=ima): branco, porque a
 *    arte de terceiros quase sempre foi feita para fundo branco.
 */

:root {
    --topo-azul: #1f3a68;
    --topo-azul-escuro: #172d52;
    --topo-vermelho: #b13b27;
    --topo-tinta: #1b2433;
    --topo-altura: 76px;
}

header.site-topo {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-height: 0;
    padding: 0;
    background: var(--topo-azul-escuro);
    box-shadow: 0 6px 24px rgba(9, 18, 34, .18);
    transition: background-color .25s ease, box-shadow .25s ease;
}

/* Página com hero: o topo flutua sobre a foto. */
body:has(#hero) header.site-topo {
    position: fixed;
}
body:has(#hero) header.site-topo:not(.site-topo--claro):not(.sticky) {
    background: linear-gradient(180deg, rgba(10, 19, 36, .66) 0%, rgba(10, 19, 36, .30) 62%, rgba(10, 19, 36, 0) 100%);
    box-shadow: none;
}

/* O style.css pinta de branco qualquer header.sticky. */
header.site-topo.sticky:not(.site-topo--claro) {
    background: var(--topo-azul-escuro);
    box-shadow: 0 6px 24px rgba(9, 18, 34, .22);
}

/* O style.css do template dá margem e posição a todo <nav>. */
header.site-topo nav {
    margin: 0 !important;
    position: static;
}

.site-topo__barra {
    display: flex;
    align-items: center;
    gap: 24px;
    height: var(--topo-altura);
    transition: height .25s ease;
}
header.site-topo.sticky .site-topo__barra {
    height: 64px;
}

.site-topo__marca {
    flex: none;
    display: flex;
    align-items: center;
    line-height: 0;
    border-radius: 6px;
}
.site-topo__marca img {
    display: block;
    width: auto;
    height: 46px;
    max-width: 260px;
    object-fit: contain;
    transition: height .25s ease;
}
header.site-topo.sticky .site-topo__marca img {
    height: 38px;
}
.site-topo--claro .site-topo__marca img {
    height: 50px;
    max-width: 200px;
}
.site-topo--claro.sticky .site-topo__marca img {
    height: 42px;
}

/* Links */
.site-topo__links {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}
.site-topo__links ul {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.site-topo__links a {
    position: relative;
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, .88);
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    white-space: nowrap;
    text-decoration: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: color .15s ease, background-color .15s ease;
}
.site-topo__links a:hover,
.site-topo__links a:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}
.site-topo__links a[aria-current="page"] {
    color: #fff;
}
.site-topo__links a[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 1px;
    height: 3px;
    border-radius: 3px;
    background: var(--topo-vermelho);
}

/* Conta e menu do celular */
.site-topo__acoes {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.site-topo__pessoa,
.site-topo__entrar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}
.site-topo__pessoa {
    padding: 0 12px 0 4px;
}
.site-topo__entrar {
    padding: 0 16px 0 13px;
}
.site-topo__pessoa:hover,
.site-topo__pessoa[aria-expanded="true"],
.site-topo__entrar:hover {
    color: #fff;
    background: rgba(255, 255, 255, .18);
    border-color: rgba(255, 255, 255, .45);
}
.site-topo__pessoa:focus,
.site-topo__entrar:focus,
.site-topo__abrir:focus {
    outline: none;
}
.site-topo__pessoa:focus-visible,
.site-topo__entrar:focus-visible,
.site-topo__abrir:focus-visible,
.site-topo__marca:focus-visible,
.site-topo__links a:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .75);
    outline-offset: 2px;
}
.site-topo--claro .site-topo__pessoa:focus-visible,
.site-topo--claro .site-topo__entrar:focus-visible,
.site-topo--claro .site-topo__abrir:focus-visible,
.site-topo--claro .site-topo__marca:focus-visible,
.site-topo--claro .site-topo__links a:focus-visible {
    outline-color: rgba(31, 58, 104, .55);
}
.site-topo__nome {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.site-topo__seta {
    opacity: .8;
    transition: transform .2s ease;
}
.site-topo__pessoa[aria-expanded="true"] .site-topo__seta {
    transform: rotate(180deg);
}
.site-topo__avatar {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--topo-vermelho);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}

.site-topo__menu-conta {
    min-width: 240px;
    margin-top: 8px !important;
    padding: 6px;
    border: 1px solid rgba(27, 36, 51, .08);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 27, 48, .18);
    font-size: 14px;
}
.site-topo__menu-conta .dropdown-item {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--topo-tinta);
    font-weight: 500;
}
.site-topo__menu-conta .dropdown-item:hover,
.site-topo__menu-conta .dropdown-item:focus {
    background: #eef2f8;
    color: var(--topo-azul);
}
.site-topo__menu-conta .site-topo__sair {
    color: var(--topo-vermelho);
}
.site-topo__menu-conta .dropdown-divider {
    margin: 6px 4px;
    border-color: #e6e9ef;
    background: none;
}
.site-topo__menu-cabeca {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    padding: 8px 12px 12px;
    border-bottom: 1px solid #e6e9ef;
    color: #5b6577;
    font-size: 13px;
    line-height: 1.35;
}
.site-topo__menu-cabeca strong {
    display: block;
    color: var(--topo-tinta);
    font-size: 14px;
    font-weight: 700;
}

.site-topo__abrir {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 42px;
    height: 40px;
    padding: 0 11px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    cursor: pointer;
}
.site-topo__abrir span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: #fff;
}

/* Topo claro (logo de terceiros) */
header.site-topo.site-topo--claro {
    background: #fff;
    box-shadow: 0 1px 0 #e6e9ef, 0 6px 20px rgba(15, 27, 48, .06);
}
.site-topo--claro .site-topo__links a {
    color: var(--topo-tinta);
    text-shadow: none;
}
.site-topo--claro .site-topo__links a:hover,
.site-topo--claro .site-topo__links a:focus-visible {
    color: var(--topo-azul);
    background: #eef2f8;
}
.site-topo--claro .site-topo__links a[aria-current="page"] {
    color: var(--topo-azul);
}
.site-topo--claro .site-topo__pessoa,
.site-topo--claro .site-topo__entrar,
.site-topo--claro .site-topo__abrir {
    border-color: #d9dfe8;
    background: #fff;
    color: var(--topo-tinta);
}
.site-topo--claro .site-topo__pessoa:hover,
.site-topo--claro .site-topo__pessoa[aria-expanded="true"],
.site-topo--claro .site-topo__entrar:hover {
    border-color: #b9c3d3;
    background: #f4f6fa;
    color: var(--topo-tinta);
}
.site-topo--claro .site-topo__abrir span {
    background: var(--topo-tinta);
}

/* Telas médias: os links apertam antes de sumir. */
@media (max-width: 1199.98px) {
    .site-topo__barra { gap: 14px; }
    .site-topo__marca img { height: 38px; }
    header.site-topo.sticky .site-topo__marca img { height: 34px; }
    .site-topo__links ul { gap: 0; }
    .site-topo__links a { padding: 8px 8px; font-size: 14px; }
    .site-topo__links a[aria-current="page"]::after { left: 8px; right: 8px; }
    .site-topo__nome,
    .site-topo__seta { display: none; }
    .site-topo__pessoa { padding: 0 4px; }
}

@media (max-width: 991.98px) {
    :root { --topo-altura: 64px; }
    header.site-topo.sticky .site-topo__barra { height: 60px; }
    .site-topo__links { display: none; }
    .site-topo__abrir { display: inline-flex; }
    .site-topo__marca img { height: 34px; max-width: 190px; }
    header.site-topo.sticky .site-topo__marca img { height: 32px; }
    .site-topo--claro .site-topo__marca img,
    .site-topo--claro.sticky .site-topo__marca img { height: 40px; max-width: 150px; }
}

@media (max-width: 374.98px) {
    .site-topo__marca img { height: 28px; }
    .site-topo__entrar span { display: none; }
    .site-topo__entrar { padding: 0 11px; }
}

/* Menu do celular (offcanvas do Bootstrap) */
.site-menu-movel {
    --bs-offcanvas-zindex: 10050;
    --bs-offcanvas-width: min(340px, 88vw);
    border-left: 0 !important;
    color: var(--topo-tinta);
}
.offcanvas-backdrop {
    z-index: 10040;
}
.offcanvas-backdrop.show {
    opacity: .55;
}
.site-menu-movel .offcanvas-header {
    padding: 18px 20px;
    border-bottom: 1px solid #e6e9ef;
}
.site-menu-movel__titulo {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #5b6577;
}
.site-menu-movel .offcanvas-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 12px 12px 24px;
}
.site-menu-movel nav {
    margin: 0 !important;
}
.site-menu-movel__links {
    margin: 0;
    padding: 0;
    list-style: none;
}
.site-menu-movel__links a {
    display: block;
    padding: 13px 14px;
    border-radius: 10px;
    color: var(--topo-tinta);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
}
.site-menu-movel__links a:hover {
    background: #eef2f8;
    color: var(--topo-azul);
}
.site-menu-movel__links a[aria-current="page"] {
    background: #eef2f8;
    color: var(--topo-azul);
    box-shadow: inset 3px 0 0 var(--topo-vermelho);
}
.site-menu-movel__conta {
    display: grid;
    gap: 10px;
    margin-top: auto;
    padding: 0 8px;
}
.site-menu-movel__bt {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border: 1px solid #d9dfe8;
    border-radius: 12px;
    background: #fff;
    color: var(--topo-tinta);
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}
.site-menu-movel__bt:hover {
    color: var(--topo-azul);
    border-color: #b9c3d3;
}
.site-menu-movel__bt--cheio {
    border-color: var(--topo-azul);
    background: var(--topo-azul);
    color: #fff;
}
.site-menu-movel__bt--cheio:hover {
    background: var(--topo-azul-escuro);
    color: #fff;
}

/* Preloader: nas cores da marca, e nunca preso na tela. O functions.js só o
   tira no load da janela; se algum recurso de fora travar, ele sai sozinho. */
#preloader {
    background-color: var(--topo-azul-escuro);
    animation: topo-preloader-sai .35s ease 2.5s forwards;
}
#preloader .sk-spinner-wave div {
    width: 5px;
    margin: 0 1px;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, .9);
}
@keyframes topo-preloader-sai {
    to { opacity: 0; visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    header.site-topo,
    .site-topo__barra,
    .site-topo__marca img { transition: none; }
}
