/* Casca da página de mapa: cabeçalho fixo, trilho de ícones (computador)
   ou gaveta (celular) e fundo escuro. Estrutura do Rotier (webgis.css
   237-351 do tenant ARPB) com as cores da SUDEMA (tokens.css).
   Comportamento em libs/webgis/mapa-shell.js: ele só alterna
   `menu-aberto` em <body>; quem decide trilho ou gaveta é este arquivo. */

/* Fontes — vinham de sidebar-admin-style.css, que saiu. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined');

/* Medidas da casca (nomes do webgis.css do Rotier). */
:root {
    --mh-h: 52px;                /* cabeçalho */
    --sb-min: 52px;              /* trilho de ícones, computador */
    --sb-max: 220px;             /* trilho expandido, computador */
    --gaveta-w: 260px;           /* gaveta, celular */
    --toolbar-celular-h: 52px;   /* toolbar presa à base (fatia 2): 44px + 2 x 4px */
    --dur: 280ms;
    --ease: cubic-bezier(.16, 1, .3, 1);
}

/* --- Resets que viviam em sidebar-admin-style.css --- */
html, body { height: 100%; }
body {
    margin: 0;
    overflow: hidden;
    font-family: var(--app-font);
    background: var(--surface-2);
}
li { list-style: none; }
a { text-decoration: none; }
.wrapper { display: flex; }
.main { min-height: 100vh; width: 100%; overflow: hidden; }

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 48;
}

/* --- Modais do Bootstrap acima do cabeçalho ---
   O cabeçalho fixo (#map-header, 3000) ficava por cima dos modais (1055)
   e do fundo escuro (1050): cobria o topo da caixa e não escurecia. Aqui
   (só páginas de mapa) o fundo passa a 3100 e o modal a 3110, acima do
   cabeçalho, da gaveta (2500), do fundo da gaveta (2400) e do painel/folha
   (2000). A caixa começa abaixo do cabeçalho mesmo assim. Os avisos
   (toast.js, 3200) continuam por cima de tudo. */
.modal {
    --bs-modal-zindex: 3110;
}

.modal-backdrop {
    --bs-backdrop-zindex: 3100;
}

.modal-dialog {
    margin-top: calc(var(--mh-h) + var(--bs-modal-margin));
}

.modal-dialog-centered {
    min-height: calc(100% - var(--mh-h) - var(--bs-modal-margin) * 2);
}

/* --- Cabeçalho --- */
#map-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mh-h);
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 0 4px;
    background: var(--brand);
    color: #fff;
    box-shadow: var(--sh-sm);
}

.mh-menu {
    width: var(--toque);
    height: var(--toque);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.mh-menu:hover,
.mh-menu:focus-visible { background: rgba(255, 255, 255, .12); outline: none; }
.mh-menu:focus-visible { box-shadow: 0 0 0 2px #fff; }

.mh-marca { display: flex; align-items: center; gap: 6px; }
.mh-marca-simbolo { height: 32px; width: auto; }
.mh-marca-nome { height: 26px; width: auto; }

.mh-conta { margin-left: auto; display: flex; align-items: center; }

.mh-entrar,
.mh-usuario {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font: 500 13px/1 var(--app-font);
    white-space: nowrap;
    cursor: pointer;
}

.mh-entrar:hover,
.mh-usuario:hover,
.mh-usuario.show { background: rgba(255, 255, 255, .22); color: #fff; }
.mh-usuario::after { display: none; }   /* seta que o .dropdown-toggle do Bootstrap põe */
.mh-usuario-nome { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.mh-conta .dropdown-menu { font-size: 13px; border-color: var(--border); box-shadow: var(--sh-painel); }
.mh-conta .dropdown-item { display: flex; align-items: center; gap: 6px; }
.mh-conta .material-symbols-outlined { font-size: 20px; }
.mh-sair { color: #b5485f; }

/* --- Trilho (computador): 52px só com ícones, sempre visível; expande a
   220px POR CIMA do mapa (o mapa não encolhe). --- */
#sidebar {
    position: fixed;
    top: var(--mh-h);
    left: 0;
    bottom: 0;
    width: var(--sb-min);
    z-index: 2500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--brand);
    transition: width var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

body.menu-aberto #sidebar {
    width: var(--sb-max);
    box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
}

.sidebar-nav {
    flex: 1 1 auto;
    margin: 0;
    padding: 8px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-item { margin: 0 0 2px; }

a.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-left: 3px solid transparent;
    color: #fff;
    font: 500 13px/1.2 var(--app-font);
    text-decoration: none;
    white-space: nowrap;
    transition: background .12s;
}

a.sidebar-link:hover,
a.sidebar-link:focus-visible {
    background: rgba(255, 255, 255, .1);
    border-left-color: #fff;
    color: #fff;
    outline: none;
}

/* Ícone centrado na largura do trilho (descontada a borda esquerda). */
.sidebar-link .material-symbols-outlined {
    flex: 0 0 auto;
    width: calc(var(--sb-min) - 3px);
    text-align: center;
    font-size: 22px;
    color: #fff;
}

/* Rótulo: invisível no trilho, aparece ao expandir. */
.sidebar-link span:not(.material-symbols-outlined) {
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms var(--ease);
}

body.menu-aberto .sidebar-link span:not(.material-symbols-outlined) {
    opacity: 1;
    pointer-events: auto;
}

/* --- Fundo escuro: fecha o menu ao clicar (mapa-shell.js) --- */
.map-sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 2400;
    background: rgba(0, 0, 0, .35);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur), visibility var(--dur);
}

body.menu-aberto .map-sidebar-overlay { opacity: 1; visibility: visible; }

/* --- Celular: o trilho some; ☰ abre o MESMO #sidebar como gaveta --- */
@media (max-width: 767.98px) {
    #sidebar {
        width: var(--gaveta-w);
        transform: translateX(-100%);
        visibility: hidden;
        box-shadow: none;
        transition: transform var(--dur) var(--ease), visibility 0s var(--dur);
    }

    body.menu-aberto #sidebar {
        width: var(--gaveta-w);
        transform: none;
        visibility: visible;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
        transition: transform var(--dur) var(--ease), visibility 0s;
    }

    /* Na gaveta os rótulos estão sempre à vista. */
    .sidebar-link span:not(.material-symbols-outlined) { opacity: 1; pointer-events: auto; }

    .mh-marca-nome,
    .mh-usuario-nome,
    .mh-entrar span:not(.material-symbols-outlined) { display: none; }
    .mh-entrar, .mh-usuario { padding: 0 8px; }
}
