* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', sans-serif;
}

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

/* ===== SEARCH + FILTER PANEL ===== */
.search-container {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 10;
    background-color: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 300px;
    gap: 8px;
    transition: background-color 0.3s ease;
}

.search-container:hover {
    background-color: rgba(255, 255, 255, 0.98);
}

.input-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    background: white;
    border: 1.5px solid #ddd;
    border-radius: 7px;
    padding: 0 8px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: #0077ff;
}

.search-icon {
    color: #888;
    font-size: 14px;
}

.search-input {
    border: none;
    background: transparent;
    padding: 8px 6px;
    width: 100%;
    outline: none;
    font-size: 14px;
    color: #222;
}

.clear-icon {
    cursor: pointer;
    font-size: 18px;
    color: #999;
    padding: 0 4px;
    line-height: 1;
    user-select: none;
}

.clear-icon:hover {
    color: #dc3545;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    width: 100%;
    gap: 5px;
}

.filter-btn {
    flex: 1;
    padding: 5px 4px;
    font-size: 11px;
    font-weight: 600;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    color: #555;
}

.filter-btn:hover {
    border-color: #aaa;
}

.filter-btn.active-all {
    background: #0077ff;
    color: white;
    border-color: #0077ff;
}

.filter-btn.active-online {
    background: #28a745;
    color: white;
    border-color: #28a745;
}

.filter-btn.active-offline {
    background: #fd7e14;
    color: white;
    border-color: #fd7e14;
}

.filter-btn.active-nonaktif {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

/* Search Results Dropdown */
.search-results {
    width: 100%;
    background-color: white;
    border-radius: 7px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    display: none;
    border: 1px solid #eee;
}

.search-results.show {
    display: block;
}

.search-item {
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    color: #333;
    transition: background 0.15s;
}

.search-item:last-child {
    border-bottom: none;
}

.search-item:hover {
    background-color: #f0f7ff;
}

.search-item strong {
    display: block;
    font-size: 13px;
    color: #111;
}

.search-item span {
    font-size: 11px;
    color: #777;
}

/* ===== STATS PANEL ===== */
.stats-panel {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    padding: 12px 16px;
    display: flex;
    gap: 14px;
    align-items: center;
}

.stat-item {
    text-align: center;
    min-width: 50px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    font-size: 10px;
    color: #888;
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-divider {
    width: 1px;
    height: 32px;
    background: #e0e0e0;
}

.color-online {
    color: #28a745;
}

.color-offline {
    color: #fd7e14;
}

.color-nonaktif {
    color: #dc3545;
}

.color-total {
    color: #0077ff;
}

/* ===== BADGE ===== */
.badge {
    padding: 2px 8px;
    border-radius: 20px;
    color: white;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.3px;
}

.bg-green {
    background-color: #28a745;
}

.bg-red {
    background-color: #dc3545;
}

.bg-orange {
    background-color: #fd7e14;
}

/* ===== POPUP ===== */
.maplibregl-popup-content {
    padding: 0;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    overflow: hidden;
    min-width: 220px;
}

.popup-header {
    padding: 10px 14px;
    color: white;
}

.popup-header.online {
    background: linear-gradient(135deg, #28a745, #20c75b);
}

.popup-header.offline {
    background: linear-gradient(135deg, #aaa, #888);
}

.popup-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.popup-header .router-name {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
}

.popup-body {
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.7;
}

.popup-row {
    display: flex;
    gap: 6px;
}

.popup-row b {
    color: #555;
    min-width: 56px;
}

.redaman-box {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 7px;
    text-align: center;
    padding: 8px;
    margin: 8px 0;
}

.redaman-label {
    font-size: 10px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.redaman-value {
    font-weight: 700;
    font-size: 18px;
    color: #555;
}

.popup-address {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.last-off-row {
    font-size: 12px;
    color: #aaa;
    border-top: 1px dashed #eee;
    padding-top: 4px;
    margin-top: 2px;
}

.last-off-row b {
    color: #bbb;
}

/* ===== ANIMASI ===== */
.blink {
    animation: blinker 1s linear infinite;
}

@keyframes blinker {
    50% {
        opacity: 0.4;
    }
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 520px) {
    .search-container {
        width: calc(100% - 32px);
        top: 12px;
        left: 16px;
    }

    .stats-panel {
        top: auto;
        bottom: 24px;
        right: 16px;
        padding: 8px 12px;
        gap: 10px;
    }

    .stat-value {
        font-size: 16px;
    }
}