:root {
  --primary-dark: #0f172a;       
  --primary-brand: #1e3a8a;      
  --primary-light: #2563eb;      
  --accent-orange: #f97316;      
  --accent-emerald: #10b981;     
  --accent-teal: #0d9488;        
  --accent-amber: #f59e0b;       
  --bg-main: #f8fafc;            
  --surface: #ffffff;            
  --text-main: #0f172a;          
  --text-muted: #64748b;         
  --border-line: #e2e8f0;        
  --shadow-subtle: 0 4px 20px -2px rgba(15, 23, 42, 0.08);
}

* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden !important; 
  position: fixed;
}

body { 
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif; 
  background: var(--bg-main); 
  color: var(--text-main); 
  display: flex; 
  flex-direction: column; 
}

/* Header */
header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  padding: 0 24px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.2);
  z-index: 10;
}

.header-left { 
  display: flex; 
  align-items: center; 
  gap: 14px; 
  min-width: 0; 
}

.header-badge {
  display: flex; 
  align-items: center; 
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  padding: 6px 10px;
  flex-shrink: 0;
}

.header-badge-icon {
  width: 32px; 
  height: 32px;
  background: #ffffff;
  border-radius: 8px;
  display: flex; 
  align-items: center; 
  justify-content: center;
}

.header-badge-icon img {
  width: 26px !important; 
  height: 26px !important;
}

.header-badge-text { 
  font-size: 12px; 
  font-weight: 800; 
  letter-spacing: 0.05em; 
  text-transform: uppercase; 
  color: #ffffff;
}

.header-sep { 
  width: 1px; 
  height: 32px; 
  background: rgba(255, 255, 255, 0.2); 
  flex-shrink: 0; 
}

.header-title { min-width: 0; }

.header-title h1 {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-title p {
  font-size: 11.5px;
  opacity: 0.8;
  margin-top: 2px;
}

.header-right { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  flex-shrink: 0; 
}

.stat-chip {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex; 
  align-items: center; 
  gap: 6px;
  white-space: nowrap;
}

.stat-chip-num { 
  font-size: 14px; 
  font-weight: 800; 
  color: var(--accent-amber);
}

.layer-toggle {
  display: flex; 
  gap: 3px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 4px;
}

.layer-btn {
  padding: 6px 12px; 
  border-radius: 7px; 
  border: none;
  font-size: 12px; 
  font-weight: 600; 
  cursor: pointer;
  color: rgba(255, 255, 255, 0.75);
  background: transparent; 
  transition: all 0.2s;
}

.layer-btn.active {
  background: #ffffff;
  color: var(--primary-dark);
}

.btn-header {
  padding: 8px 15px; 
  border-radius: 10px; 
  border: none;
  font-size: 12.5px; 
  font-weight: 700; 
  cursor: pointer;
  display: flex; 
  align-items: center; 
  gap: 6px;
  white-space: nowrap; 
  text-decoration: none;
}

.btn-primary { 
  background: var(--accent-orange); 
  color: #ffffff; 
}

.btn-ghost { 
  background: rgba(255, 255, 255, 0.12); 
  color: #ffffff; 
  border: 1px solid rgba(255, 255, 255, 0.2); 
}

.btn-hamburger {
  display: none;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff; 
  border-radius: 10px;
  padding: 8px 12px; 
  font-size: 18px; 
  cursor: pointer;
}

/* Tata Letak Main */
.main { 
  display: flex; 
  flex: 1; 
  overflow: hidden; 
  position: relative; 
  height: calc(100% - 72px);
}

/* ── SIDEBAR ── */
.sidebar { 
  width: 320px; 
  height: 100%;
  background: var(--surface); 
  border-right: 1px solid var(--border-line); 
  display: flex; 
  flex-direction: column; 
  flex-shrink: 0; 
}

.sidebar.hidden { display: none; }

.sidebar-header {
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-line);
  background: var(--bg-main);
}

.sidebar-title { 
  font-size: 13px; 
  font-weight: 700; 
  color: var(--primary-dark); 
  display: flex; 
  align-items: center; 
  gap: 6px; 
}

