/* satupeta.css - UPDATED FOR DYNAMIC SCROLLING */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: #e9f0ee;
    /* PERBAIKAN: Pastikan overflow diizinkan agar scrollbar muncul secara natural */
    overflow-y: auto;
    min-height: 100vh;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
}

#main-layout {
    /* PERBAIKAN: Gunakan min-height agar layout bisa bertambah tinggi ke bawah */
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: flex-start; /* Menghindari stretching tinggi sidebar */
}

/* Sidebar */
#sidebar {
    width: 380px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* PERBAIKAN: Gunakan sticky agar sidebar tetap di tempat saat halaman di-scroll */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.header-card .brand-row {
    display: flex;
    align-items: center;
    gap: 0px;
}

.brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.brand-title {
    font-weight: 800;
    color: #1f6f3f;
}

.brand-sub {
    font-size: 13px;
    color: #6d7a71;
}

/* Search box */
.search-box {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.search-box input {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #e6efe7;
}

.btn-search {
    background: #1f6f3f;
    color: #fff;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
}

/* small actions */
.small-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-ghost {
    background: #fff;
    border: 1px solid #e6efe7;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
}

/* Mapset card */
.card-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
}

.mapset-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 18px;
    border-radius: 8px;
    border: 1px dashed #e8efe8;
    background: linear-gradient(180deg, #fff, #fbfffb);
}

.mapset-icon {
    font-size: 28px;
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: linear-gradient(180deg, #e9f7ee, #e0f0e6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.mapset-title {
    font-weight: 700;
    color: #145936;
    margin-bottom: 6px;
}

.mapset-desc {
    font-size: 13px;
    color: #6d7a71;
    margin-bottom: 12px;
}

#mapset-content {
    max-height: 400px;
    overflow-y: auto;
}

.mapset-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 8px;
    background: #f9f9f9;
    margin-bottom: 8px;
    position: relative;
}

.cat-symbol {
    margin-right: 10px;
}

.cat-meta {
    flex: 1;
}

.cat-title {
    font-weight: 600;
    color: #333;
}

.cat-desc {
    font-size: 12px;
    color: #666;
}

.btn-primary {
    background: #1f6f3f;
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
}

/* Measurement */
.measure-tools {
    display: flex;
    gap: 10px;
}

.tool {
    width: 72px;
    height: 48px;
    border-radius: 10px;
    border: 1px solid #eef6ef;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
    font-size: 18px;
}

/* Footer small */
.sidebar-footer {
    margin-top: auto;
    text-align: center;
    color: #98a79f;
    font-size: 13px;
    padding-bottom: 4px;
}

/* --- Map Area Fix --- */
:root {
    --map-margin: 36px;
    --map-frame-radius: 12px;
}

#map-area {
    flex: 1;
    position: relative;
    /* PERBAIKAN: Ubah height vh menjadi min-height agar bisa memanjang saat agregat muncul */
    min-height: 100vh;
    padding-bottom: 50px; /* Jarak bawah agar tidak mepet */
}

#map {
    /* PERBAIKAN: Jangan gunakan position: absolute jika ingin mendorong konten di bawahnya */
    /* Namun jika Anda tetap ingin tampilan peta presisi, kita gunakan tinggi tetap */
    position: relative;
    height: calc(100vh - (var(--map-margin) * 2));
    margin: var(--map-margin);

    border-radius: 20px;
    border: 4px solid #1f6f3f;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15),
        inset 0 2px 8px rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #ffffff 0%, #f8fdf9 100%);
    overflow: hidden;
    z-index: 1;
}

/* Legend wrapper (fixed bar below the map) */
.legend-wrapper .legend-title {
    font-weight: 700;
    color: #333;
    margin-right: 12px;
    white-space: nowrap;
}
.legend-wrapper .legend-scale {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.legend-wrapper .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #444;
}
.legend-wrapper .legend-swatch {
    width: 16px;
    height: 12px;
    border: 1px solid #ccc;
    border-radius: 2px;
    display: inline-block;
}

/* Kontrol di dalam peta */
.map-controls {
    position: absolute;
    right: 32px;
    top: 132px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1200;
}

.map-ctrl {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.coord {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 13px;
    z-index: 1200;
}

.scale {
    position: absolute;
    right: 32px;
    bottom: 30px;
    z-index: 1200;
}

.chat-btn {
    position: absolute;
    right: 32px;
    bottom: 30px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: linear-gradient(135deg, #ff8a00, #ff5a2a);
    color: #fff;
    border: none;
    z-index: 1300;
    box-shadow: 0 4px 15px rgba(255, 90, 42, 0.3);
}

/* Responsive */
@media (max-width: 900px) {
    #sidebar {
        width: 320px;
    }
    #map {
        margin: 10px;
        height: 80vh;
    }
}
/* Overlay for peta */
#peta-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

#peta-overlay.show {
    display: flex;
}

#peta-overlay .overlay-content {
    width: 90vw;
    height: 90vh;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

/* ============================================
   CHOROPLETH LEGEND STYLES
   ============================================ */
.choropleth-legend {
    background: linear-gradient(135deg, #ffffff 0%, #f8fdf9 50%, #f0f8f2 100%);
    border-radius: 16px;
    padding: 20px 24px;
    box-shadow: 0 8px 24px rgba(20, 60, 30, 0.12),
        inset 0 1px 3px rgba(255, 255, 255, 0.8);
    border: 2px solid #d4edda;

    /* PERBAIKAN: Ubah position dari absolute ke relative/static agar dia muncul di bawah peta
       dan mendorong tinggi halaman sehingga scrollbar browser muncul */
    position: relative;
    margin: 20px var(--map-margin) 40px var(--map-margin);

    width: auto;
    min-width: 450px;
    max-width: 90%;
    z-index: 10;
}

.legend-title {
    font-weight: 800;
    font-size: 16px;
    color: #166d3b;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.legend-subtitle {
    font-weight: 600;
    font-size: 14px;
    color: #495057;
    margin-bottom: 12px;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: #fbfdfb;
    border-radius: 8px;
    border: 1px solid #f0f6f0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.legend-item:hover {
    background: #f0f8f2;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.legend-color {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 2px solid rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.legend-label {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.legend-value {
    font-size: 13px;
    font-weight: 700;
    color: #166d3b;
    background: linear-gradient(135deg, #e9f5ec 0%, #dff0df 100%);
    padding: 4px 10px;
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
}
