/* ================================================
   MAP.CSS — Mapa, Marcadores, Clusters, GPS,
             Filtros, Context Menu e Controles
   Midnight Edition | MinhaRua App
   ================================================ */

/* ================= CONTAINER DO MAPA ================= */
.map-container {
    flex: 1;
    position: relative;
    width: 100%;
    background-color: #1A1A1D;
}

#map {
    width: 100%;
    height: 100%;
    z-index: var(--z-map);
}

/* Filtro midnight no tile do Leaflet */
[data-tema="escuro"] .leaflet-tile-pane {
    filter: brightness(1.45) saturate(1.8) hue-rotate(-12deg) contrast(0.9);
}

/* ================= CONTROLES DE ZOOM ================= */
.leaflet-control-zoom {
    border: 1px solid rgba(57, 255, 110, 0.2) !important;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.leaflet-control-zoom a {
    background: rgba(18, 20, 26, 0.85) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #a3ff00 !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 1.4rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    transition: background 0.2s, color 0.2s !important;
}

.leaflet-control-zoom a:hover {
    background: rgba(26, 30, 38, 0.95) !important;
    color: #fff !important;
}

/* Suporte ao tema claro para os controles de zoom */
[data-tema="claro"] .leaflet-control-zoom a {
  background-color: #ffffff !important;
  color: #1e293b !important;
  border-color: #cbd5e1 !important;
}

[data-tema="claro"] .leaflet-control-zoom a:hover {
  background-color: #f1f5f9 !important;
}

@media (max-width: 768px) {
    .leaflet-control-zoom { display: none !important; }
    .leaflet-control-localizar { top: 70px; }
}

/* ================= BOTÃO LOCALIZADOR ================= */
.leaflet-control-localizar {
    position: absolute;
    top: 115px;
    right: 10px;
    z-index: 1000;
}

#btn-localizar {
    width: 44px;
    height: 44px;
    background: rgba(18, 20, 26, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(57, 255, 110, 0.2);
    border-radius: 12px;
    color: #a3ff00;
    font-size: 1.2rem;
    transform: scale(1.05);
}

.zoom-controls button:active { transform: scale(0.95); }

/* ================= GPS EM TEMPO REAL ================= */
.gps-marker-pulse {
    width: 24px;
    height: 24px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gps-marker-dot {
    width: 14px;
    height: 14px;
    background: #3B82F6;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.6);
    position: relative;
    z-index: 2;
}

.gps-marker-pulse::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: rgba(59, 130, 246, 0.35);
    border-radius: 50%;
    animation: gps-pulse 1.8s ease-out infinite;
}

@keyframes gps-pulse {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

#btn-localizar.gps-ativo {
    background: #EFF6FF;
    color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
    outline: none;
    animation: gps-btn-pulse 2s ease-in-out infinite;
}

#btn-localizar.gps-ativo svg { stroke: #3B82F6; }

@keyframes gps-btn-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15); }
}

/* ================= MARCADORES NEON (DROP PIN) ================= */
.neon-marker {
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    cursor: pointer;
}

.neon-marker:hover { transform: rotate(-45deg) scale(1.18); }

.nm-inner {
    transform: rotate(45deg);
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    user-select: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* Variantes por categoria */
.neon-buraco    { background: rgba(239, 68, 68, 0.88); border: 2.5px solid rgba(255,150,150,0.6); }
.neon-iluminacao{ background: rgba(245,158, 11, 0.88); border: 2.5px solid rgba(255,215,100,0.6); }
.neon-vegetacao { background: rgba( 16,185,129, 0.88); border: 2.5px solid rgba(100,255,200,0.6); }
.neon-vazamento { background: rgba( 59,130,246, 0.88); border: 2.5px solid rgba(140,195,255,0.6); }
.neon-lixo      { background: rgba(139, 92,246, 0.88); border: 2.5px solid rgba(190,160,255,0.6); }
.neon-placa     { background: rgba(220, 38, 38, 0.88); border: 2.5px solid rgba(255,120,120,0.6); }
.neon-outros    { background: rgba(242,125, 35, 0.88); border: 2.5px solid rgba(255,185,110,0.6); }

/* ================= MARCADOR RESOLVIDO ================= */
.marker-resolvido {
    width: 38px;
    height: 38px;
    background: white;
    border: 3px solid #22C55E;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25), 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: marker-resolvido-pulse 2.5s ease-in-out infinite;
    position: relative;
}

.marker-resolvido::after {
    content: '✅';
    position: absolute;
    font-size: 11px;
    top: -6px;
    right: -6px;
    background: white;
    border-radius: 50%;
    line-height: 1;
}

@keyframes marker-resolvido-pulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25), 0 2px 8px rgba(0, 0, 0, 0.2); }
    50%       { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0.1), 0 2px 8px rgba(0, 0, 0, 0.2); }
}

