/* ==========================================================================
   Leaflet 1.9.4 Core Styles + Modern Interactive Radar UI
   Davis2SQL CMS Component
   ========================================================================== */

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
	position: absolute;
	left: 0;
	top: 0;
}
.leaflet-container {
	overflow: hidden;
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
	-webkit-user-select: none;
	-moz-user-select: none;
	user-select: none;
	-webkit-user-drag: none;
}
.leaflet-tile::selection {
	background: transparent;
}
.leaflet-safari .leaflet-tile {
	image-rendering: -webkit-optimize-contrast;
}
.leaflet-safari .leaflet-tile-container {
	width: 1600px;
	height: 1600px;
	-webkit-transform-origin: 0 0;
}
.leaflet-marker-icon,
.leaflet-marker-shadow {
	display: block;
}
.leaflet-container .leaflet-overlay-pane svg {
	max-width: none !important;
	max-height: none !important;
}
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
	max-width: none !important;
	max-height: none !important;
	width: auto;
	padding: 0;
}
.leaflet-container.leaflet-touch-zoom {
	-ms-touch-action: pan-x pan-y;
	touch-action: pan-x pan-y;
}
.leaflet-container.leaflet-touch-drag {
	-ms-touch-action: pinch-zoom;
	touch-action: none;
	touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
	-ms-touch-action: none;
	touch-action: none;
}
.leaflet-container {
	-webkit-tap-highlight-color: transparent;
}
.leaflet-container a {
	-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
}
.leaflet-tile {
	filter: inherit;
	visibility: hidden;
}
.leaflet-tile-loaded {
	visibility: inherit;
}
.leaflet-zoom-box {
	width: 0;
	height: 0;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
	z-index: 800;
}
.leaflet-overlay-pane svg {
	-moz-user-select: none;
}
.leaflet-pane         { z-index: 400; }
.leaflet-tile-pane    { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane  { z-index: 500; }
.leaflet-marker-pane  { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane   { z-index: 700; }

.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg    { z-index: 200; }

.leaflet-control {
	position: relative;
	z-index: 800;
	pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
	position: absolute;
	z-index: 1000;
	pointer-events: none;
}
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control {
	float: left;
	clear: both;
}
.leaflet-right .leaflet-control { float: right; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }

.leaflet-zoom-animated {
	-webkit-transform-origin: 0 0;
	-ms-transform-origin: 0 0;
	transform-origin: 0 0;
}
svg.leaflet-zoom-animated {
	will-change: transform;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
	-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
	-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
	transition: transform 0.25s cubic-bezier(0,0,0.25,1);
}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
	-webkit-transition: none;
	-moz-transition: none;
	transition: none;
}
.leaflet-zoom-anim .leaflet-zoom-hide {
	visibility: hidden;
}

.leaflet-interactive { cursor: pointer; }
.leaflet-grab { cursor: grab; }
.leaflet-crosshair, .leaflet-crosshair .leaflet-interactive { cursor: crosshair; }
.leaflet-popup-pane, .leaflet-control { cursor: auto; }
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable { cursor: grabbing; }

.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
	pointer-events: none;
}
.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
	pointer-events: auto;
}

.leaflet-container {
	background: #1e293b;
	font-family: inherit;
	font-size: 0.8rem;
}
.leaflet-bar {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
	border-radius: 8px;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.15);
}
.leaflet-bar a {
	background-color: rgba(30, 41, 59, 0.85);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	width: 32px;
	height: 32px;
	line-height: 32px;
	display: block;
	text-align: center;
	text-decoration: none;
	color: #f8fafc;
	font-weight: bold;
	transition: background-color 0.15s ease, color 0.15s ease;
}
.leaflet-bar a:hover {
	background-color: rgba(15, 23, 42, 0.95);
	color: #38bdf8;
}
.leaflet-bar a:last-child {
	border-bottom: none;
}

/* ==========================================================================
   Radar Component Custom Styles & Glassmorphism UI
   ========================================================================== */

.radar-wrapper {
	position: relative;
	z-index: 1;
	isolation: isolate;
	container-type: inline-size;
	width: 100%;
	height: 516px;
	border-radius: 0;
	overflow: hidden;
	background: #0f172a;
	display: flex;
	flex-direction: column;
}

.radar-wrapper:fullscreen,
.radar-wrapper:-webkit-full-screen {
	width: 100vw !important;
	height: 100vh !important;
	border-radius: 0 !important;
}

#radar-map {
	width: 100%;
	flex: 1;
	min-height: 0;
	z-index: 1;
}

