/* ============================================
   PETA DESA MENTARAMAN - Interactive Map Styles
   Theme: Dark Cartography + Brown-Green Glassmorphism
   ============================================ */

/* ---- MAP LAYOUT ---- */
.map-page-wrapper {
  display: flex;
  min-height: calc(100vh - var(--nav-height));
  position: relative;
}

.map-container-wrap {
  flex: 1;
  position: relative;
  min-height: 75vh;
}

#petaDesaMap {
  width: 100%;
  height: 100%;
  min-height: 75vh;
  z-index: 1;
  border-radius: 0;
}

/* Dark filter on CartoDB tiles to match theme */
.dark-tiles {
  filter: brightness(0.85) contrast(1.1) saturate(0.8) sepia(0.15) hue-rotate(-10deg);
}

/* ---- SIDEBAR ---- */
.map-sidebar {
  width: 380px;
  background: rgba(20, 30, 22, 0.92);
  backdrop-filter: blur(30px) saturate(1.6);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
  z-index: 10;
  padding: 0;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
}

.map-sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(30, 45, 36, 0.5) 0%, transparent 100%);
}

.sidebar-header h3 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: var(--gold-light);
  margin-bottom: 6px;
}

.sidebar-header p {
  font-size: 0.85rem;
  color: rgba(244, 239, 230, 0.6);
  line-height: 1.5;
}

/* ---- SIDEBAR SECTIONS ---- */
.sidebar-section {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-section-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--gold-accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-section-title::before {
  content: '';
  width: 16px;
  height: 2px;
  background: var(--gold-accent);
  border-radius: 1px;
}

/* ---- INFO GRID (Batas Wilayah) ---- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
  transition: all 0.3s ease;
}

.info-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(184, 150, 62, 0.3);
}

.info-item .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(244, 239, 230, 0.45);
  margin-bottom: 4px;
}

.info-item .value {
  font-size: 0.88rem;
  color: var(--text-light);
  font-weight: 500;
}

/* ---- DUSUN CARDS ---- */
.dusun-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dusun-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(.4,0,.2,1);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.dusun-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0 2px 2px 0;
  transition: all 0.3s ease;
}

.dusun-card[data-color="green"]::before { background: #5E9B73; }
.dusun-card[data-color="gold"]::before { background: #D4BC7A; }
.dusun-card[data-color="brown"]::before { background: #B8963E; }

.dusun-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(184, 150, 62, 0.4);
  transform: translateX(4px);
}

.dusun-card:hover::before {
  width: 5px;
}

.dusun-card.active {
  background: rgba(184, 150, 62, 0.12);
  border-color: rgba(184, 150, 62, 0.5);
}

.dusun-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dusun-icon svg {
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}

.dusun-card[data-color="green"] .dusun-icon {
  background: rgba(94, 155, 115, 0.2);
  color: #5E9B73;
}
.dusun-card[data-color="gold"] .dusun-icon {
  background: rgba(212, 188, 122, 0.2);
  color: #D4BC7A;
}
.dusun-card[data-color="brown"] .dusun-icon {
  background: rgba(184, 150, 62, 0.2);
  color: #B8963E;
}

.dusun-info h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 3px;
}

.dusun-info span {
  font-size: 0.78rem;
  color: rgba(244, 239, 230, 0.5);
}

.dusun-arrow {
  margin-left: auto;
  color: rgba(244, 239, 230, 0.3);
  transition: all 0.3s ease;
}

.dusun-card:hover .dusun-arrow {
  color: var(--gold-light);
  transform: translateX(3px);
}

/* ---- FILTER BUTTONS ---- */
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(244, 239, 230, 0.7);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-body);
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(184, 150, 62, 0.4);
  color: var(--text-light);
}

.filter-btn.active {
  background: rgba(184, 150, 62, 0.2);
  border-color: var(--gold-accent);
  color: var(--gold-light);
}

