html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1; 
}

/* ==========================================================
   #map-controls (Kontrol Peta) - DEFAULT (Desktop/Tablet)
   ========================================================== */
#map-controls {
    position: absolute;
    top: 20px; /* Diubah dari -20px agar langsung terlihat saat load */
    left: 50%; 
    transform: translateX(-50%); 
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 20px 15px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    white-space: nowrap;
    transition: top 0.4s ease-in-out;
}

#map-controls .title {
    font-size: 16px;
    font-weight: bold;
    margin-right: 20px; /* Margin diperkecil untuk desktop */
}

#map-controls .title .namaMPP_sm {
    font-size: 30px !important;
}

#map-controls button {
    margin-left: 5px; 
    width: 38px;
    height: 38px;
    font-size: 16px;
}

/* ==========================================================
   .slide-in-panel (Panel Detail Samping) - DEFAULT
   ========================================================== */
.slide-in-panel {
    position: fixed;
    top: 0;
    right: -500px; 
    width: 500px; /* Lebar default */
    height: 100%;
    background-color: white;
    box-shadow: -2px 0 8px rgba(0,0,0,0.2);
    z-index: 2000;
    padding: 20px;
    overflow-y: auto;
    transition: right 0.3s ease-in-out;
}

.slide-in-panel.open {
    right: 0;
}

.slide-in-panel .close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
}

#stats-accordion .card-header a {
    text-decoration: none;
    color: #343a40; 
    font-weight: bold;
}

#stats-accordion .card-header a:hover {
    color: #0056b3; 
}

#stats-accordion .card-body {
    padding: 0; 
}

/* ==========================================================
   Leaflet Controls & Custom Markers
   ========================================================== */
.leaflet-control-custom {
    background: #fff;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
}

.leaflet-control-custom a {
    background-position: 50% 50%;
    background-repeat: no-repeat;
    display: block;
    width: 30px;
    height: 30px;
    text-align: center;
    line-height: 30px;
    font-size: 16px; 
    color: #333; 
    text-decoration: none;
}

.leaflet-control-custom a:hover {
    background-color: #f4f4f4;
    color: #000;
}

.polygon-center-label {
    border: none !important;
    background: transparent !important;
}
.polygon-center-label * {
    pointer-events: none;
}

.leaflet-div-icon {
    background: transparent;
    border: none;
}

.polygon-bubble {
    position: relative; 
    height: 22px; 
    padding: 3px 8px;
    box-sizing: border-box; 
    border-radius: 10px;
    color: white;
    font-size: 10px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    white-space: nowrap;
    text-overflow: ellipsis; 
    background-color: #50cd89; 
}

.polygon-bubble::after {
    content: '';
    position: absolute;
    bottom: -5px; 
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent; 
    border-right: 6px solid transparent; 
    border-top: 6px solid #0d6efd; 
}

.polygon-bubble.bg-info {
    background-color: #50cd89; 
}
.polygon-bubble.bg-info::after {
    border-top-color: #50cd89; 
}

.polygon-bubble.bg-danger {
    background-color: #dc3545; 
}
.polygon-bubble.bg-danger::after {
    border-top-color: #dc3545; 
}

/* ==========================================================
   Panel Bottom (Legenda) & Control Collapse
   ========================================================== */
#map-controls.collapsed {
    top: -80px; 
}

.collapse-control-wrapper {
    position: absolute;
    bottom: -20px; 
    left: 50%;
    transform: translateX(-50%);
}

#collapse-controls-btn {
    border-radius: 50%; 
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.slide-panel-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000; 
    background-color: #ffffff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease-in-out;
    max-height: 50vh; 
    transform: translateY(100%); 
}

.slide-panel-bottom.open {
    transform: translateY(0);
}

.slide-panel-bottom .panel-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    height: 50px; 
    cursor: pointer;
    border-bottom: 1px solid #eee;
    position: relative;
}

.slide-panel-bottom .panel-header #toggleLegendBtn {
    position: absolute;
    top: 0; 
    left: 2%; 
    transform: translate(-50%, -100%); 
    margin-right: 0; 
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-bottom: none; 
    border-radius: 5px 5px 0 0; 
}

.slide-panel-bottom.open #toggleLegendBtn i {
    transform: rotate(180deg);
}
.slide-panel-bottom #toggleLegendBtn i {
    transition: transform 0.3s ease;
}