/* OpenStreetMap Dark Mode Theme Filter - only active when dark style is selected */
.radar-basemap-layer.radar-basemap-dark {
	filter: invert(100%) hue-rotate(180deg) brightness(80%) contrast(110%);
}

/* Pulsing Station Marker */
.station-pin {
	position: relative;
	width: 16px;
	height: 16px;
}
.station-pin .station-dot {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 12px;
	height: 12px;
	background: #ef4444;
	border: 2px solid #ffffff;
	border-radius: 50%;
	box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
	z-index: 2;
}
.station-pin .station-pulse {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 24px;
	height: 24px;
	background: rgba(239, 68, 68, 0.4);
	border-radius: 50%;
	animation: station-pulse-anim 2s infinite ease-out;
	z-index: 1;
}
@keyframes station-pulse-anim {
	0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0.9; }
	100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

/* Floating Top Controls */
.radar-top-controls {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 1001;
	display: flex;
	gap: 8px;
	pointer-events: auto;
}
.radar-btn {
	background: rgba(15, 23, 42, 0.8);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: #f8fafc;
	padding: 6px 10px;
	border-radius: 6px;
	font-size: 0.85rem;
	font-weight: 500;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	transition: all 0.15s ease;
	user-select: none;
}
.radar-btn:hover {
	background: rgba(30, 41, 59, 0.95);
	border-color: #38bdf8;
	color: #38bdf8;
}

/* Timeline Control Bar (Bottom Glassmorphism) */
.radar-timeline-container {
	position: absolute;
	bottom: 48px;
	left: 12px;
	right: 12px;
	z-index: 1001;
	background: rgba(15, 23, 42, 0.85);
	backdrop-filter: blur(12px);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 8px;
	padding: 10px 14px;
	display: flex;
	align-items: center;
	gap: 12px;
	color: #f8fafc;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
	pointer-events: auto;
	box-sizing: border-box;
}
.radar-timeline-info {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}
.radar-play-btn {
	background: #38bdf8;
	color: #0f172a;
	border: none;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 0.9rem;
	cursor: pointer;
	flex-shrink: 0;
	transition: transform 0.1s ease, background-color 0.15s ease;
}
.radar-play-btn:hover {
	transform: scale(1.08);
	background: #7dd3fc;
}
.radar-play-btn:active {
	transform: scale(0.95);
}
.radar-time-display {
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	font-size: 0.95rem;
	min-width: 60px;
	text-align: center;
	white-space: nowrap;
}
.radar-time-badge {
	font-size: 0.7rem;
	text-transform: uppercase;
	padding: 2px 6px;
	border-radius: 4px;
	background: #334155;
	letter-spacing: 0.05em;
	white-space: nowrap;
}
.radar-time-badge.is-now {
	background: #0284c7;
	color: #ffffff;
}

.radar-slider-wrap {
	flex: 1;
	display: flex;
	align-items: center;
	position: relative;
	min-width: 0;
}
.radar-range-slider {
	width: 100%;
	-webkit-appearance: none;
	appearance: none;
	height: 6px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.25);
	outline: none;
	cursor: pointer;
	margin: 0;
}
.radar-range-slider::-webkit-slider-runnable-track {
	width: 100%;
	height: 6px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.25);
	cursor: pointer;
}
.radar-range-slider::-moz-range-track {
	width: 100%;
	height: 6px;
	border-radius: 3px;
	background: rgba(255, 255, 255, 0.25);
	cursor: pointer;
}
.radar-range-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #38bdf8;
	box-shadow: 0 0 6px rgba(56, 189, 248, 0.8);
	cursor: pointer;
	margin-top: -5px;
	transition: transform 0.1s ease;
}
.radar-range-slider::-webkit-slider-thumb:hover {
	transform: scale(1.25);
}
.radar-range-slider::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #38bdf8;
	border: none;
	box-shadow: 0 0 6px rgba(56, 189, 248, 0.8);
	cursor: pointer;
	transition: transform 0.1s ease;
}
.radar-range-slider::-moz-range-thumb:hover {
	transform: scale(1.25);
}

