:root {
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --primary: #6366f1; /* Indigo */
    --accent: #38bdf8;  /* Sky Blue */
    --danger: #ef4444;
    --success: #22c55e;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; }

body { background-color: #f1f5f9; color: #334155; }

.dashboard-container { display: flex; min-height: 100vh; }

/* --- SIDEBAR --- */
.sidebar {
    width: 260px; background-color: var(--sidebar-bg); color: var(--text-light);
    display: flex; flex-direction: column; padding: 25px;
    position: fixed; height: 100vh; z-index: 1000;
}
.logo { font-size: 1.4rem; font-weight: 700; margin-bottom: 40px; color: white; display: flex; align-items: center; gap: 10px; }
.logo span { color: var(--accent); }
.nav-links { list-style: none; flex: 1; }
.nav-links li { margin-bottom: 8px; }
.nav-links a {
    text-decoration: none; color: var(--text-muted); padding: 12px 15px; display: flex;
    align-items: center; border-radius: 10px; transition: 0.3s; font-weight: 500; font-size: 0.9rem;
}
.nav-links a i { margin-right: 12px; width: 20px; text-align: center; }
.nav-links li.active a, .nav-links a:hover { background-color: var(--primary); color: white; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }
.server-status { margin-top: auto; background: rgba(255,255,255,0.05); padding: 12px; border-radius: 10px; font-size: 0.8rem; display: flex; align-items: center; gap: 10px; }
.pulse-dot { width: 8px; height: 8px; background-color: var(--success); border-radius: 50%; animation: pulse 2s infinite; }

/* --- MAIN CONTENT --- */
.main-content { flex: 1; margin-left: 260px; padding: 30px; }
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.user-profile { display: flex; align-items: center; gap: 15px; font-weight: 500; font-size: 0.9rem; }
.avatar { width: 40px; height: 40px; background: var(--primary); color: white; border-radius: 10px; display: flex; align-items: center; justify-content: center; }

/* --- MAP --- */
.map-card { background: white; border-radius: 16px; padding: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); margin-bottom: 25px; position: relative; }
#map { height: 380px; width: 100%; border-radius: 12px; z-index: 1; }
.map-overlay { position: absolute; bottom: 25px; left: 25px; background: rgba(255, 255, 255, 0.95); padding: 8px 15px; border-radius: 30px; font-size: 0.75rem; font-weight: 600; color: var(--sidebar-bg); z-index: 2; box-shadow: 0 2px 10px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 8px; }

/* --- GRID LAYOUT --- */
.content-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 25px; }
.panel { background: white; border-radius: 16px; padding: 25px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); height: 500px; display: flex; flex-direction: column; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid #f1f5f9; padding-bottom: 15px; }
.panel-header h3 { font-size: 1rem; color: var(--sidebar-bg); font-weight: 600; display: flex; align-items: center; gap: 10px; }
.badge-count { background: var(--primary); color: white; padding: 2px 8px; border-radius: 6px; font-size: 0.75rem; }

/* --- GALERI GRID (YOLO) --- */
.feed-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; overflow-y: auto; padding: 4px; }
.gallery-card { position: relative; border-radius: 10px; overflow: hidden; height: 130px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: all 0.3s ease; cursor: pointer; background: #f8fafc; }
.gallery-card:hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(0,0,0,0.1); z-index: 5; }
.gallery-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0)); padding: 20px 8px 8px 8px; color: white; opacity: 0; transform: translateY(10px); transition: 0.3s; }
.gallery-card:hover .gallery-overlay { opacity: 1; transform: translateY(0); }
.gallery-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; margin-bottom: 2px; }
.gallery-meta { font-size: 0.65rem; opacity: 0.9; display: flex; align-items: center; gap: 4px; }

/* --- TABLE SENSOR --- */
.table-wrapper { overflow-y: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 10px; background: #f8fafc; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; position: sticky; top: 0; }
td { padding: 10px; border-bottom: 1px solid var(--border-color); font-size: 0.85rem; font-family: 'Courier New', monospace; }
.val-high { color: var(--danger); font-weight: bold; }
.live-tag { background: var(--danger); color: white; padding: 2px 6px; border-radius: 4px; font-size: 0.65rem; font-weight: 700; animation: blink 1s infinite; }

/* --- CUSTOM LEAFLET POPUP (THE BEST PART) --- */
.custom-leaflet-popup .leaflet-popup-content-wrapper { background: #fff; border-radius: 12px; padding: 0 !important; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.25); border: none; }
.custom-leaflet-popup .leaflet-popup-content { margin: 0 !important; width: 100% !important; }
.custom-leaflet-popup .leaflet-popup-tip { background: #ef4444; }
.custom-leaflet-popup a.leaflet-popup-close-button { color: white; font-size: 20px; top: 5px; right: 5px; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
.custom-leaflet-popup a.leaflet-popup-close-button:hover { color: #f1f5f9; }

.popup-card { font-family: 'Poppins', sans-serif; display: flex; flex-direction: column; }
.popup-header { background: linear-gradient(135deg, #ef4444, #b91c1c); color: white; padding: 12px 15px; font-size: 0.85rem; font-weight: 700; display: flex; align-items: center; gap: 8px; letter-spacing: 0.5px; }
.popup-image-wrapper { width: 100%; height: 160px; background: #e2e8f0; position: relative; }
.popup-image-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.popup-details { padding: 15px; background: #fff; }
.detail-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; color: #475569; font-size: 0.8rem; font-weight: 500; }
.detail-icon-box { width: 24px; height: 24px; background: #f1f5f9; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 0.75rem; }
.popup-btn { display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--primary); color: white !important; text-decoration: none; padding: 12px; font-size: 0.85rem; font-weight: 600; transition: all 0.2s; border-top: 1px solid #e2e8f0; }
.popup-btn:hover { background: #4f46e5; }

/* Animasi */
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); } 70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
@keyframes blink { 50% { opacity: 0.5; } }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* Responsive */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 15px; }
    .content-grid { grid-template-columns: 1fr; }
}