.leaflet-right {
    left: 0;
}

/* Unified responsive map controls: keeps map buttons from overlapping across
   desktop, tablet and field-phone widths. */
.terrain3d-toggle,
.offline-map-toggle,
.gps-tracking-toggle {	
	justify-content: center !important;
}
.terrain3d-toggle { top: 118px !important; right: 18px !important; bottom: auto !important; }
.offline-map-toggle { top: 164px !important; right: 18px !important; bottom: auto !important; }
.gps-tracking-toggle { top: 210px !important; right: 18px !important; bottom: auto !important; }
.poi-floating-container {
	top: 258px !important;
	right: 18px !important;
	transform: none !important;
	gap: 8px !important;
}
.poi-main-btn {
	width: 42px !important;
	height: 42px !important;
	border-radius: 9px !important;
}
.poi-main-btn.is-menu-open,
.poi-main-btn.is-menu-open:hover {
	transform: none !important;
}
.poi-chatbot-btn img {
	width: 30px !important;
	height: 30px !important;
	border-radius: 50% !important;
	object-fit: cover !important;
}
.poi-sub-menu {
	position: fixed !important;
	right: auto !important;
	bottom: auto !important;
	max-width: calc(100vw - 24px) !important;
	max-height: calc(100vh - 16px) !important;
	overflow-y: auto !important;
	overscroll-behavior: contain !important;
	scrollbar-width: thin !important;
}
#chatbot-container {
	right: 76px !important;
	bottom: 18px !important;
	z-index: 9000 !important;
}
.chat-trigger {
	display: none !important;
}
.chat-modern {
	position: fixed !important;
	right: 76px !important;
	bottom: 18px !important;
}
.chat-modern.is-fullscreen {
	inset: 12px !important;
	right: 12px !important;
	bottom: 12px !important;
	left: 12px !important;
	top: 12px !important;
	width: auto !important;
	height: auto !important;
	max-width: none !important;
	max-height: none !important;
	border-radius: 12px !important;
	z-index: 2147483000 !important;
}
.floating-robot {
	width: 58px !important;
	height: 58px !important;
}
.access-stats-mini {
	right: 18px !important;
	bottom: 16px !important;
	z-index: 8500 !important;
}
.stats-mini-bar {
	min-height: 36px !important;
	padding: 5px 12px !important;
}
.leaflet-control.toolbox {
	z-index: 8200 !important;
}
.terrain3d-measure {
	display: none !important;
}
.terrain3d-shell.is-measuring .terrain3d-measure {
	display: block !important;
}

@media (max-width: 900px) {
	.terrain3d-toggle,
	.offline-map-toggle,
	.gps-tracking-toggle {
		left: 10px !important;
		right: auto !important;
		bottom: auto !important;
		width: 38px !important;
		height: 38px !important;
		padding: 0 !important;
	}	
	.terrain3d-toggle { top: 72px !important; }
	.offline-map-toggle { top: 118px !important; }
	.gps-tracking-toggle { top: 164px !important; }
	.terrain3d-toggle span,
	.offline-map-toggle span,
	.gps-tracking-toggle span {
		display: none !important;
	}
	.poi-floating-container {
		top: 72px !important;
		right: 8px !important;
		bottom: auto !important;
		transform: none !important;
		gap: 7px !important;
	}
	.poi-main-btn {
		width: 38px !important;
		height: 38px !important;
		font-size: 17px !important;
		border-radius: 9px !important;
	}
	.poi-sub-menu {
		width: min(260px, calc(100vw - 72px)) !important;
		max-height: calc(100vh - 16px) !important;
	}
	#chatbot-container {
		right: 56px !important;
		bottom: 74px !important;
	}
	.floating-robot {
		width: 50px !important;
		height: 50px !important;
	}
	.access-stats-mini {
		left: 50% !important;
		right: auto !important;
		bottom: 52px !important;
		transform: translateX(-50%) !important;
		width: min(330px, calc(100vw - 92px)) !important;
	}
	.terrain3d-panel {
		min-width: 0 !important;
		max-width: calc(100vw - 132px) !important;
	}
	.terrain3d-meta,
	.terrain3d-wind,
	.terrain3d-status {
		display: none !important;
	}
	.terrain3d-inspect,
	.terrain3d-measure {
		left: 12px !important;
		right: 12px !important;
		bottom: 12px !important;
		width: auto !important;
		max-height: 112px !important;
		overflow-y: auto !important;
	}
	.terrain3d-measure {
		max-height: 172px !important;
	}
	.terrain3d-shell.is-measuring .terrain3d-inspect {
		display: none !important;
	}
}

