/* ========================================
   Base map and layout sizing
======================================== */

#map,
#controls { height: 100vh; }

#controls { padding: 15px 0px 15px 0px }

/* ========================================
   Legend styling
   - desktop legend layout
   - legend checkbox styles
   - legend icon sizing
======================================== */

/* Legend - safe/simple version */
.legend,
#legend {
	background-color: #fff;
	border-radius: 6px;
	bottom: 30px;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
	color: #1f2937;
	font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
	padding: 10px;
	position: absolute;
	right: 15px;
	z-index: 1;
	opacity: 0.92;
	min-width: 220px;
}

#legend .map-filter-checkbox {
	cursor: pointer;
	margin: 4px 0;
	white-space: nowrap;
	color: #374151;
}

#legend .map-filter-checkbox input[type="checkbox"] {
	margin: 0 6px 0 0;
	vertical-align: middle;
	accent-color: #6b7280; /* changed from blue */
	cursor: pointer;
}

#legend .map-filter-checkbox input[type="checkbox"]:hover {
	filter: brightness(0.9);
}

.legend img,
#legend img {
	display: inline-block;
	width: 24px;
	height: 24px;
	object-fit: contain;
	vertical-align: middle;
	margin-right: 6px;
}

.legend svg,
#legend svg {
	display: inline-block;
	width: 24px;
	height: 24px;
	vertical-align: middle;
	margin-right: 6px;
}

/* ========================================
   Sidebar / filter panel container
   - left filter drawer
   - glassmorphism background
======================================== */

/* Controls sidebar */
#controls {
	width: 0;
	background: rgba(255, 255, 255, 0.96);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border-right: 1px solid rgba(15, 23, 42, 0.08);
	box-shadow: 10px 0 30px rgba(15, 23, 42, 0.12);
	position: absolute;
	z-index: 1;
	height: 100%;
	top: 0;
	left: 0;
	overflow-x: hidden;
	transition: 0.35s ease;
	padding-top: 56px;
}

#controls.collapsed { width: 320px; }

#controls div.col-md-12 {
	padding: 0 12px;
}

/* ========================================
   Filter panels
   - accordion cards
   - panel spacing and shadows
======================================== */

/* Filter panels */
#controls .panel {
	border: 1px solid rgba(15, 23, 42, 0.08);
	border-radius: 14px;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
	overflow: hidden;
	margin-bottom: 12px;
	background: #ffffff;
}

#controls .panel-heading {
	background: #f8fafc;
	border-bottom: 1px solid rgba(15, 23, 42, 0.08);
	padding: 12px 14px;
}

#controls .panel-title,
#controls .accordion-toggle {
	color: #111827;
	font-weight: 700;
	font-size: 14px;
	text-decoration: none;
	cursor: pointer;
}

#controls .panel-body {
	padding: 14px;
}

#controls label {
	color: #374151;
	font-size: 12px;
	font-weight: 600;
	margin-bottom: 5px;
}

/* ========================================
   Filter field styling
   - inputs
   - selects
   - focus states
======================================== */

/* Inputs */
#controls input,
#controls select {
	border: 1px solid #d1d5db;
	border-radius: 10px;
	box-shadow: none;
	color: #111827;
	font-size: 13px;
	height: 36px;
	padding: 7px 10px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#controls input:focus,
#controls select:focus {
	border-color: #2563eb;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
	outline: none;
}

/* ========================================
   Top map control buttons
   - filter toggle
   - reset button
======================================== */

/* Buttons */
button#controls-open,
button#controls-refresh {
	border: 1px solid rgba(15, 23, 42, 0.10);
	border-radius: 10px;
	box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
	background: #ffffff;
	color: #111827;
	height: 34px;
	min-width: auto;
	padding: 6px 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	font-size: 12px;
	line-height: 1;
	transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

button#controls-open:hover,
button#controls-refresh:hover {
	background: #f8fafc;
	transform: translateY(-1px);
	box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

button#controls-open {
	position: absolute;
	top: 14px;
	left: 14px;
	z-index: 2;
}

button#controls-refresh {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
}

.accordion-toggle { cursor: pointer }

div.map-container { padding: 0 !important; margin: 0 !important; }
canvas.mapboxgl-canvas { width: 100% !important; height: 100% !important; }

/* ========================================
   Layout fixes and spacing tweaks
======================================== */

/* --- Layout fixes after modern styling --- */

/* Make the sidebar header controls sit cleanly at the top */
#controls {
	padding-top: 58px;
}

#controls .glyphicon {
	position: static;
	top: auto;
}

/* Keep Bootstrap button text/icons from clipping */
button#controls-open,
button#controls-refresh {
	width: auto !important;
	white-space: nowrap;
	overflow: visible;
}


/* ========================================
   Modern popup styling
   - popup card
   - popup shadows
   - close button
======================================== */