.sidebar-badge {
  background: var(--primary-light);
  color: #ffffff; 
  font-size: 10.5px; 
  font-weight: 700;
  padding: 2px 8px; 
  border-radius: 12px;
}

.btn-close-sidebar {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
}

.sidebar-search { 
  padding: 10px 10px 6px; 
}

.search-box {
  display: flex; 
  align-items: center; 
  gap: 8px;
  background: var(--bg-main);
  border: 1.5px solid var(--border-line);
  border-radius: 8px;
  padding: 8px 12px;
}

.search-icon { font-size: 14px; flex-shrink: 0; }

.search-input { 
  flex: 1; 
  border: none; 
  background: transparent; 
  font-size: 13px; 
  color: var(--text-main); 
  outline: none; 
  font-family: inherit; 
}

/* ── STYLING FILTER CHIPS ── */
.filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 10px;
  border-bottom: 1px solid var(--border-line);
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  border: 1.5px solid var(--border-line);
  background: var(--bg-main);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: var(--primary-light);
  color: var(--primary-brand);
}

.filter-chip.active {
  background: var(--primary-brand);
  border-color: var(--primary-brand);
  color: #ffffff;
}

.filter-chip.active .chip-icon {
  background: #ffffff;
  border-radius: 50%;
  padding: 1px;
}

.sidebar-list { 
  flex: 1; 
  overflow-y: auto; 
  padding: 10px; 
  -webkit-overflow-scrolling: touch; 
}

.warga-card {
  padding: 10px 12px; 
  border-radius: 10px;
  border: 1.5px solid var(--border-line);
  margin-bottom: 8px; 
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--surface);
  display: flex; 
  align-items: center; 
  gap: 10px;
}

.warga-card:hover {
  border-color: var(--primary-light);
  background: #eff6ff;
}

.warga-card.selected {
  border-color: var(--primary-light);
  background: #dbeafe;
}

.warga-avatar {
  width: 38px; 
  height: 38px;
  background: linear-gradient(135deg, var(--primary-brand), var(--primary-light));
  border-radius: 8px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: 12px; 
  color: #ffffff; 
  font-weight: 700; 
  flex-shrink: 0;
}

.warga-avatar.sangkar { 
  background: linear-gradient(135deg, var(--accent-orange), var(--accent-amber)); 
}

.warga-avatar.masjid { 
  background: linear-gradient(135deg, var(--accent-emerald), #059669); 
  font-size: 16px;
}

.warga-avatar.lapangan { 
  background: linear-gradient(135deg, var(--accent-teal), #0f766e); 
  font-size: 16px;
}

.warga-info { flex: 1; min-width: 0; }

.warga-nama { 
  font-size: 13px; 
  font-weight: 700; 
  color: var(--primary-dark); 
  line-height: 1.3; 
}

.warga-meta { 
  font-size: 11px; 
  color: var(--text-muted); 
  margin-top: 2px; 
}

.warga-pill {
  display: inline-flex; 
  align-items: center; 
  gap: 3px;
  font-size: 10px; 
  padding: 2px 8px;
  border-radius: 6px; 
  margin-top: 4px; 
  font-weight: 600;
  background: #eff6ff; 
  color: var(--primary-light); 
  border: 1px solid #bfdbfe;
}

.warga-pill.sangkar { 
  background: #fff7ed; 
  color: var(--accent-orange); 
  border-color: #ffedd5; 
}

.warga-pill.masjid { 
  background: #ecfdf5; 
  color: var(--accent-emerald); 
  border-color: #a7f3d0; 
}

.warga-pill.lapangan { 
  background: #f0fdfa; 
  color: var(--accent-teal); 
  border-color: #99f6e4; 
}

/* ── MAP ── */
.map-wrap { 
  position: relative; 
  flex: 1; 
  height: 100%;
}

#map { 
  width: 100%; 
  height: 100%; 
  z-index: 0; 
}

.btn-toggle-sidebar {
  position: absolute; 
  top: 50%; 
  left: 10px; 
  transform: translateY(-50%);
  z-index: 1000;
  background: var(--primary-brand);
  color: #ffffff; 
  border: none; 
  border-radius: 8px;
  padding: 8px 10px; 
  cursor: pointer; 
  font-size: 13px;
  box-shadow: var(--shadow-subtle);
}

.sidebar-overlay { 
  display: none; 
  position: fixed; 
  inset: 0; 
  background: rgba(15, 23, 42, 0.4); 
  z-index: 1500; 
}

.sidebar-overlay.show { display: block; }


/* ── LEGENDA PETA MELAYANG ── */
.legend-float {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--border-line);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-dark);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-orange);
  border: 1.5px solid #ffffff;
  display: inline-block;
}