@media (max-width: 560px), (max-height: 520px) {
	.terrain3d-toolbar {
		top: 6px !important;
		left: 6px !important;
		right: 6px !important;
		display: grid !important;
		grid-template-columns: minmax(0, 1fr) auto !important;
		gap: 6px !important;
		align-items: start !important;
	}
	.terrain3d-panel {
		width: auto !important;
		min-width: 0 !important;
		max-width: none !important;
		padding: 6px 8px !important;
		border-radius: 7px !important;
	}
	.terrain3d-title {
		font-size: 10px !important;
		line-height: 1.15 !important;
		white-space: nowrap !important;
		overflow: hidden !important;
		text-overflow: ellipsis !important;
	}
	.terrain3d-actions {
		display: grid !important;
		grid-template-columns: repeat(4, 30px) !important;
		gap: 5px !important;
	}
	.terrain3d-action {
		width: 30px !important;
		height: 30px !important;
		border-radius: 7px !important;
		font-size: 12px !important;
	}
	.terrain3d-quick-controls {
		top: 44px !important;
		left: 6px !important;
		right: 6px !important;
		max-width: none !important;
		gap: 5px !important;
	}
	.terrain3d-quick-toggle {
		min-height: 28px !important;
		padding: 5px 8px !important;
		border-radius: 7px !important;
		font-size: 11px !important;
	}
	.terrain3d-quick-panel {
		width: 100% !important;
		max-width: none !important;
		max-height: min(34vh, 150px) !important;
		overflow-y: auto !important;
		overflow-x: hidden !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		gap: 5px !important;
	}
	.terrain3d-quick-controls.is-open .terrain3d-quick-panel {
		display: grid !important;
	}
	.terrain3d-switch {
		min-height: 26px !important;
		padding: 4px 7px !important;
		border-radius: 7px !important;
		font-size: 10px !important;
		line-height: 1.1 !important;
		white-space: normal !important;
	}
	.terrain3d-select-row {
		grid-column: 1 / -1 !important;
	}
	.terrain3d-inspect,
	.terrain3d-measure {
		left: 6px !important;
		right: 6px !important;
		bottom: 6px !important;
		top: auto !important;
		width: auto !important;
		max-width: none !important;
		max-height: 86px !important;
		padding: 7px 8px !important;
		border-radius: 8px !important;
		font-size: 10px !important;
		transform: none !important;
	}
	.terrain3d-measure {
		max-height: 140px !important;
	}
}