.filter-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-btn[data-cat="pemerintahan"] .dot { background: #4ECDC4; }
.filter-btn[data-cat="pendidikan"] .dot { background: #45B7D1; }
.filter-btn[data-cat="sejarah"] .dot { background: #F7DC6F; }
.filter-btn[data-cat="wisata"] .dot { background: #FF6B6B; }
.filter-btn[data-cat="semua"] .dot { 
  background: linear-gradient(135deg, #4ECDC4, #FF6B6B); 
}

/* ---- STATS BAR ---- */
.sidebar-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-mini {
  text-align: center;
  padding: 16px 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-mini:last-child {
  border-right: none;
}

.stat-mini .stat-num {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-mini .stat-lbl {
  font-size: 0.68rem;
  color: rgba(244, 239, 230, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ---- LEAFLET OVERRIDES (Dark Theme) ---- */
.leaflet-popup-content-wrapper {
  background: rgba(20, 30, 22, 0.95) !important;
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(184, 150, 62, 0.3) !important;
  border-radius: 14px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5) !important;
  color: var(--text-light) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-family: var(--font-body) !important;
  min-width: 220px;
}

.leaflet-popup-tip {
  background: rgba(20, 30, 22, 0.95) !important;
  border: 1px solid rgba(184, 150, 62, 0.3) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.leaflet-popup-close-button {
  color: rgba(244, 239, 230, 0.5) !important;
  font-size: 20px !important;
  right: 10px !important;
  top: 10px !important;
  z-index: 10;
}

.leaflet-popup-close-button:hover {
  color: var(--gold-light) !important;
}

/* Custom popup content styling */
.popup-content {
  padding: 0;
}

.popup-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.popup-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.popup-icon-wrap svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}

.popup-icon-wrap.cat-pemerintahan { background: rgba(78, 205, 196, 0.2); color: #4ECDC4; }
.popup-icon-wrap.cat-pendidikan { background: rgba(69, 183, 209, 0.2); color: #45B7D1; }
.popup-icon-wrap.cat-sejarah { background: rgba(247, 220, 111, 0.2); color: #F7DC6F; }
.popup-icon-wrap.cat-wisata { background: rgba(255, 107, 107, 0.2); color: #FF6B6B; }

.popup-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--gold-light);
  font-weight: 600;
  line-height: 1.3;
}

.popup-cat-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(244, 239, 230, 0.5);
  margin-top: 2px;
}

.popup-body {
  padding: 14px 18px 16px;
}

.popup-body p {
  font-size: 0.85rem;
  color: rgba(244, 239, 230, 0.8);
  line-height: 1.6;
  margin: 0;
}

.popup-body .popup-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: rgba(244, 239, 230, 0.45);
}

.popup-body .popup-meta svg {
  width: 14px;
  height: 14px;
  stroke: rgba(244, 239, 230, 0.4);
}

/* ---- CUSTOM MARKERS ---- */
.custom-marker-container {
  background: none;
  border: none;
}

.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  cursor: pointer;
}

.custom-marker::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: inherit;
  border: 1.5px solid currentColor;
  opacity: 0;
  animation: marker-pulse 2.5s ease-in-out infinite;
}

@keyframes marker-pulse {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(1.18); }
}

.custom-marker:hover {
  transform: rotate(-45deg) scale(1.15);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* The SVG icon inside marker — counter-rotate so SVG stays upright */
.custom-marker .marker-svg {
  transform: rotate(45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.custom-marker .marker-svg svg {
  stroke: currentColor;
  fill: none;
  width: 17px;
  height: 17px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

/* Category colour themes */
.marker-pemerintahan {
  background: linear-gradient(135deg, #4ECDC4 0%, #2C9E96 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(78, 205, 196, 0.35);
}
.marker-pendidikan {
  background: linear-gradient(135deg, #45B7D1 0%, #2E8FA8 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(69, 183, 209, 0.35);
}
.marker-sejarah {
  background: linear-gradient(135deg, #F7DC6F 0%, #D4A825 100%);
  color: #4A3A00;
  box-shadow: 0 6px 20px rgba(247, 220, 111, 0.35);
}
.marker-wisata {
  background: linear-gradient(135deg, #FF6B6B 0%, #D44E4E 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.35);
}

/* ---- DUSUN POLYGON TOOLTIP ---- */
.dusun-tooltip {
  background: rgba(20, 30, 22, 0.9) !important;
  border: 1px solid rgba(184, 150, 62, 0.4) !important;
  border-radius: 8px !important;
  color: var(--gold-light) !important;
  font-family: var(--font-heading) !important;
  font-size: 0.85rem !important;
  padding: 6px 14px !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  letter-spacing: 0.5px;
}

.dusun-tooltip::before {
  border-top-color: rgba(184, 150, 62, 0.4) !important;
}

/* ---- LEAFLET CONTROLS ---- */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: rgba(20, 30, 22, 0.92) !important;
  color: var(--text-light) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 16px !important;
  transition: all 0.2s ease;
}

.leaflet-control-zoom a:hover {
  background: rgba(40, 55, 46, 0.95) !important;
  color: var(--gold-light) !important;
}

.leaflet-control-attribution {
  background: rgba(20, 30, 22, 0.7) !important;
  color: rgba(244, 239, 230, 0.35) !important;
  font-size: 0.65rem !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 6px 0 0 0 !important;
  padding: 3px 8px !important;
}

.leaflet-control-attribution a {
  color: rgba(184, 150, 62, 0.6) !important;
}

/* ---- MAP LEGEND ---- */
.map-legend {
  position: absolute;
  bottom: 32px;
  left: 16px;
  z-index: 800;
  background: rgba(20, 30, 22, 0.92);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  min-width: 180px;
}

.map-legend h4 {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--gold-accent);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 0.82rem;
  color: rgba(244, 239, 230, 0.75);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.legend-dot.pemerintahan { background: #4ECDC4; color: #4ECDC4; }
.legend-dot.pendidikan { background: #45B7D1; color: #45B7D1; }
.legend-dot.sejarah { background: #F7DC6F; color: #F7DC6F; }
.legend-dot.wisata { background: #FF6B6B; color: #FF6B6B; }

/* ---- SIDEBAR TOGGLE (Mobile) ---- */
.sidebar-toggle {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 900;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(20, 30, 22, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.sidebar-toggle:hover {
  background: rgba(40, 55, 46, 0.95);
  border-color: rgba(184, 150, 62, 0.4);
  color: var(--gold-light);
}

/* ---- FULLSCREEN BTN ---- */
.fullscreen-btn {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 800;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(20, 30, 22, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.fullscreen-btn:hover {
  background: rgba(40, 55, 46, 0.95);
  border-color: rgba(184, 150, 62, 0.4);
  color: var(--gold-light);
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .map-page-wrapper {
    flex-direction: column;
  }

  .map-sidebar {
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    order: 2;
  }

  .map-container-wrap {
    order: 1;
    min-height: 55vh;
  }

  #petaDesaMap {
    min-height: 55vh;
  }

  .sidebar-toggle {
    display: none;
  }

  .map-legend {
    bottom: 16px;
    left: 12px;
    padding: 12px 16px;
    min-width: 160px;
  }
}

@media (max-width: 640px) {
  .map-container-wrap {
    min-height: 45vh;
  }

  #petaDesaMap {
    min-height: 45vh;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-group {
    gap: 6px;
  }

  .filter-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .map-legend {
    bottom: 12px;
    left: 8px;
    padding: 10px 14px;
    min-width: 140px;
    border-radius: 10px;
  }

  .map-legend h4 {
    font-size: 0.7rem;
  }

  .legend-item {
    font-size: 0.75rem;
    gap: 8px;
    padding: 3px 0;
  }
}
