/* ==========================================================================
   MAPA DE SERVIÇOS PÚBLICOS — CSS  v3
   Fullscreen layout · sidebar com sections · pin icons · pill filters
   Responsivo: desktop (sidebar 360px) → mobile (sidebar overlay).
   ========================================================================== */

/* ---------- Reset para fullscreen ---------- */
body.mapa-fullscreen {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
    color: #0f172a;
    background: #f8fafc;
}

/* ===== HEADER ===== */
.mapa-header {
    height: 58px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 1000;
    position: relative;
}

.mapa-header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    gap: 1rem;
}

.mapa-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: #0f172a;
    flex-shrink: 0;
    min-width: 0;
}

.mapa-logo img {
    height: 36px;
    width: auto;
    border-radius: 4px;
}

.mapa-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.mapa-logo-municipio {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mapa-logo-modulo {
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.mapa-nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-shrink: 0;
}

.mapa-nav-link {
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    color: #475569;
    transition: background .15s, color .15s;
}

.mapa-nav-link:hover,
.mapa-nav-link.is-active {
    background: #eff6ff;
    color: #1d4ed8;
}

.mapa-nav-emergencia {
    color: #b91c1c;
}

.mapa-nav-emergencia:hover,
.mapa-nav-emergencia.is-active {
    background: #fef2f2;
    color: #991b1b;
}

.mapa-nav-portal {
    border: 1px solid #e2e8f0;
}

/* ===== FOOTER ===== */
.mapa-footer {
    height: 34px;
    background: #0f172a;
    color: #94a3b8;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    z-index: 1000;
    position: relative;
}

.mapa-footer-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.mapa-footer a { color: #60a5fa; text-decoration: none; }
.mapa-footer a:hover { text-decoration: underline; }
.mapa-footer-sep { color: #4b5563; }

/* ===== LAYOUT PRINCIPAL ===== */
.mapa-main {
    height: calc(100vh - 92px);
    height: calc(100dvh - 92px);
    position: relative;
}

.mapa-layout {
    display: flex;
    height: 100%;
    position: relative;
}

/* ===== SIDEBAR ===== */
.mapa-sidebar {
    width: 360px;
    min-width: 360px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 500;
}

/* -- Busca -- */
.mapa-sidebar-header {
    padding: 0.85rem 0.85rem 0.7rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.mapa-sidebar-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.45rem;
}

.mapa-busca-wrapper {
    position: relative;
}

.mapa-busca-svg {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.mapa-busca-input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2.3rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
    background: #f9fafb;
}

.mapa-busca-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
    background: #fff;
}

.mapa-sidebar-total {
    display: block;
    font-size: 0.72rem;
    color: #9ca3af;
    padding: 0.4rem 0 0;
    font-weight: 500;
}

/* ===== PILL FILTERS ===== */
.mapa-filtros {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex-shrink: 0;
}

.mapa-filtro-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
    user-select: none;
}

.mapa-filtro-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mapa-filtro-pill:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.mapa-filtro-pill.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
}

.mapa-filtro-pill.active .mapa-filtro-dot {
    box-shadow: 0 0 0 2px rgba(255,255,255,.35);
}

.mapa-filtro-pill .mapa-filtro-count {
    font-size: 0.68rem;
    opacity: 0.75;
    font-weight: 700;
}

/* ===== CATEGORY SECTIONS ===== */
.mapa-lista {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
}

.mapa-cat-section {
    margin-bottom: 0.25rem;
}

.mapa-cat-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1f2937;
    transition: color .2s;
}

.mapa-cat-toggle:hover {
    color: #3b82f6;
}

.mapa-cat-heading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.mapa-cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mapa-cat-count {
    font-size: 0.65rem;
    font-weight: 600;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 0.1rem 0.4rem;
    border-radius: 1rem;
    margin-left: 0.2rem;
}

.mapa-cat-chevron {
    transition: transform .25s;
    color: #9ca3af;
    flex-shrink: 0;
}