@media (max-width: 768px) {
	.terrain3d-toggle,
	.offline-map-toggle,
	.gps-tracking-toggle {
		left: 10px !important;
		right: auto !important;
		bottom: auto !important;
		width: 38px !important;
		height: 38px !important;
		padding: 0 !important;
	}
	.terrain3d-toggle { top: 72px !important; }
	.offline-map-toggle { top: 118px !important; }
	.gps-tracking-toggle { top: 164px !important; }
	.terrain3d-toggle span,
	.offline-map-toggle span,
	.gps-tracking-toggle span {
		display: none !important;
	}
	.poi-floating-container {
		top: 72px !important;
		right: 8px !important;
		bottom: auto !important;
		transform: none !important;
		gap: 7px !important;
	}
	.poi-main-btn {
		width: 38px !important;
		height: 38px !important;
		font-size: 17px !important;
		border-radius: 9px !important;
	}
	.poi-sub-menu {
		width: min(260px, calc(100vw - 72px)) !important;
		max-height: calc(100vh - 16px) !important;
	}
	#chatbot-container {
		right: 56px !important;
		bottom: 74px !important;
	}
	.floating-robot {
		width: 50px !important;
		height: 50px !important;
	}
	.chat-modern {
		position: fixed !important;
		right: 8px !important;
		left: 8px !important;
		bottom: 74px !important;
		width: auto !important;
		height: min(70vh, 520px) !important;
	}
	.chat-modern.is-fullscreen {
		inset: 0 !important;
		right: 0 !important;
		bottom: 0 !important;
		left: 0 !important;
		top: 0 !important;
		width: auto !important;
		height: auto !important;
		border-radius: 0 !important;
	}
	.access-stats-mini {
		left: 50% !important;
		right: auto !important;
		bottom: 52px !important;
		transform: translateX(-50%) !important;
		width: min(330px, calc(100vw - 92px)) !important;
	}
	.stats-mini-bar {
		justify-content: center !important;
		gap: 8px !important;
		padding: 5px 10px !important;
	}
	.mini-item {
		font-size: 12px !important;
	}
	.mini-detail-btn {
		display: none !important;
	}
	.stats-full-panel {
		position: fixed !important;
		right: 8px !important;
		left: 8px !important;
		bottom: 96px !important;
		width: auto !important;
	}
}
.legend {
    left: 0;
    right: initial;
    bottom: 0px;
}
select#thematicSelect {
	padding: 5px;
	border-radius: 5px;
	border: 1px #dbd1d180 solid;
}

.section-label {
	display: flex;
	justify-content: space-around;
	align-items: center;
	flex-direction: column;
}

.button_tmp {
	width: 45% !important;
	float: left;
	margin: 5px !important;
	justify-content: space-between;
}

#radiusSlider {
	-webkit-appearance: none;
	height: 4px;
	background: #ddd;
	border-radius: 5px;
	outline: none;
}

#radiusSlider::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 15px;
	height: 15px;
	background: #da251d;
	border-radius: 50%;
	cursor: pointer;
}

.toolbox-section {
	padding: 10px;
	border: 1px solid #eeeeee;
	border-radius: 6px;
}

.btn-pin-popup {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 16px;
	padding: 0 5px;
	line-height: 1;
	transition: transform 0.2s;
}

.btn-pin-popup.is-pinned {
	filter: drop-shadow(0 0 2px #da251d);
	transform: scale(1.2);
}

.popup-header-container {
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid #eee;
	padding-bottom: 5px;
	margin-bottom: 10px;
	cursor: move;
}

.icon-btn {
	width: 50px;
	border: 1px solid #f00;
	height: 50px;
	background: #fff;
	padding: 5px;
	cursor: pointer;
	transition: transform 0.1s, filter 0.2s;
}

.icon-btn:active {
	transform: scale(0.9);
	filter: brightness(1.2);
}

.planning-toolbox-btn {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	flex-direction: column !important;
	gap: 1px !important;
	color: #da251d !important;
	font-weight: 900 !important;
	font-size: 15px !important;
	border-radius: 8px !important;
}

.planning-toolbox-btn span {
	font-size: 10px !important;
	line-height: 1 !important;
}

.planning-toolbox-btn.is-active {
	background: #da251d !important;
	color: #fff !important;
	border-color: #da251d !important;
	box-shadow: 0 5px 14px rgba(218, 37, 29, .28) !important;
}

.map-layer-btn {
	pointer-events: auto !important;
}

.map-layer-btn img {
	pointer-events: none;
	user-select: none;
}

.filter-panel {
	display: none;
	margin-top: 8px;
	padding: 8px;
	background: #fff;
	border: 1px solid #eee;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	font-size: 13px;
}

.filter-panel.show {
	display: block;
}

.filter-row {
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
	margin-bottom: 6px;
}

.filter-row > label {
	font-weight: 600;
	margin-right: 6px;
}

.filter-panel input[type="number"] {
	width: 92px;
}

.filter-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	justify-content: space-between;
}

.filter-count {
	opacity: 0.7;
	font-size: 12px;
	margin-left: auto;
}

.leaflet-control.toolbox {
	position: relative;
	display: flex;
	background: transparent;
	border: none;
	z-index: 1500;
	align-items: flex-end;
}

.leaflet-popup-content {
	min-width: 360px;
}

