/* ==================================================================
   HALAMAN PETA TATA RUANG — modern & responsive
   Dipakai bersama <body class="page-map"> oleh style.css
   ================================================================== */

/* ---------- Wrapper peta full 1 layar ---------- */
.map-wrapper {
	flex: 1;
	min-height: 0;
	position: relative;
	background: #dce8f0;
}

#map {
	position: absolute;
	inset: 0;
	z-index: 1;
	background: #dce8f0;
}

/* ---------- Kartu kaca generik ---------- */
.map-title-panel,
.legend,
.coord-bar,
.btn-reset {
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	background: rgba(255, 255, 255, 0.85);
	border: 1px solid rgba(255, 255, 255, 0.65);
	box-shadow: 0 8px 24px rgba(15, 63, 120, 0.18);
}

/* ---------- Panel judul (kiri atas) ---------- */
.map-title-panel {
	position: absolute;
	top: 16px;
	left: 16px;
	z-index: 1000;
	border-radius: 14px;
	padding: 14px 18px;
	max-width: 300px;
	border-left: 4px solid #1a6fc0;
	animation: floatIn 0.5s ease;
}

.map-title-panel h2 {
	font-size: 14px;
	font-weight: 700;
	color: #14568f;
	display: flex;
	align-items: center;
	gap: 8px;
}

.map-title-panel p {
	font-size: 11px;
	color: #64748b;
	margin-top: 5px;
	line-height: 1.55;
}

/* ---------- Legenda (kiri bawah, di atas bar koordinat) ---------- */
.legend {
	position: absolute;
	bottom: 60px;
	left: 16px;
	right: auto;
	z-index: 1000;
	border-radius: 14px;
	padding: 14px 18px;
	max-width: 220px;
	/* Tinggi dibatasi relatif terhadap area peta (bukan viewport) dan
	   menyisakan ruang untuk kontrol kiri-atas (zoom + kolom pencarian),
	   sehingga legenda tidak menabrak pencarian/header. */
	max-height: calc(100% - 180px);
	overflow-y: auto;
	transition: transform 0.25s;
}

.legend::-webkit-scrollbar {
	width: 6px;
}
.legend::-webkit-scrollbar-thumb {
	background: rgba(26, 111, 192, 0.4);
	border-radius: 999px;
}
.legend::-webkit-scrollbar-track {
	background: transparent;
}

.legend h3 {
	font-size: 12px;
	font-weight: 700;
	color: #14568f;
	margin-bottom: 10px;
	padding-bottom: 8px;
	border-bottom: 1px solid #e2ebf3;
}

.legend ul {
	list-style: none;
}

.legend li {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 11px;
	color: #475569;
	margin-bottom: 8px;
	line-height: 1.3;
}

.legend li:last-child {
	margin-bottom: 0;
}