/* ================= MARKER CLUSTER ================= */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background-color: transparent !important; }

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div { background-color: transparent !important; color: inherit !important; }

.cluster-midnight {
    background: rgba(18, 20, 26, 0.92);
    border: 1.5px solid rgba(57, 255, 110, 0.55);
    border-radius: 50%;
    color: #ffffff;
    font-family: 'Inter', 'Poppins', sans-serif;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.cluster-midnight:hover {
    transform: scale(1.08);
}

/* ================= PAINEL LATERAL DE FILTROS ================= */
.floating-panel,
#painel-filtros {
    position: absolute;
    top: 90px;
    left: 20px;
    width: 240px;
    background: rgba(10, 14, 22, 0.78);
    backdrop-filter: blur(18px) saturate(1.4);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid rgba(57, 255, 110, 0.22);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(57,255,110,0.08), inset 0 1px 0 rgba(255,255,255,0.06);
    color: rgba(255, 255, 255, 0.9);
    padding: 15px;
    z-index: var(--z-panel);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    display: none;
}

#painel-filtros.ativo {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.floating-panel::-webkit-scrollbar { width: 4px; }
.floating-panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

#painel-filtros::before {
    content: '';
    display: none;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #cbd5e1;
    border-radius: 10px;
    z-index: 10;
}

@media (max-width: 768px) {
    #painel-filtros.ativo::before { display: block; }
    #painel-filtros.ativo { padding-top: 20px; }

    .floating-panel,
    #painel-filtros {
        display: none;
        position: fixed;
        width: 100%;
        left: 0;
        bottom: 65px;
        top: auto;
        max-height: 70vh;
        z-index: 9999;
        border-radius: 20px 20px 0 0;
        padding: 20px;
        padding-top: 25px;
        animation: slideUpPanel 0.3s ease-out;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.2);
        overflow-y: auto;
        overflow-x: hidden;
        will-change: transform, opacity;
    }

    .floating-panel.ativo,
    #painel-filtros.ativo { display: flex; flex-direction: column; }

    .floating-panel::before,
    #painel-filtros::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 50px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 10px;
        z-index: 10;
        animation: pulseHandle 2s ease-in-out infinite;
    }

    @keyframes pulseHandle {
        0%, 100% { opacity: 0.6; }
        50% { opacity: 1; }
    }

    @keyframes slideUpPanel {
        from { transform: translateY(100%); opacity: 0; }
        to   { transform: translateY(0); }
    }
}

#painel-filtros h3 {
    margin-top: 0;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(57, 255, 110, 0.2);
    color: #39ff14;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-list { display: flex; flex-direction: column; gap: 6px; }

.btn-filter-map {
    background: transparent;
    border: 1px solid #eee;
    padding: 8px 12px;
    text-align: left;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dark);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.btn-filter-map:hover { background: #f8f9fa; padding-left: 16px; }
.btn-filter-map.ativo {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(10, 61, 98, 0.2);
}

.separator {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin: 12px 0 4px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

/* ================= CONTEXT MENU / BOTÃO REPORTAR DESKTOP ================= */
#context-menu {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: transparent;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50px;
    box-shadow: none;
    display: none;
    justify-content: center;
    align-items: center;
    width: auto !important;
}

.context-item {
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    font-weight: 800;
    color: #0d1a00;
    background: #a3ff00;
    border: none;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
    padding: 13px 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.context-item:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 6px 16px rgba(0,0,0,0.4); }
.context-item:active { transform: scale(0.96); }

@media (max-width: 768px) { .btn-nova-ocorrencia-desktop { display: none; } }

/* ================= FOTOS ANTES/DEPOIS ================= */
.foto-antes-depois { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.foto-lado { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.foto-lado img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; cursor: pointer; transition: transform 0.2s; }
.foto-lado img:hover { transform: scale(1.03); }
.foto-seta { font-size: 1.4rem; color: #22C55E; font-weight: bold; flex-shrink: 0; }