.badge {
	display: inline-block;
	padding: 6px 10px;
	border-radius: 10px;
	border: 1px solid #e3e3e3;
	background: #f9f9f9;
	margin-right: 6px;
	margin-bottom: 6px;
}

.badge b {
	display: block;
	font-size: 16px;
	margin-top: 2px;
}

.section-title {
	margin: 8px 0 4px;
	font-weight: bold;
}

.leaflet-popup {
	transition: none !important;
}

.label-xa {
	font-size: 12px;
	font-weight: 600;
	margin-top: -36px !important;
	color: #222;
	text-shadow: 1px 1px 2px #fff;
	pointer-events: none;
	white-space: nowrap;
}

.leaflet-top.leaflet-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    bottom: 46px;
    right:15px;
}
.leaflet-control-layers.leaflet-control {
    margin: 0px !important;
    display: none;
}

.toolbox-header {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-items: flex-end;
}

#toggleToolboxBtn,#reloadPageBtn {
	font-size: 20px;
	border: 1px solid #888;
	border-radius: 6px;
	background: #fff;
	cursor: pointer;
	width: 50px;
	height: 50px;
	transition: 0.2s;
}

#toggleToolboxBtn:hover,#reloadPageBtn:hover {
	background: #f0f0f0;
}

#toggleToolboxBtn:hover {
	background: #f0f0f0;
}

.toolbox-content {
	position: fixed !important;
	bottom: 85px;
	left: 50%;
	transform: translateX(-50%);
	width: 280px;
	max-height: 70vh;
	display: none;
	flex-direction: column;
	overflow: hidden;
	background: white;
	border-radius: 15px;
	box-shadow: 0 10px 30px rgba(0,0,0,0.3);
	border: 1px solid #ddd;
	z-index: 3000 !important;
	animation: slideUp 0.3s ease-out;
	pointer-events: auto;
}

.toolbox-content button {
	width: 100%;
	margin: 4px 0;
	padding: 10px;
	font-size: 14px;
	font-weight: 500;
	text-align: left;
	border: 1px solid #eee;
	border-radius: 8px;
	background: #fff;
	color: #333;
	cursor: pointer;
	transition: all 0.2s;
	display: flex;
	align-items: center;
	gap: 10px;
}

.toolbox-content button:active {
	background: #f0f0f0 !important;
	transform: scale(0.98);
}

#toggleCameraBtn {
	background: #f0f4ff !important;
	color: #2563eb !important;
	border-color: #dbeafe !important;
}

.txtcsv_thangtv {
	display: flex;
	gap: 6px;
	width: 100%;
}

.txtcsv_thangtv button.txtcsv {
	flex: 1;
	text-align: center !important;
	padding: 8px !important;
}

.toolbox-content button img {
	max-width: 100%;
	height: auto;
	display: block;
	margin: 0 auto;
}

.toolbox-content button:hover {
	background: #eaeaea;
}

.toolbox-content button.off {
	opacity: 0.5;
}

.zoom-btns {
	display: flex;
	justify-content: space-between;
	width: 100%;
}

.zoom-btns button {
	width: 40px;
	text-align: center;
}

.txtcsv {
	width: 48% !important;
}

.map-layer-btn {
	font-size: 18px;
	margin: 0 2px;
	cursor: pointer;
	border: 1px solid #ab0808 !important;
	border-radius: 4px;
	background: #fff !important;
	transition: all 0.2s;
}

.map-layer-btn:hover {
	background: #f0f0f0;
	transform: scale(1.1);
}

.btn-ai-voice {
	flex: 1.2 !important;
	border: 2px solid var(--red-flag) !important;
}

.toolbox-header .icon-btn:active, .toolbox-header button:active {
	transform: scale(0.9);
	filter: brightness(0.9);
}

.toolbox-content.open {
	display: flex;
}

.toolbox-header-inner {
	background: #f8f9fa;
	padding: 10px 15px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	border-bottom: 1px solid #eee;
	font-weight: bold;
	color: #da251d;
}

#closeToolbox {
	font-size: 24px;
	cursor: pointer;
	color: #999;
}

#closeToolbox:hover {
	color: red;
}

.toolbox-body {
	padding: 10px;
	overflow-y: auto;
}