/* Settings Drawer Overlay */
.radar-drawer {
	position: absolute;
	top: 50px;
	right: 12px;
	z-index: 1002;
	background: rgba(15, 23, 42, 0.92);
	backdrop-filter: blur(14px);
	border: 1px solid rgba(255, 255, 255, 0.18);
	border-radius: 8px;
	padding: 14px;
	width: 260px;
	max-width: calc(100% - 24px);
	box-sizing: border-box;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
	display: none;
	flex-direction: column;
	gap: 12px;
	color: #f8fafc;
	pointer-events: auto;
}
.radar-drawer.is-open {
	display: flex;
}
.radar-drawer-title {
	font-weight: 600;
	font-size: 0.9rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	padding-bottom: 6px;
}
.radar-drawer-row {
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.radar-drawer-row label {
	font-size: 0.8rem;
	color: #94a3b8;
}
.radar-drawer-select {
	background: #1e293b;
	color: #f8fafc;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 4px;
	padding: 6px 8px;
	font-size: 0.85rem;
}

/* Legend & Attribution Bar */
.radar-footer-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 12px;
	font-size: 0.75rem;
	color: var(--secondary-color, #6c757d);
	background: var(--card-bg, #ffffff);
	border-top: 1px solid var(--border-color, #e2e8f0);
	flex-shrink: 0;
	z-index: 10;
}

[data-theme="dark"] .radar-footer-bar,
.radar-wrapper:fullscreen .radar-footer-bar,
.radar-wrapper:-webkit-full-screen .radar-footer-bar {
	background: #0f172a;
	color: #94a3b8;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.radar-legend {
	display: flex;
	align-items: center;
	gap: 8px;
}
.radar-legend-bar {
	width: 90px;
	height: 8px;
	border-radius: 4px;
	background: linear-gradient(to right, #00ece8, #01a0f6, #0000f6, #00e500, #008f00, #ffff00, #ff9000, #ff0000, #d60000, #c000ff);
}
.radar-attribution a {
	color: inherit;
	text-decoration: none;
}
.radar-attribution a:hover {
	text-decoration: underline;
}

/* Container Query: Switch timeline to stacked 2-row layout when container is narrow */
@container (max-width: 520px) {
	.radar-timeline-container {
		flex-direction: column;
		align-items: stretch;
		gap: 6px;
		left: 8px;
		right: 8px;
		padding: 8px 10px;
		bottom: 56px;
	}
	.radar-timeline-info {
		width: 100%;
		justify-content: flex-start;
		gap: 8px;
	}
	.radar-slider-wrap {
		width: 100%;
		padding: 2px 0;
	}
	.radar-range-slider {
		height: 8px;
	}
	.radar-range-slider::-webkit-slider-runnable-track {
		height: 8px;
		border-radius: 4px;
	}
	.radar-range-slider::-moz-range-track {
		height: 8px;
		border-radius: 4px;
	}
	.radar-range-slider::-webkit-slider-thumb {
		width: 20px;
		height: 20px;
		margin-top: -6px;
	}
	.radar-range-slider::-moz-range-thumb {
		width: 20px;
		height: 20px;
	}
	.radar-time-display {
		font-size: 0.85rem;
		min-width: auto;
	}
	.radar-btn span.btn-text {
		display: none;
	}
	.radar-footer-bar {
		padding: 4px 8px;
		font-size: 0.68rem;
		flex-wrap: wrap;
		gap: 4px 8px;
	}
	.radar-legend {
		gap: 6px;
		font-size: 0.68rem;
	}
	.radar-legend-bar {
		width: 65px;
		height: 6px;
	}
	.radar-attribution {
		font-size: 0.68rem;
	}
}

@media (max-width: 767px) {
	.radar-wrapper {
		height: 420px;
	}
	.radar-btn span.btn-text {
		display: none;
	}
}

/* Fallback for browsers without container query support on mobile */
@supports not (container-type: inline-size) {
	@media (max-width: 520px) {
		.radar-timeline-container {
			flex-direction: column;
			align-items: stretch;
			gap: 6px;
			left: 8px;
			right: 8px;
			padding: 8px 10px;
			bottom: 56px;
		}
		.radar-timeline-info {
			width: 100%;
			justify-content: flex-start;
			gap: 8px;
		}
		.radar-slider-wrap {
			width: 100%;
			padding: 2px 0;
		}
		.radar-range-slider {
			height: 8px;
		}
		.radar-range-slider::-webkit-slider-runnable-track {
			height: 8px;
			border-radius: 4px;
		}
		.radar-range-slider::-moz-range-track {
			height: 8px;
			border-radius: 4px;
		}
		.radar-range-slider::-webkit-slider-thumb {
			width: 20px;
			height: 20px;
			margin-top: -6px;
		}
		.radar-range-slider::-moz-range-thumb {
			width: 20px;
			height: 20px;
		}
		.radar-footer-bar {
			padding: 4px 8px;
			font-size: 0.68rem;
			flex-wrap: wrap;
			gap: 4px 8px;
		}
		.radar-legend {
			gap: 6px;
			font-size: 0.68rem;
		}
		.radar-legend-bar {
			width: 65px;
			height: 6px;
		}
		.radar-attribution {
			font-size: 0.68rem;
		}
	}
}