/* Modern Mapbox popup */
.mapboxgl-popup {
	max-width: 320px !important;
}

.mapboxgl-popup-content {
	padding: 18px 18px 14px !important;
	border: 1px solid rgba(15, 23, 42, 0.12) !important;
	border-radius: 14px !important;
	box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22) !important;
	background: rgba(255, 255, 255, 0.98) !important;
	color: #1f2937;
	font: 13px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
}

.mapboxgl-popup-tip {
	border-top-color: rgba(255, 255, 255, 0.98) !important;
	border-bottom-color: rgba(255, 255, 255, 0.98) !important;
}

.mapboxgl-popup-close-button {
	top: 8px;
	right: 8px;
	width: 24px;
	height: 24px;
	border-radius: 999px;
	border: 1px solid rgba(15, 23, 42, 0.10);
	background: #f8fafc;
	color: #475569;
	font-size: 18px;
	line-height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.mapboxgl-popup-close-button:hover {
	background: #e5e7eb;
	color: #111827;
	transform: scale(1.05);
}

.mapboxgl-popup-close-button:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.popup-info {
	margin: 0 28px 4px 0;
	color: #475569;
}

.popup-info:first-child {
	margin-bottom: 6px;
}

.popup-info b,
.popup-info a {
	color: #111827;
	font-size: 14px;
	font-weight: 600;
}

.popup-info a {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
	text-decoration-color: rgba(17, 24, 39, 0.45);
}

.popup-info a:hover {
	color: #2563eb;
	text-decoration: underline;
}


/* ========================================
   Popup accessibility / focus polish
======================================== */

/* Popup link focus fix: remove default browser outline and use a cleaner focus style */
.mapboxgl-popup-content a,
.mapboxgl-popup-content a:focus,
.mapboxgl-popup-content a:active {
	outline: none !important;
	box-shadow: none !important;
}

.mapboxgl-popup-content a:focus-visible {
	outline: none !important;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18) !important;
	border-radius: 4px;
}


/* ========================================
   Per-field clear (x) button
   - wrapper
   - clear button visibility
   - hover/focus states
======================================== */

/* Small clear (x) button inside filter fields */
.input-with-clear {
	position: relative;
}

.input-with-clear input.map-filter {
	padding-right: 34px;
}

.input-clear-btn {
	position: absolute;
	right: 9px;
	top: 50%;
	transform: translateY(-50%);
	width: 18px;
	height: 18px;
	border: 0;
	border-radius: 999px;
	background: #e5e7eb;
	color: #4b5563;
	font-size: 13px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	padding: 0;
	cursor: pointer;
	display: none;
	box-shadow: none;
	transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.input-clear-btn:hover {
	background: #d1d5db;
	color: #111827;
	transform: translateY(-50%) scale(1.05);
}

.input-clear-btn:focus {
	outline: none;
	box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.18);
}

.input-with-clear.has-value .input-clear-btn {
	display: block;
}

.input-with-clear.has-value input.map-filter {
	border-color: #475569;
	background: #f8fafc;
	box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.20);
}

/* ========================================
   Sidebar auto-height behavior
======================================== */

#controls {
	height: auto;
	max-height: 100%;
	overflow-y: auto;
}

#controls .panel-body {
	padding-bottom: 8px;
}

/* ========================================
   Global focus-visible accessibility polish
======================================== */

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
	outline: none;
	box-shadow: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
	border-color: #2563eb;
}

/* ========================================
   Mobile helper hint
   Explains that filter options depend
   on the visible map area.
======================================== */

/* Mobile-only filter hint */
.mobile-filter-hint {
	display: none;
}

@media (max-width: 768px) {
	.mobile-filter-hint {
		display: block;
		margin: 8px 0 12px;
		padding: 8px 10px;
		border-radius: 8px;
		background: #f8fafc;
		border: 1px solid #e5e7eb;
		color: #64748b;
		font-size: 12px;
		line-height: 16px;
	}
}

/* ========================================
   Mobile legend behavior
   - compact hidden legend
   - legend toggle button
======================================== */

#legend-toggle {
	display: none;
}

@media (max-width: 768px) {
	#legend {
		display: none;
		right: 12px;
		left: auto;
		width: 220px;
		max-width: calc(100vw - 24px);
		bottom: 78px;
		padding: 8px 10px;
		font-size: 11px;
	}

	#legend.mobile-open {
		display: block;
	}

	#legend-toggle {
		display: block;
		position: absolute;
		right: 12px;
		bottom: 16px;
		z-index: 2;
		border: 1px solid rgba(15, 23, 42, 0.12);
		border-radius: 10px;
		background: #ffffff;
		padding: 6px 10px;
		font-size: 12px;
		font-weight: 600;
		box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
	}
}