:root {
  --primary-blue: #2c5ead;
  --secondary-blue: #1591dc;
  --accent-blue: #4bb8fa;
  --light-blue: #c4e2f5;
  --dark-bg: rgba(10, 18, 30, 0.82);
  --border-glass: rgba(255, 255, 255, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  overflow: hidden; /* Mencegah scroll pada halaman peta */
  background-color: #000;
  color: #fff;
}

/* KANVAS PETA FULL LAYAR */
#map {
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* HEADER MENGAMBANG */
.map-header {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  height: 64px;
  background: var(--dark-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-back {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-glass);
  transition: all 0.25s ease;
}

.btn-back:hover {
  background: var(--secondary-blue);
  border-color: var(--accent-blue);
}

.title-group h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.title-group span {
  font-size: 0.75rem;
  color: var(--light-blue);
}

.coord-box {
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: monospace;
  color: var(--accent-blue);
  border: 1px solid rgba(75, 184, 250, 0.3);
}

/* SIDEBAR KIRI */
.map-sidebar {
  position: absolute;
  top: 96px;
  left: 16px;
  width: 340px;
  max-height: calc(100vh - 116px);
  background: var(--dark-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-header h2 {
  display: flex; /* Membuat ikon dan teks sejajar dalam satu baris */
  align-items: center; /* Menyejajarkan posisi vertikal tepat di tengah */
  gap: 10px; /* Memberikan jarak spasi antara ikon SVG dan teks */
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--light-blue);
  margin: 0;
}

/* Opsional: Memastikan ukuran ikon proporsional dengan ukuran huruf */
.sidebar-header h2 svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.sidebar-content {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-content::-webkit-scrollbar {
  width: 5px;
}
.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.control-group h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-blue);
  margin-bottom: 10px;
}

/* KOTAK KHUSUS ORTOFOTO */
.highlight-box {
  background: linear-gradient(
    135deg,
    rgba(21, 145, 220, 0.2),
    rgba(44, 94, 173, 0.1)
  );
  border: 1px solid rgba(75, 184, 250, 0.35);
  padding: 12px;
  border-radius: 12px;
}

.layer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.layer-row h3 {
  margin-bottom: 0;
}

.helper-text {
  font-size: 0.72rem;
  color: #ccc;
  margin: 6px 0 10px;
  line-height: 1.4;
}

.slider-container label {
  font-size: 0.75rem;
  display: block;
  margin-bottom: 6px;
  color: #eee;
}

.slider-container input[type="range"] {
  width: 100%;
  accent-color: var(--secondary-blue);
  cursor: pointer;
}

/* RADIO & CHECKBOX ITEMS */
.radio-item,
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  padding: 6px 0;
  cursor: pointer;
  color: #e2e8f0;
}

.radio-item input,
.check-item input {
  accent-color: var(--secondary-blue);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* SIMBOL LEGENDA */
.legend-line {
  width: 18px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid #fff;
}

.legend-poly {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

/* KARTU STATISTIK */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-blue);
}

.stat-label {
  font-size: 0.72rem;
  color: #aaa;
}

/* PINDAHKAN TOMBOL ZOOM LEAFLET KE KANAN BAWAH */
.leaflet-top.leaflet-left {
  top: auto;
  bottom: 24px;
  left: auto;
  right: 16px;
}

/* --- PANEL KACA PUTIH TRANSPARAN (KANAN ATAS) --- */
.info-glass-card {
  position: absolute;
  top: 96px; /* Sejajar dengan bagian atas sidebar kiri */
  right: 16px;
  width: 330px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  /* Efek Kaca Putih Transparan (Frosted White Glassmorphism) */
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 18px;
  padding: 20px;
  z-index: 1000;
  color: #0f172a; /* Teks gelap agar kontras & tajam di atas kaca putih */
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);

  /* Animasi Sembunyi / Muncul */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.97);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.info-glass-card.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.close-glass-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.1);
  color: #0f172a;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.close-glass-btn:hover {
  background: #ff4757;
  color: #fff;
}

.glass-badge {
  display: inline-block;
  background: rgba(21, 145, 220, 0.15);
  color: #2b87d7;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.info-glass-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  text-transform: capitalize;
  margin-bottom: 14px;
  padding-right: 24px;
}

.glass-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(15, 23, 42, 0.12);
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
  padding: 12px 0;
  margin-bottom: 14px;
}

.meta-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
}

.meta-val {
  font-size: 0.84rem;
  font-weight: 600;
  color: #0f172a;
}