.slide-panel-bottom .panel-header .panel-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    margin-left: 0px; 
}

.slide-panel-bottom .panel-content {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(40vh - 50px); 
}


/* ==========================================================
   Font Faces & Utility Classes
   ========================================================== */
@font-face {
	font-family: 'changa'; 
	src: url('../../assets/fonts/Changa/Changa-VariableFont_wght.ttf') format('truetype');
	font-weight: normal; 
	font-style: normal; 
}

.changa {
	font-family: 'changa';
}

.divNama_sm {
	font-family: 'changa';
	color:#000;
	text-align: left;
}

.namaApp_sm {
	font-size:24px;
	white-space: nowrap;
	line-height: 18px;
	margin-bottom:0%;
} 
.subApp_sm {
	font-size:18px;
	white-space: nowrap;
	margin-top:0%;
}


/* ==========================================================
   SweetAlert Toast Styling
   ========================================================== */
.colored-toast.swal2-icon-success { background-color: #a5dc86 !important; }
.colored-toast.swal2-icon-error { background-color: #f27474 !important; }
.colored-toast.swal2-icon-warning { background-color: #f8bb86 !important; }
.colored-toast.swal2-icon-info { background-color: #3fc3ee !important; }
.colored-toast.swal2-icon-question { background-color: #87adbd !important; }
.colored-toast .swal2-title { color: white; }
.colored-toast .swal2-close { color: white; }
.colored-toast .swal2-html-container { color: white; }


/* ==========================================================
   Custom Leaflet Popup Styling
   ========================================================== */
.custom-leaflet-popup .leaflet-popup-content-wrapper {
    background: transparent; 
    border: none;
    box-shadow: none; 
    padding: 0; 
}

.custom-leaflet-popup .leaflet-popup-content {
    margin: 0;
    padding: 0;
    width: auto !important; 
}

.custom-leaflet-popup .leaflet-popup-tip-container {
    display: none;
}

.custom-leaflet-popup .leaflet-popup-content .card {
    margin: 0; 
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); 
    border-radius: 8px; 
    overflow: hidden; 
}

.custom-leaflet-popup .leaflet-popup-close-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%; 
    width: 28px;
    height: 28px;
    font: bold 20px 'Arial', sans-serif;
    color: #555;
    text-align: center;
    line-height: 28px; 
    z-index: 10; 
    transition: all 0.2s ease;
}

.custom-leaflet-popup .leaflet-popup-close-button:hover {
    background-color: #ffffff;
    color: #000;
}


/* ==========================================================
   RESPONSIVENESS (Mobile Adjustments)
   ========================================================== */
@media (max-width: 767px) {
    
    /* Kontrol Peta: Layout Mobile */
    #map-controls {
        /* Posisikan di bawah pada mobile */
        top: auto;
        bottom: 20px; 
        left: 50%;
        transform: translateX(-50%);
        width: calc(100% - 40px); /* Ambil hampir semua lebar layar */
        
        display: flex;
        flex-wrap: wrap; 
        justify-content: center;
        padding: 10px;
    }

    /* Sembunyikan Tulisan Panjang/Title di Mobile agar kontrol muat */
    #map-controls .title {
        display: none !important; 
    }
    
    /* Kecilkan Logo */
    #map-controls img {
        max-height: 30px !important; 
    }
    
    /* Atur Jarak antar Tombol */
    #map-controls > a, 
    #map-controls > button {
        margin: 5px !important; 
        flex-shrink: 0; 
    }

    /* Sembunyikan Tombol Collapse Kontrol di Mobile */
    .collapse-control-wrapper {
        display: none; 
    }
    
    /* Panel Detail Samping: Lebar Mobile */
    .slide-in-panel {
        width: 90%; 
    }
    
    /* Panel Legenda Bawah: Tinggi Mobile */
    .slide-panel-bottom {
        max-height: 60vh; /* Maksimal 60% tinggi layar HP */
    }
    
    .slide-panel-bottom .panel-content {
        max-height: calc(60vh - 50px); /* Konten menyesuaikan max-height baru */
    }
}

@media (max-width: 480px) {
    /* Untuk HP yang sangat kecil, ambil seluruh lebar layar */
    .slide-in-panel {
        width: 100%;
    }
}