/* ==========================================================================
   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: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: #1f2937;
    background: #f3f4f6;
}

/* ===== HEADER SLIM (56px) ===== */
.mapa-header {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    z-index: 1000;
    position: relative;
}

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

.mapa-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #1f2937;
    font-weight: 700;
    flex-shrink: 0;
}

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

.mapa-logo-text {
    font-size: 0.85rem;
    white-space: nowrap;
}

.mapa-titulo {
    font-size: 1.05rem;
    margin: 0;
    color: #1e40af;
    white-space: nowrap;
    font-weight: 700;
}

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

.mapa-nav-link {
    padding: 0.35rem 0.8rem;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
    transition: background .2s, color .2s;
}

.mapa-nav-link:hover {
    background: #f3f4f6;
    color: #1e40af;
}

.mapa-btn-emergencia {
    background: #ef4444 !important;
    color: #fff !important;
    font-weight: 600;
    animation: pulse-subtle 3s ease-in-out 2;
}

.mapa-btn-emergencia:hover {
    background: #dc2626 !important;
}

@keyframes pulse-subtle {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
    50% { box-shadow: 0 0 0 6px rgba(239,68,68,.25); }
}

/* ===== FOOTER MICRO (36px) ===== */
.mapa-footer {
    height: 36px;
    background: #1f2937;
    color: #9ca3af;
    font-size: 0.68rem;
    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);
    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.75rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.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.25rem;
    padding: 0.3rem 0.65rem;
    border-radius: 2rem;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
    user-select: none;
}

.mapa-filtro-pill:hover {
    border-color: var(--pill-cor, #6b7280);
    color: var(--pill-cor, #6b7280);
}

.mapa-filtro-pill.active {
    background: var(--pill-cor, #6b7280);
    border-color: var(--pill-cor, #6b7280);
    color: #fff;
}

.mapa-filtro-pill .mapa-filtro-count {
    font-size: 0.62rem;
    opacity: 0.8;
    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-emoji {
    font-size: 1.2rem;
    line-height: 1;
    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.76rem;
    color: #6b7280;
    margin: 0.12rem 0;
    line-height: 1.4;
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}

.mapa-card-detail span {
    flex-shrink: 0;
    font-size: 0.7rem;
}

/* ===== 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: #f97316; color: #ea580c; }
.mapa-btn-rota:hover { background: #fff7ed; }

.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, #3b82f6);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    position: relative;
    transition: transform .15s;
}

.mapa-pin:hover {
    transform: rotate(-45deg) scale(1.15);
}

.mapa-pin-emoji {
    transform: rotate(45deg);
    line-height: 1;
    filter: grayscale(0);
}

.mapa-pin-emergencia {
    animation: pin-pulse 2s ease-in-out infinite;
}

@keyframes pin-pulse {
    0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,.3); }
    50% { box-shadow: 0 0 0 8px rgba(220,38,38,.25), 0 2px 6px rgba(0,0,0,.3); }
}

/* ===== 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: rgba(59,130,246,.75); }
.mapa-cluster-medium { background: rgba(245,158,11,.8); }
.mapa-cluster-large  { background: rgba(239,68,68,.8); }

/* ===== 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-emoji {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.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: center;
    margin-bottom: 2rem;
}

.emergencias-hero h1 {
    font-size: 2rem;
    color: #dc2626;
    margin-bottom: 0.5rem;
}

.emergencias-hero p {
    color: #6b7280;
    font-size: 1.05rem;
}

.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-titulo { display: none; }
    .mapa-logo-text { display: none; }
    .mapa-nav-link:not(.mapa-btn-emergencia) { display: none; }

    .mapa-footer-container { font-size: 0.6rem; }
    .mapa-footer-sep:last-of-type,
    .mapa-footer span:nth-child(3) { display: none; }

    /* 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: 48px; padding: 0 0.5rem; }
    .mapa-main { height: calc(100vh - 84px); }
    .mapa-btn-emergencia { padding: 0.3rem 0.5rem; font-size: 0.72rem; }
    .emergencias-numeros { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .emergencias-card-numero { padding: 1rem 0.5rem; }
    .emergencias-card-icon { font-size: 1.8rem; }
}