/* Foto Dokumentasi di Bawah Teks */
.glass-photo-box {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.glass-photo-box img {
  width: 100%;
  height: 165px;
  object-fit: cover;
  display: block;
}

.photo-caption {
  display: block;
  text-align: center;
  font-size: 0.72rem;
  color: #334155;
  padding: 6px;
  font-weight: 500;
}

/* --- EFEK SIDEBAR MENGECIL JADI IKON (COLLAPSED) --- */
.map-sidebar.collapsed {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  cursor: pointer;
  background: var(--dark-bg);
}

.map-sidebar.collapsed:hover {
  border-color: var(--accent-blue);
  background: rgba(21, 145, 220, 0.25);
}

/* Tengah-kan ikon SVG saat sidebar mengecil */
.map-sidebar.collapsed .sidebar-header {
  padding: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  border-bottom: none;
}

/* Trik CSS: Sembunyikan teks "Layer Data" dengan font-size 0, tapi biarkan SVG tampil */
.map-sidebar.collapsed .sidebar-header h2 {
  font-size: 0;
  gap: 0;
}

.map-sidebar.collapsed .sidebar-header h2 svg {
  width: 22px;
  height: 22px;
}

/* Sembunyikan tombol hamburger & seluruh isi daftar layer saat mengecil */
.map-sidebar.collapsed .toggle-btn,
.map-sidebar.collapsed .sidebar-content {
  display: none;
}

/* --- RESPONSIVE UNTUK LAYAR SEMPIT & HP --- */
@media (max-width: 768px) {
  .map-header {
    top: 10px;
    left: 10px;
    right: 10px;
    height: 56px;
    padding: 0 12px;
  }

  .title-group h1 {
    font-size: 0.9rem;
  }

  .title-group span,
  .coord-box {
    display: none; /* Sembunyikan sub-judul & koordinat agar header tidak sesak */
  }

  /* Sidebar tetap di kiri atas, tidak dipindah ke bawah agar tidak menabrak kartu */
  .map-sidebar {
    top: 76px;
    left: 10px;
    width: calc(100vw - 20px);
    max-width: 300px;
    max-height: 55vh;
  }

  /* Kartu Kaca Putih berubah menjadi Bottom Sheet yang rapi di bagian bawah layar */
  .info-glass-card {
    top: auto;
    bottom: 12px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 48vh;
    padding: 16px;
    transform: translateY(20px);
  }

  /* Susun data koordinat & waktu menjadi 2 kolom agar hemat ruang vertikal di HP */
  .glass-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
  }

  .glass-photo-box img {
    height: 120px;
  }
}

/* =========================================================================
   GAYA LEGENDA HORIZONTAL BAWAH (GLASSMORPHISM)
   ========================================================================= */

.bottom-legend-container {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.legend-horizontal-card {
  background: rgba(18, 25, 38, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 12px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  color: #fff;
  pointer-events: auto;

  /* Logika Muncul/Sembunyi */
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.legend-horizontal-card.active {
  display: block;
  opacity: 1;
}

.legend-horiz-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.legend-horiz-body {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.legend-horiz-body.grid-layout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 14px;
}

.legend-horiz-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #e2e8f0;
}

.swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
  .bottom-legend-container {
    bottom: 16px;
  }
  .legend-horiz-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .legend-horiz-body.grid-layout {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =========================================================
   OVERRIDE LEAFLET POPUP - GLASSMORPHISM DARK MODE
   ========================================================= */

/* Mengubah kotak putih menjadi kaca transparan gelap */
.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.75) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 12px !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
  padding: 0 !important;
}

/* Mengubah warna segitiga penunjuk di bawah popup */
.leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  backdrop-filter: blur(12px) !important;
  box-shadow: none !important;
}

/* Mengatur tombol (X) Close */
.leaflet-popup-close-button {
  color: #94a3b8 !important;
  padding-top: 8px !important;
  padding-right: 8px !important;
  transition: color 0.2s ease;
}
.leaflet-popup-close-button:hover {
  color: #4bb8fa !important;
}

/* =========================================================
   MENGATUR TULISAN DI DALAM POPUP
   ========================================================= */
.leaflet-popup-content {
  margin: 16px 20px 16px 16px !important;
  font-family: "Inter", sans-serif !important;
}

/* Judul (Bold Biru Cerah) */
.glass-popup-content .popup-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #4bb8fa;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Deskripsi Singkat */
.glass-popup-content .popup-desc {
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.6;
  margin: 0;
  text-align: justify;
}

/* =========================================================
   PANEL TRANSPARANSI LAYER (KANAN BAWAH)
   ========================================================= */
.opacity-glass-panel {
  position: absolute;
  bottom: 24px;
  right: 60px; /* Diberi jarak 60px dari kanan agar tidak menutupi tombol Zoom (+/-) */
  width: 250px;

  /* Tema Dark Glassmorphism */
  background: rgba(10, 18, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 14px 16px;
  z-index: 900; /* Tetap di bawah popup putih (1000) agar tidak tertindih aneh */
  color: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease,
    transform 0.3s ease;
}

.opacity-glass-panel.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px); /* Efek turun sedikit saat menghilang */
}

.opacity-glass-panel .panel-title {
  font-size: 0.75rem;
  color: #4bb8fa; /* Biru cerah */
  margin-bottom: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.slider-group {
  margin-bottom: 8px;
}
.slider-group:last-child {
  margin-bottom: 0;
}

.slider-group label {
  display: block;
  font-size: 0.7rem;
  color: #cbd5e1;
  margin-bottom: 4px;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: #1591dc;
  cursor: pointer;
  height: 4px; /* Membuat slider terlihat lebih tipis dan elegan */
}

/* Responsif untuk Layar HP */
@media (max-width: 768px) {
  .opacity-glass-panel {
    display: none; /* Sembunyikan di HP agar layar tidak penuh sesak */
  }
}