.toolbox-body button:hover {
	background: #fff5f5;
	border-color: #da251d;
}

.btn-highlight {
	background: #f0f7ff !important;
	color: #2563eb !important;
	font-weight: bold;
	border: 1px solid #2563eb !important;
}

.txtcsv_row {
	display: flex;
	gap: 8px;
	margin-bottom: 8px;
}

select#thematicSelect {
	padding: 5px;
}

.txtcsv_row button {
	flex: 1;
	justify-content: center;
}

@keyframes slideUpMobile {
	from {
		opacity: 0;
		transform: translate(-50%, 20px);
	}

	to {
		opacity: 1;
		transform: translate(-50%, 0);
	}
}

@keyframes slideUp {
	from {
		opacity: 0;
		transform: translate(-50%, 20px);
	}

	to {
		opacity: 1;
		transform: translate(-50%, 0);
	}
}

@media (max-width: 767.99px) {
	#mapLayersMenu {
		bottom: 60px !important;
		flex-direction: row !important;
		right: -45px !important;
	}
	.leaflet-top.leaflet-right {
    bottom: 5px;
}

	.button_tmp {
		width: 100% !important;
	}

	.leaflet-control.toolbox {
		margin: 0 !important;
		float: none !important;
		width: 100%;
		display: flex;
		justify-content: center;
		pointer-events: none;
	}

	#toolboxContent.toolbox-content {
		position: fixed !important;
		left: 50% !important;
		top: auto !important;
		bottom: 80px !important;
		transform: translateX(-50%) !important;
		width: 92% !important;
		max-width: 340px !important;
		max-height: calc(100vh - 160px) !important;
		overflow-y: auto !important;
		background: white;
		border-radius: 12px;
		box-shadow: 0 -5px 25px rgba(0,0,0,0.2);
		z-index: 1001;
		pointer-events: auto;
		display: none;
	}

	#toolboxContent.toolbox-content.open {
		display: block;
		animation: slideUpMobile 0.3s ease-out;
	}

	.toolbox-body {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 6px;
		padding: 12px;
	}

	.toolbox-body button {
		padding: 8px 4px;
		font-size: 12px;
		height: 40px;
		margin: 0;
	}

	.toolbox-header-inner {
		padding: 10px;
		font-size: 14px;
	}

	.toolbox-content {
		width: 85vw;
		bottom: 80px;
		max-height: 70vh;
		overflow-y: auto;
	}

	.leaflet-control.toolbox {
		position: fixed !important;
		bottom: 10px !important;
		left: 50% !important;
		transform: translateX(-50%) !important;
		width: 96vw !important;
		background: rgba(255, 255, 255, 0.9);
		padding: 6px !important;
		border-radius: 12px;
		box-shadow: 0 4px 15px rgba(0,0,0,0.2);
		display: flex !important;
		justify-content: center !important;
		z-index: 2000;
	}

	.toolbox-header {
		display: flex !important;
		flex-direction: row !important;
		width: 100% !important;
		gap: 4px !important;
		justify-content: center !important;
		align-items: center !important;
	}

	.toolbox-header .icon-btn, .toolbox-header button {
		flex: 1 !important;
		min-width: 0 !important;
		max-width: 50px !important;
		aspect-ratio: 1 / 1 !important;
		width: auto !important;
		height: auto !important;
		padding: 5px !important;
		background: #fff !important;
		border: 1px solid #ddd !important;
		border-radius: 8px !important;
		display: flex !important;
		align-items: center !important;
		justify-content: center !important;
		box-sizing: border-box !important;
	}

	.toolbox-header img.icon-btn {
		object-fit: contain !important;
	}

	#toggleToolboxBtn, #reloadPageBtn {
		font-size: 18px !important;
		line-height: 1 !important;
	}

	#toolboxContent.toolbox-content {
		position: fixed;
		left: 50%;
		top: auto;
		bottom: 90px;
		transform: translateX(-50%);
		width: 90%;
		max-width: 350px;
		max-height: 60vh;
		overflow-y: auto;
		background: #ffffff;
		border-radius: 15px;
		box-shadow: 0 -5px 20px rgba(0,0,0,0.2);
	}
}
