* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #0f2b3d 0%, #1a4a6f 100%);
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 3px solid #ffc107;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-title i {
    font-size: 28px;
    color: #ffc107;
}

.logo-title h1 {
    font-size: 1.6rem;
    font-weight: 800;
}

.logo-title p {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-top: 2px;
}

.header-badge {
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 40px;
    font-size: 0.8rem;
}

.data-status {
    font-size: 0.7rem;
    margin-top: 4px;
    color: #ffc107;
}

/* Dashboard */
.dashboard {
    background: white;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid #e2e8f0;
    z-index: 10;
    flex-shrink: 0;
}

.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: space-between;
    align-items: center;
}

.total-card {
    background: linear-gradient(135deg, #1e3c72 0%, #2b4c8a 100%);
    color: white;
    padding: 8px 20px;
    border-radius: 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.total-card .value {
    font-size: 24px;
    font-weight: 800;
}

.type-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #f8fafc;
    padding: 5px 15px;
    border-radius: 48px;
    min-width: 0;
}

.type-badge {
    background: white;
    border-radius: 40px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-left: 4px solid;
}

/* Search */
.search-wrapper {
    position: relative;
    background: white;
    border-radius: 48px;
    display: flex;
    align-items: center;
    padding: 4px 12px;
    gap: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    min-width: 0;
}

.search-wrapper input {
    border: none;
    outline: none;
    font-size: 14px;
    width: 220px;
    padding: 8px 0;
    min-width: 0;
}

.search-wrapper button {
    background: #1e3c72;
    border: none;
    color: white;
    padding: 6px 14px;
    border-radius: 40px;
    cursor: pointer;
    font-size: 13px;
    transition: 0.2s;
}

.search-wrapper button:hover {
    background: #0f2b4f;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    max-height: 260px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.autocomplete-item:hover {
    background-color: #f1f5f9;
}

/* Peta */
#map {
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 1;
    min-height: 0;
}

/* Popup */
.custom-popup .house-name {
    font-weight: 800;
    font-size: 15px;
    margin-bottom: 6px;
    color: #0f172a;
    border-bottom: 2px solid #e2e8f0;
}

.info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px 12px;
    font-size: 12px;
    margin-top: 8px;
}

.info-grid i {
    width: 18px;
    color: #3b82f6;
}

/* Control buttons */
.custom-control-btn {
    background: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: 0.2s;
}

.custom-control-btn:hover {
    background: #eef2ff;
    transform: scale(1.05);
}

.map-sidebar {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.sidebar-shell {
    width: 280px;
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.97);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    overflow: hidden;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.map-sidebar.collapsed .sidebar-shell {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}

.map-sidebar.collapsed {
    gap: 0;
}

.sidebar-toggle-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #1e3c72;
    transition: 0.2s;
}

.sidebar-toggle-btn:hover {
    background: #eef2ff;
    transform: scale(1.05);
}

.leaflet-top.leaflet-right .leaflet-control-zoom {
    margin-top: 20px;
    margin-right: 20px;
}

.sidebar-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, #1e3c72, #2b4c8a);
    color: white;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 800;
}

.sidebar-subtitle {
    margin-top: 2px;
    font-size: 12px;
    opacity: 0.9;
}

.sidebar-content {
    padding: 12px;
    overflow-y: auto;
    max-height: calc(100vh - 190px);
}

.sidebar-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.sidebar-card + .sidebar-card {
    margin-top: 12px;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
}

.layer-control-section {
    padding: 10px 12px;
}

.layer-control-title {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.layer-control-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #0f172a;
    cursor: pointer;
}

.layer-control-item:last-child {
    margin-bottom: 0;
}

.layer-control-item input {
    margin: 0;
    cursor: pointer;
}

.layer-control-item span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-control-item i {
    width: 16px;
    color: #1e3c72;
}

/* Legend */
.legend-content {
    padding: 10px 12px;
}

.legend-group-title {
    margin: 8px 0 6px;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
}

.legend-group-title:first-child {
    margin-top: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 12px;
}

.legend-color {
    width: 18px;
    height: 12px;
    border-radius: 2px;
    margin-right: 10px;
}

.legend-color-point {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 10px;
}

/* Animasi pulse untuk marker lokasi */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Responsive */
@media (max-width: 800px) {
    .app-header {
        padding: 12px 16px;
    }

    .logo-title {
        align-items: flex-start;
        gap: 10px;
    }

    .logo-title i {
        font-size: 24px;
    }

    .logo-title h1 {
        font-size: 1.15rem;
    }

    .logo-title p {
        font-size: 0.75rem;
    }

    .dashboard {
        padding: 10px 12px;
    }

    .stats-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .type-stats {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 10px;
        border-radius: 16px;
    }

    .type-badge {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .search-wrapper {
        width: 100%;
        flex-wrap: wrap;
        align-items: center;
        border-radius: 16px;
        padding: 10px 12px;
        gap: 10px;
    }

    .search-wrapper > i {
        font-size: 15px;
        color: #64748b;
    }

    .search-wrapper input {
        flex: 1 1 160px;
        width: auto;
        padding: 6px 0;
    }

    .search-wrapper button {
        flex: 1 1 calc(50% - 5px);
        justify-content: center;
        padding: 10px 12px;
    }

    .map-sidebar {
        top: auto;
        bottom: 10px;
        left: 10px;
        right: 10px;
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 8px;
    }

    .sidebar-shell {
        width: 100%;
        max-width: none;
        max-height: min(58vh, calc(100dvh - 220px));
        border-radius: 18px;
    }

    .sidebar-content {
        max-height: min(50vh, calc(100dvh - 290px));
    }

    .map-sidebar.collapsed .sidebar-shell {
        transform: translateY(calc(100% + 12px));
        opacity: 0;
        pointer-events: none;
    }

    .sidebar-toggle-btn {
        width: 44px;
        height: 44px;
        align-self: flex-end;
        border-radius: 14px;
    }

    .autocomplete-list {
        max-height: min(40vh, 280px);
    }

    .leaflet-top.leaflet-right .leaflet-control-zoom {
        margin-top: 12px;
        margin-right: 10px;
    }

    .leaflet-bottom.leaflet-left .leaflet-control,
    .leaflet-bottom.leaflet-right .leaflet-control {
        margin-bottom: 10px;
    }
}

@media (max-width: 520px) {
    .app-header {
        padding: 10px 12px;
    }

    .logo-title h1 {
        font-size: 1rem;
    }

    .logo-title p {
        font-size: 0.7rem;
    }

    .dashboard {
        padding: 8px 10px;
    }

    .search-wrapper {
        padding: 10px;
    }

    .search-wrapper input {
        flex-basis: 100%;
        width: 100%;
    }

    .search-wrapper button {
        flex-basis: 100%;
        width: 100%;
    }

    .map-sidebar {
        bottom: 8px;
        left: 8px;
        right: 8px;
    }

    .sidebar-shell {
        max-height: min(62vh, calc(100dvh - 210px));
    }

    .sidebar-header {
        padding: 12px 14px;
    }

    .sidebar-content {
        padding: 10px;
    }

    .sidebar-title {
        font-size: 15px;
    }

    .sidebar-subtitle {
        font-size: 11px;
    }
}