.mapa-cat-section.collapsed .mapa-cat-chevron {
    transform: rotate(-90deg);
}

.mapa-cat-cards {
    transition: max-height .3s ease;
    overflow: hidden;
}

.mapa-cat-section.collapsed .mapa-cat-cards {
    display: none;
}

/* ===== CARDS ===== */
.mapa-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.65rem;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .15s;
}

.mapa-card:hover,
.mapa-card:focus-visible {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59,130,246,.1);
    transform: translateY(-1px);
    outline: none;
}

.mapa-card-emergencia {
    border-left: 3px solid #dc2626;
    background: #fef2f2;
}

.mapa-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.mapa-card-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 0.35rem;
    flex-shrink: 0;
}

.mapa-card-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.mapa-card-nome {
    font-size: 0.84rem;
    line-height: 1.3;
}

.mapa-badge-emergencia {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mapa-card-detail {
    font-size: 0.8rem;
    color: #475569;
    margin: 0.15rem 0 0;
    line-height: 1.4;
    padding-left: 1.1rem;
}

.mapa-card-detail-meta {
    color: #64748b;
    font-size: 0.76rem;
}

/* ===== BOTÕES DE AÇÃO ===== */
.mapa-card-acoes {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.45rem;
    flex-wrap: wrap;
}

.mapa-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.28rem 0.55rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.7rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    background: #fff;
    color: #374151;
    transition: all .15s;
    white-space: nowrap;
}