.legend .swatch {
	width: 16px;
	height: 16px;
	border-radius: 5px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	flex-shrink: 0;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* ---------- Bar koordinat (kiri bawah) ---------- */
.coord-bar {
	position: absolute;
	bottom: 12px;
	left: 16px;
	z-index: 1000;
	border-radius: 10px;
	padding: 8px 14px;
	font-size: 11px;
	font-weight: 600;
	color: #14568f;
	font-family: "Consolas", "Courier New", monospace;
	min-width: 200px;
	text-align: center;
	letter-spacing: 0.3px;
}

/* ---------- Tombol reset ---------- */
.btn-reset {
	position: absolute;
	top: 10px;
	left: auto;
	right: 270px;
	width: auto;
	white-space: nowrap;
	z-index: 1001;
	border: 1px solid rgba(255, 255, 255, 0.65);
	border-radius: 10px;
	padding: 10px 16px;
	font-size: 11.5px;
	font-weight: 700;
	color: #14568f;
	cursor: pointer;
	transition: all 0.25s;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.btn-reset:hover {
	background: #1a6fc0;
	color: #fff;
	border-color: #1a6fc0;
	transform: translateY(-1px);
}

/* ---------- Indikator loading layer peta ---------- */
.map-loader {
	position: absolute;
	top: 14px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 1002;
	display: none;
	align-items: center;
	gap: 8px;
	padding: 9px 16px;
	border-radius: 999px;
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	background: rgba(255, 255, 255, 0.92);
	border: 1px solid rgba(255, 255, 255, 0.65);
	box-shadow: 0 8px 24px rgba(15, 63, 120, 0.18);
	font-size: 11.5px;
	font-weight: 600;
	color: #14568f;
	white-space: nowrap;
	pointer-events: none;
}

.map-loader i {
	color: #1a6fc0;
	font-size: 13px;
}

/* ---------- Tooltip nama kecamatan ---------- */
.leaflet-tooltip {
	background: transparent;
	border: 0;
	box-shadow: none;
	color: #1f2937;
	font-weight: 700;
	font-size: 11px;
	text-shadow:
		0 1px 2px rgba(255, 255, 255, 0.9),
		0 0 4px rgba(255, 255, 255, 0.9);
}

.custom-tooltip-hidden {
	display: none !important;
}

/* ---------- Kontrol Leaflet agar serasi ---------- */
.leaflet-control-layers {
	border-radius: 12px !important;
	box-shadow: 0 8px 24px rgba(15, 63, 120, 0.18) !important;
	border: 1px solid rgba(255, 255, 255, 0.65) !important;
	overflow: hidden;
}

.leaflet-control-layers-toggle {
	border-radius: 10px;
}

.leaflet-bar a {
	border-radius: 8px !important;
}

.leaflet-popup-content-wrapper {
	border-radius: 12px;
	box-shadow: 0 8px 28px rgba(15, 63, 120, 0.22);
}

.leaflet-popup-content {
	font-family: "Segoe UI", Tahoma, sans-serif;
	margin: 12px 14px;
	font-size: 12px;
	color: #334155;
}

.leaflet-popup-content b {
	color: #14568f;
}

.popup-title {
	font-size: 12.5px;
	font-weight: 700;
	color: #14568f;
	margin-bottom: 4px;
}

.popup-desc {
	font-size: 11.5px;
	color: #64748b;
	line-height: 1.5;
}

/* ================================================================
   PANEL LAYER (Leaflet Panel Layers) — modern
================================================================ */
.leaflet-panel-layers {
	width: auto;
	min-width: 46px;
	max-width: 320px;
	padding: 6px !important;
	background: rgba(255, 255, 255, 0.9) !important;
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border-radius: 2px !important;
	border: 1px solid rgba(255, 255, 255, 0.7) !important;
	box-shadow: 0 10px 30px rgba(15, 63, 120, 0.22) !important;
	overflow: hidden;
	font-family: "Segoe UI", Tahoma, sans-serif;
	transition: box-shadow 0.25s;
}

.leaflet-panel-layers:hover {
	box-shadow: 0 12px 36px rgba(15, 63, 120, 0.28) !important;
}

.leaflet-panel-layers.expanded {
	overflow-x: hidden;
	overflow-y: auto;
	max-height: calc(100vh - 140px);
}

/* Icon header panel */
.leaflet-panel-layers .leaflet-panel-layers-icon {
	background: transparent !important;
	color: #14568f;
}

/* Grup */
.leaflet-panel-layers-group {
	padding: 0 !important;
	margin: 6px 4px !important;
	border: 0 !important;
	background: transparent !important;
	border-radius: 10px !important;
}

/* Label grup (header grup) */
.leaflet-panel-layers-grouplabel {
	padding: 9px 12px !important;
	height: auto !important;
	font-size: 12px !important;
	font-weight: 700 !important;
	color: #14568f !important;
	background: linear-gradient(180deg, #f2f7fc 0%, #e7f0f9 100%) !important;
	border-radius: 10px !important;
	border: 1px solid #dbe8f3 !important;
	line-height: 1.3 !important;
	transition:
		background 0.2s,
		color 0.2s;
}

.leaflet-panel-layers-grouplabel:hover {
	background: linear-gradient(180deg, #e7f0f9 0%, #d8e8f6 100%) !important;
}

.leaflet-panel-layers-group.collapsible:not(.expanded) {
	height: auto !important;
}

.leaflet-panel-layers-group.collapsible:not(.expanded)
	.leaflet-panel-layers-grouplabel {
	height: auto !important;
	overflow: visible !important;
}

/* Item layer */
.leaflet-panel-layers-item {
	min-height: 26px !important;
	margin: 4px 0 0 0 !important;
	padding: 6px 10px !important;
	white-space: normal !important;
	background: #fff !important;
	border: 1px solid #e2ebf3 !important;
	border-radius: 9px !important;
	transition:
		border-color 0.2s,
		box-shadow 0.2s,
		transform 0.15s;
}

.leaflet-panel-layers-overlays .leaflet-panel-layers-item {
	background: #fff !important;
	border: 1px solid #e2ebf3 !important;
}

.leaflet-panel-layers-item:hover {
	border-color: #1a6fc0 !important;
	box-shadow: 0 4px 12px rgba(26, 111, 192, 0.15);
	transform: translateY(-1px);
	cursor: pointer;
}

.leaflet-panel-layers-title {
	white-space: normal !important;
	font-size: 11.5px !important;
	color: #334155 !important;
	font-weight: 600 !important;
	line-height: 1.35 !important;
}

/* Checkbox/radio lebih rapi */
.leaflet-panel-layers-selector {
	position: relative;
	top: 2px !important;
	margin-top: 0 !important;
	accent-color: #1a6fc0;
	cursor: pointer;
}

/* Pemisah antar base/overlay */
.leaflet-panel-layers-separator {
	height: 0 !important;
	margin: 8px 4px !important;
	border-top: 1px dashed #d5e2ee !important;
}

/* Scrollbar halus saat expanded */
.leaflet-panel-layers.expanded::-webkit-scrollbar {
	width: 6px;
}
.leaflet-panel-layers.expanded::-webkit-scrollbar-thumb {
	background: rgba(26, 111, 192, 0.4);
	border-radius: 999px;
}
.leaflet-panel-layers.expanded::-webkit-scrollbar-track {
	background: transparent;
}

.leaflet-panel-layers .leaflet-panel-layers-list {
	background: transparent !important;
}

/* ---------- Animasi ---------- */
@keyframes floatIn {
	from {
		opacity: 0;
		transform: translateY(-8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* ================================================================
   RESPONSIVE
================================================================ */

/* ---------- TABLET ---------- */
@media (max-width: 1024px) {
	.map-title-panel {
		max-width: 240px;
	}
	.legend {
		max-width: 200px;
	}
}

/* ---------- MOBILE ---------- */
@media (max-width: 768px) {
	.map-title-panel {
		top: 12px;
		left: 12px;
		right: 12px;
		max-width: none;
		padding: 12px 14px;
	}
	.map-title-panel h2 {
		font-size: 13px;
	}
	.map-title-panel p {
		font-size: 10.5px;
	}

	.legend {
		bottom: 48px;
		left: 8px;
		right: auto;
		width: min(42vw, 160px);
		max-width: 160px;
		max-height: calc(100% - 150px);
		padding: 8px 10px;
		z-index: 1000;
		font-size: 10px;
	}
	.legend h3 {
		font-size: 11px;
	}
	.legend li {
		font-size: 10px;
		gap: 8px;
		margin-bottom: 6px;
	}
	.legend .swatch {
		width: 14px;
		height: 14px;
	}

	.coord-bar {
		min-width: 0;
		width: auto;
		max-width: calc(100% - 150px);
		font-size: 9px;
		bottom: 8px;
		left: 8px;
		padding: 5px 7px;
		z-index: 1000;
	}

	.btn-reset {
		top: auto;
		bottom: 8px;
		left: auto;
		right: 8px;
		padding: 7px 9px;
		font-size: 9px;
		z-index: 1002;
	}

	/* Panel layer lebih ringkas di mobile */
	.leaflet-panel-layers {
		max-width: min(70vw, 280px);
	}
	.leaflet-panel-layers.expanded {
		max-height: min(52vh, 420px);
		max-height: min(52dvh, 420px);
	}
	.leaflet-top.leaflet-right {
		top: 8px;
		right: 8px;
	}
	.leaflet-top.leaflet-left {
		top: 8px;
		left: 8px;
	}
	.leaflet-control-geocoder {
		max-width: min(62vw, 240px);
	}
	.leaflet-control-geocoder-form input {
		max-width: 100%;
	}
	.leaflet-panel-layers-grouplabel {
		padding: 8px 10px !important;
		font-size: 11.5px !important;
	}
	.leaflet-panel-layers-item {
		padding: 5px 8px !important;
	}
	.leaflet-panel-layers-title {
		font-size: 11px !important;
	}

	.map-loader {
		top: 10px;
		padding: 7px 11px;
		font-size: 10px;
	}
	.map-loader i {
		font-size: 11px;
	}
}

/* ---------- MOBILE KECIL ---------- */
@media (max-width: 480px) {
	.map-title-panel p {
		display: none;
	}
	.legend {
		max-width: 150px;
	}
}