/* ── MATA ANGIN / KOMPAS ── */
.compass-container {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1000;
  pointer-events: auto;
}

.compass-dial {
  width: 76px; 
  height: 76px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.9);
  border: 2px solid #ffffff;
  position: relative;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
  transform: rotate(var(--compass-angle, 0deg));
  will-change: transform;
  transition: transform 0.1s ease-out;
}

.dir {
  position: absolute;
  font-weight: 800;
  font-size: 11px;
  color: #ffffff;
}

.dir.north { top: 4px; left: 50%; transform: translateX(-50%); color: var(--accent-orange); }
.dir.east  { right: 6px; top: 50%; transform: translateY(-50%); }
.dir.south { bottom: 4px; left: 50%; transform: translateX(-50%); }
.dir.west  { left: 6px; top: 50%; transform: translateY(-50%); }

.compass-needle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 40px;
  margin-top: -20px;
  margin-left: -3px;
  background: linear-gradient(to bottom, var(--accent-orange) 50%, #ffffff 50%);
  clip-path: polygon(50% 0%, 100% 50%, 65% 50%, 65% 100%, 35% 100%, 35% 50%, 0% 50%);
}

/* ── STYLING LOGO SANGKAR BURUNG KUSTOM ── */
.marker-icon-bird-wrap {
  width: 32px;
  height: 32px;
  background: #ffffff;
  border: 2px solid var(--accent-orange);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(249, 115, 22, 0.45);
  transform: translateY(-4px);
}

.marker-bird-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.inline-bird-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 2px;
}

.avatar-bird-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 50%;
  padding: 2px;
}

.chip-icon, .legend-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
}

.marker-icon-bird {
  font-size: 22px;
  line-height: 1;
  transform: translateY(-4px);
}

.marker-icon-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-orange);
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.4);
}

/* ── POPUP ── */
.leaflet-popup-content-wrapper {
  overflow: hidden !important;
  padding: 0 !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 20px -2px rgba(15, 23, 42, 0.22) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
}

.popup-wrap { 
  min-width: 240px !important; 
  max-width: 300px !important; 
  padding: 12px 14px 14px;
}

.popup-header {
  background: var(--primary-brand);
  color: #ffffff; 
  margin: -12px -14px 12px -14px !important;
  padding: 12px 34px 12px 14px !important;
  position: relative;
  display: flex; 
  align-items: center; 
  gap: 10px;
}

.popup-header.sangkar { background: var(--accent-orange); }
.popup-header.masjid { background: var(--accent-emerald); }
.popup-header.lapangan { background: var(--accent-teal); }

.popup-avatar-wrap {
  width: 30px; 
  height: 30px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: 13px; 
  font-weight: 800; 
  color: #ffffff;
}

.popup-nama { 
  font-size: 13.5px; 
  font-weight: 800; 
  color: #ffffff; 
}

.popup-row {
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  padding: 6px 0; 
  border-bottom: 1px solid var(--border-line);
  font-size: 11.5px; 
  gap: 10px;
}

.popup-row:last-of-type { border-bottom: none; }

.popup-label { color: var(--text-muted); font-weight: 500; }

.popup-val { 
  font-weight: 700; 
  color: var(--primary-dark); 
  text-align: right; 
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* ── TOMBOL POPUP GMAPS ── */
.popup-gmaps {
  display: block; 
  margin-top: 10px; 
  padding: 8px 12px;
  background: var(--primary-brand);
  color: #ffffff !important;
  border-radius: 6px; 
  font-size: 11.5px;
  text-decoration: none; 
  font-weight: 700; 
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: all 0.2s ease;
}

.popup-gmaps:hover {
  opacity: 0.9;
  color: #ffffff !important;
}

.popup-gmaps.sangkar { background: var(--accent-orange); box-shadow: 0 2px 6px rgba(249, 115, 22, 0.25); }
.popup-gmaps.masjid { background: var(--accent-emerald); box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25); }
.popup-gmaps.lapangan { background: var(--accent-teal); box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25); }