.mapa-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.mapa-btn-ver {
    border-color: #3b82f6;
    color: #2563eb;
    font-weight: 600;
}
.mapa-btn-ver:hover { background: #eff6ff; }

.mapa-btn-maps { border-color: #22c55e; color: #16a34a; }
.mapa-btn-maps:hover { background: #f0fdf4; }

.mapa-btn-rota { border-color: #cbd5e1; color: #334155; }
.mapa-btn-rota:hover { background: #f8fafc; }

.mapa-btn-ligar {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
    font-weight: 600;
}
.mapa-btn-ligar:hover { background: #b91c1c; }

.mapa-btn-grande {
    padding: 0.65rem 1.5rem;
    font-size: 0.95rem;
}

/* ===== TOGGLE SIDEBAR (Mobile) ===== */
.mapa-toggle-sidebar {
    display: none;
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 600;
    padding: 0.45rem 0.8rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    color: #1f2937;
}

/* ===== MAPA LEAFLET ===== */
.mapa-leaflet {
    flex: 1;
    min-width: 0;
    min-height: 300px;
    height: 100%;
    z-index: 0;
}

/* ===== PIN ICONS (custom divIcon) ===== */
.mapa-pin-wrapper {
    background: none !important;
    border: none !important;
}

.mapa-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--pin-cor, #2563eb);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.28);
    border: 2px solid rgba(255,255,255,.92);
    position: relative;
}

.mapa-pin-letter {
    transform: rotate(45deg);
    line-height: 1;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: "Source Sans 3", system-ui, sans-serif;
}

.mapa-pin-emergencia {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.22), 0 2px 5px rgba(15, 23, 42, 0.28);
}

/* ===== CLUSTER ICONS ===== */
.mapa-cluster-wrapper {
    background: none !important;
    border: none !important;
}

.mapa-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    width: 44px;
    height: 44px;
}

.mapa-cluster-small  { background: #2563eb; }
.mapa-cluster-medium { background: #1d4ed8; }
.mapa-cluster-large  { background: #1e3a8a; }

/* ===== POPUP (custom) ===== */
.mapa-popup-custom .leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    padding: 0;
    overflow: hidden;
}

.mapa-popup-custom .leaflet-popup-content {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.mapa-popup-custom .leaflet-popup-tip {
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.mapa-popup {
    min-width: 200px;
}

.mapa-popup-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 3px solid;
    background: #f9fafb;
}

.mapa-popup-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mapa-popup-label {
    display: inline-block;
    min-width: 4.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #94a3b8;
}

.mapa-popup-title {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.mapa-popup-title strong {
    font-size: 0.9rem;
    line-height: 1.3;
}

.mapa-popup-tag {
    display: inline-block;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    width: fit-content;
}

.mapa-popup-body {
    padding: 0.6rem 0.85rem;
}

.mapa-popup-row {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #4b5563;
    margin: 0.2rem 0;
}

.mapa-popup-icon {
    flex-shrink: 0;
    font-size: 0.75rem;
}

.mapa-popup-desc {
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 0.3rem;
    font-style: italic;
}

.mapa-popup-acoes {
    display: flex;
    gap: 0.3rem;
    padding: 0.55rem 0.85rem;
    border-top: 1px solid #f3f4f6;
    background: #fafbfc;
    flex-wrap: wrap;
}

/* ===== EMERGÊNCIAS PAGE ===== */
.emergencias-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.emergencias-hero {
    text-align: left;
    margin-bottom: 1.75rem;
}

.emergencias-kicker {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 0 0.5rem;
}

.emergencias-kicker a {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 600;
}

.emergencias-hero h1 {
    font-size: 1.85rem;
    color: #0f172a;
    letter-spacing: -0.03em;
    margin: 0 0 0.45rem;
}

.emergencias-hero p {
    color: #64748b;
    font-size: 1rem;
    margin: 0;
}

.emergencias-numeros {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.emergencias-card-numero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    background: #fff;
    border: 2px solid #fca5a5;
    border-radius: 0.75rem;
    text-decoration: none;
    color: #1f2937;
    transition: all .2s;
}

.emergencias-card-numero:hover {
    border-color: #dc2626;
    box-shadow: 0 4px 12px rgba(220,38,38,.15);
    transform: translateY(-2px);
}

.emergencias-card-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.emergencias-card-numero strong {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.emergencias-card-tel {
    font-size: 1.8rem;
    font-weight: 800;
    color: #dc2626;
    margin-bottom: 0.5rem;
}

.emergencias-card-action {
    font-size: 0.8rem;
    font-weight: 600;
    color: #dc2626;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.emergencias-section-title {
    font-size: 1.3rem;
    margin: 2rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
}

.emergencias-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.emergencias-card-local {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: box-shadow .2s;
}

.emergencias-card-local:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.emergencias-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.emergencias-emoji {
    font-size: 1.5rem;
}

.emergencias-card-top strong {
    font-size: 1rem;
}

.emergencias-endereco,
.emergencias-telefone,
.emergencias-horario,
.emergencias-descricao {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0.2rem 0;
}

.emergencias-acoes {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.emergencias-aviso {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    margin: 2rem 0;
    font-size: 0.95rem;
}

.emergencias-link-mapa {
    text-align: center;
    margin: 1.5rem 0;
}

/* ===== RESPONSIVO ===== */
@media (max-width: 768px) {
    .mapa-logo-municipio { display: none; }
    .mapa-logo-modulo { font-size: 0.9rem; }
    .mapa-nav-link { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
    .mapa-nav-portal { display: none; }

    .mapa-footer-container { font-size: 0.65rem; }

    /* Sidebar overlay */
    .mapa-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 88%;
        max-width: 360px;
        transform: translateX(-100%);
        transition: transform .3s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,.15);
    }

    .mapa-sidebar.sidebar-aberta {
        transform: translateX(0);
    }

    .mapa-toggle-sidebar {
        display: flex;
        align-items: center;
        gap: 0.3rem;
    }

    .mapa-leaflet {
        width: 100%;
    }

    /* Emergências */
    .emergencias-numeros { grid-template-columns: repeat(2, 1fr); }
    .emergencias-card-tel { font-size: 1.4rem; }
    .emergencias-hero h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .mapa-header { height: 52px; padding: 0 0.65rem; }
    .mapa-main { height: calc(100vh - 86px); height: calc(100dvh - 86px); }
    .mapa-logo-modulo { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
    .emergencias-numeros { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .emergencias-card-numero { padding: 1rem 0.5rem; }
}
