/* ============================================================
   GUARUGEO - MAP & CONTROLS
   ============================================================ */

#map {
    flex: 1;
    height: 100vh;
    z-index: 1;
    position: relative;
}

.map-back-btn {
    position: absolute;
    top: 180px; /* Bem abaixo do seletor de mapas do Google */
    left: 14px;
    z-index: 1000000; /* Garantir que fique acima dos controles nativos do Google */
    padding: 10px 18px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 800;
    color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.map-back-btn:hover {
    transform: translateX(-4px);
    background: #f8fafc;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.map-back-btn.hidden {
    display: none !important;
}

/* Floating Unified Panel (Stats + Legend) - Bottom Left & Discrete */
.stats-panel {
    position: absolute;
    bottom: 80px; /* Alavancado para evitar botões de angulação/tilt do Google */
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 18px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    width: 200px;
    /* Width fixed to keep it discrete */
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-item {
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.stat-item div:first-child {
    font-size: 10px !important;
    font-weight: 800;
    text-transform: uppercase;
    color: #94a3b8 !important;
}

.stat-item div:last-child {
    font-size: 16px !important;
    font-weight: 900 !important;
    color: var(--text-main) !important;
}

.toggle-neighborhoods-btn {
    padding: 10px 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.toggle-neighborhoods-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Dashboard Actions (Bottom Panel) */
.dashboard-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.dashboard-btn {
    flex: 1 1 auto;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 80px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dashboard-btn.primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.2);
}

.dashboard-btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.dashboard-btn.secondary {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.dashboard-btn.secondary:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Heatmap specific style */
.btn-heatmap.active {
    background: linear-gradient(135deg, #f87171, #ef4444) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3) !important;
}

.dashboard-btn.active {
    /* Style for active toggles (like Heatmap) */
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gps-location-btn {
    position: absolute;
    bottom: 150px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: 18px;
}

/* Zone Legend integrated into Stats Panel in JS, or positioned over it */
.zone-legend {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    max-height: none !important;
    overflow-y: visible !important;
    border: none !important;
    margin-top: 0 !important;
    margin-left: 0 !important;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.legend-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.legend-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-main);
}

/* ============================================================
   CONTEXT MENU STYLES (Restored)
   ============================================================ */
#context-menu {
    display: none;
    position: absolute;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    min-width: 180px;
    z-index: 10000;
    overflow: hidden;
    padding: 5px 0;
    animation: fadeIn 0.1s ease-out;
}

.context-menu-item {
    padding: 10px 15px;
    font-size: 13px;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.context-menu-item:hover {
    background: #f1f5f9;
}


.context-menu-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 4px 0;
}

/* ============================================================
   MOBILE RESPONSIVENESS
   ============================================================ */
@media (max-width: 768px) {

    /* Adjust Stats Panel position */
    .stats-panel {
        bottom: 20px; /* Ajuste para mobile */
        left: 10px;
        right: auto;
        width: auto;
        min-width: 140px;
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        padding: 12px;
    }

    /* GPS Button higher up */
    .gps-location-btn {
        bottom: 160px;
        right: 15px;
        width: 50px;
        height: 50px;
    }

    /* Larger touch targets for dashboard buttons */
    .dashboard-btn {
        padding: 12px 16px;
        font-size: 12px;
    }

    /* Make stats text legible but smaller */
    .stat-item div:last-child {
        font-size: 14px !important;
    }

    /* Ensure context menu fits on screen */
    #context-menu {
        max-width: 250px;
    }

    /* Prevent huge popups on mobile */
    .leaflet-popup-content-wrapper {
        max-width: 300px !important;
        font-size: 13px;
    }

    .leaflet-popup-content {
        margin: 10px !important;
    }
}

@keyframes slideUp {
    from { transform: translate(-50%, 100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* ============================================================
   GOOGLE MAPS INFOWINDOW OVERRIDES (BEAUTIFICATION)
   ============================================================ */
.gm-style-iw.gm-style-iw-c {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    padding: 0 !important;
}

.gm-style-iw-d {
    overflow: hidden !important;
    max-height: none !important;
}

/* Hide the default background of the tail/pointer */
.gm-style-iw-t::after {
    background: rgba(255, 255, 255, 0.95) !important;
    box-shadow: -2px 2px 2px 0 rgba(0, 0, 0, 0.05) !important;
}

/* Close button positioning and styling */
.gm-ui-hover-effect {
    top: 6px !important;
    right: 6px !important;
    background: rgba(241, 245, 249, 0.8) !important;
    border-radius: 50% !important;
    opacity: 1 !important;
    transition: all 0.2s ease !important;
}

.gm-ui-hover-effect:hover {
    background: rgba(226, 232, 240, 1) !important;
    transform: scale(1.1);
}

.gm-ui-hover-effect span {
    width: 20px !important;
    height: 20px !important;
    margin: 5px !important;
}

/* ============================================================
   LOT TOOLTIP TABS
   ============================================================ */
.lot-tooltip-tabs {
    display: flex;
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 10px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.lot-tab-btn {
    padding: 12px 18px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lot-tab-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.lot-tab-btn.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

.lot-tab-content {
    display: none;
}

.lot-tab-content.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.lot-tooltip-body {
    padding: 20px;
    max-height: 65vh;
    overflow-y: auto;
    background: white;
}

.lot-tooltip-body::-webkit-scrollbar {
    width: 6px;
}

.lot-tooltip-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.lot-tooltip-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}