/* ── TOMBOL SILANG POPUP ── */
.leaflet-popup-close-button {
  top: 10px !important;
  right: 10px !important;
  color: #ffffff !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  opacity: 0.85;
  z-index: 20;
  width: 22px !important;
  height: 22px !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.leaflet-popup-close-button:hover {
  opacity: 1;
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.2);
}

/* ── TOAST ── */
.toast {
  position: fixed; 
  bottom: 20px; 
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary-dark);
  color: #ffffff; 
  padding: 9px 18px; 
  border-radius: 20px;
  font-size: 12.5px; 
  font-weight: 600;
  z-index: 3000; 
  transition: transform 0.25s ease;
  pointer-events: none; 
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.toast.show { transform: translateX(-50%) translateY(0); }

.empty-state { text-align: center; padding: 30px 16px; color: var(--text-muted); font-size: 13px; }

/* ── MOBILE LAYER BAR ── */
.mobile-layer-bar {
  display: none; 
  position: absolute; 
  top: 10px; 
  left: 50%; 
  transform: translateX(-50%);
  z-index: 1000; 
  background: rgba(15, 23, 42, 0.9);
  border-radius: 20px; 
  padding: 3px 5px; 
  gap: 3px;
}

.mobile-layer-bar .layer-btn { color: rgba(255, 255, 255, 0.7); font-size: 11px; padding: 4px 10px; }

.mobile-layer-bar .layer-btn.active { background: #ffffff; color: var(--primary-dark); }

.judul-short { display: none; }

/* ── MEDIA QUERIES TAMPILAN HP ── */
@media (max-width: 640px) {
  header { 
    height: 62px; 
    padding: 0 12px; 
  }

  .main {
    height: calc(100dvh - 62px);
  }
  
  .header-badge { padding: 4px 8px; }
  .header-badge-icon { width: 26px; height: 26px; }
  .header-badge-icon img { width: 20px !important; height: 20px !important; }
  .header-badge-text { font-size: 11px; }

  .header-title h1 { font-size: 14.5px; }
  .header-title p { display: none; }
  .header-sep { display: none; }
  
  .header-right .layer-toggle, 
  .header-right .stat-chip, 
  .btn-header span { display: none; }
  
  .btn-hamburger { display: flex; align-items: center; justify-content: center; }
  
  .judul-full { display: none; }
  .judul-short { display: inline; }
  
  .sidebar {
    position: fixed; 
    top: 0; 
    left: 0; 
    bottom: 0;
    height: 100dvh;
    width: 82vw; 
    max-width: 290px; 
    z-index: 2000;
    transform: translateX(-100%); 
    transition: transform 0.25s ease;
    display: flex !important;
  }
  
  .sidebar.mobile-open { transform: translateX(0); }
  .btn-toggle-sidebar { display: none; }
  .mobile-layer-bar { display: flex !important; }
  
  .compass-container { top: 52px; right: 10px; }
  .compass-dial { width: 56px; height: 56px; }
  .dir { font-size: 9px; }
  .compass-needle { height: 30px; margin-top: -15px; width: 5px; margin-left: -2.5px; }

  .legend-float {
    bottom: 10px;
    left: 10px;
    padding: 6px 10px;
    font-size: 10px;
    gap: 8px;
  }

  .warga-card { padding: 8px 10px; }
  .warga-avatar { width: 34px; height: 34px; font-size: 11px; }
  .warga-nama { font-size: 12.5px; }
  .warga-meta { font-size: 10.5px; }
  
  .popup-wrap {
    min-width: 210px !important;
    max-width: 78vw !important;
    padding: 10px 12px 12px;
  }

  .popup-header {
    margin: -10px -12px 10px -12px !important;
    padding: 10px 30px 10px 12px !important;
  }
}

@media (min-width: 641px) {
  .btn-hamburger { display: none; }
  .mobile-layer-bar { display: none !important; }
  .sidebar-overlay { display: none !important; }
}