/* ===========================
   CSS Reset & Base Styles
   =========================== */

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	font-family:
		-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
		Cantarell, sans-serif;
	overflow: hidden;
}

/* ===========================
   Map Container (Full Screen)
   =========================== */

#map {
	width: 100%;
	height: 100vh;
	height: 100dvh; /* Dynamic viewport height for mobile */
	z-index: 0;
}

/* ===========================
   Control Panel (Mobile First)
   =========================== */

.control-panel {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 1000;
	display: flex;
	gap: 10px;
	flex-direction: column;
	width: calc(100% - 40px);
	max-width: 400px;
}

.control-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 20px;
	background: #fff;
	border: none;
	border-radius: 12px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	font-size: 16px;
	font-weight: 600;
	color: #2563eb;
	cursor: pointer;
	transition: all 0.2s ease;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

.control-btn:active {
	transform: scale(0.98);
}

.control-btn.secondary {
	background: #f3f4f6;
	color: #4b5563;
}

.control-btn svg {
	flex-shrink: 0;
}

/* Tablet and Desktop */
@media (min-width: 768px) {
	.control-panel {
		flex-direction: row;
		width: auto;
		max-width: none;
	}

	.control-btn {
		padding: 12px 20px;
		font-size: 15px;
	}
}

/* ===========================
   Modal (Location Permission)
   =========================== */

.modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.6);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2000;
	padding: 20px;
}

.modal.hidden {
	display: none;
}

.modal-content {
	background: #fff;
	border-radius: 16px;
	padding: 24px;
	max-width: 400px;
	width: 100%;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
	font-size: 22px;
	margin-bottom: 16px;
	color: #111827;
}

.modal-content p {
	font-size: 15px;
	line-height: 1.6;
	color: #4b5563;
	margin-bottom: 12px;
}

.modal-content ul {
	margin: 12px 0 16px 20px;
	color: #4b5563;
}

.modal-content li {
	margin-bottom: 8px;
	font-size: 15px;
}

.privacy-note {
	background: #fef3c7;
	border-left: 3px solid #f59e0b;
	padding: 12px;
	border-radius: 6px;
	margin: 16px 0;
	font-size: 14px;
}

.modal-actions {
	display: flex;
	gap: 10px;
	margin-top: 20px;
	flex-direction: column;
}

.btn-primary,
.btn-secondary {
	padding: 14px 20px;
	border: none;
	border-radius: 8px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s ease;
	touch-action: manipulation;
}

.btn-primary {
	background: #2563eb;
	color: #fff;
}

.btn-primary:active {
	background: #1d4ed8;
}

.btn-secondary {
	background: #f3f4f6;
	color: #6b7280;
}

.btn-secondary:active {
	background: #e5e7eb;
}

@media (min-width: 480px) {
	.modal-actions {
		flex-direction: row;
	}

	.btn-primary,
	.btn-secondary {
		flex: 1;
	}
}

/* ===========================
   Routing Indicator
   =========================== */

.routing-indicator {
	position: fixed;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 1000;
	background: #10b981;
	color: #fff;
	padding: 12px 20px;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 15px;
	font-weight: 600;
}

.routing-indicator.hidden {
	display: none;
}

.routing-indicator button {
	background: rgba(255, 255, 255, 0.2);
	border: none;
	color: #fff;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	transition: background 0.2s ease;
}

.routing-indicator button:active {
	background: rgba(255, 255, 255, 0.3);
}

/* ===========================
   Toast Notifications
   =========================== */

.toast {
	position: fixed;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 1500;
	background: #1f2937;
	color: #fff;
	padding: 14px 20px;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	font-size: 15px;
	max-width: calc(100% - 40px);
	text-align: center;
	animation: slideDown 0.3s ease;
}

.toast.hidden {
	display: none;
}

.toast.error {
	background: #dc2626;
}

.toast.success {
	background: #10b981;
}

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

/* ===========================
   Leaflet Popup Customization
   =========================== */

.leaflet-popup-content-wrapper {
	border-radius: 12px;
	padding: 0;
	overflow: hidden;
}

.leaflet-popup-content {
	margin: 0;
	min-width: 260px;
}

.popup-content {
	padding: 16px;
}

.popup-title {
	font-size: 18px;
	font-weight: 700;
	color: #111827;
	margin-bottom: 8px;
}

.popup-description {
	font-size: 14px;
	color: #6b7280;
	line-height: 1.5;
	margin-bottom: 14px;
}

.popup-actions {
	display: flex;
	gap: 8px;
	flex-direction: column;
}

.popup-btn {
	padding: 10px 16px;
	border: none;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	text-align: center;
	transition: all 0.2s ease;
	display: block;
}

.popup-btn-primary {
	background: #2563eb;
	color: #fff;
}

.popup-btn-primary:active {
	background: #1d4ed8;
}

.popup-btn-secondary {
	background: #f3f4f6;
	color: #4b5563;
}

.popup-btn-secondary:active {
	background: #e5e7eb;
}

.popup-btn.disabled {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
}

/* ===========================
   Marker Cluster Customization
   =========================== */

.marker-cluster {
	background: rgba(37, 99, 235, 0.6);
	border: 3px solid rgba(37, 99, 235, 0.8);
}

.marker-cluster div {
	background: rgba(37, 99, 235, 0.8);
	color: #fff;
	font-weight: 700;
}

/* ===========================
   Leaflet Control Adjustments
   =========================== */

.leaflet-control-zoom {
	border: none !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-control-zoom a {
	border-radius: 8px !important;
	border: none !important;
	width: 36px !important;
	height: 36px !important;
	line-height: 36px !important;
	font-size: 20px !important;
}

.leaflet-control-zoom a:first-child {
	border-bottom: 1px solid #e5e7eb !important;
}

/* Hide routing machine controls on mobile */
.leaflet-routing-container {
	display: none;
}

/* Desktop: Show routing instructions in a sidebar */
@media (min-width: 1024px) {
	.leaflet-routing-container {
		display: block;
		width: 320px;
	}
}

/* ===========================
   Touch Optimizations
   =========================== */

@media (hover: none) and (pointer: coarse) {
	/* Increase touch target sizes on mobile */
	.leaflet-marker-icon {
		cursor: pointer;
	}

	/* Prevent text selection */
	.control-panel,
	.modal-content,
	.popup-content {
		-webkit-user-select: none;
		user-select: none;
	}
}

/* ===========================
   Loading State (Optional)
   =========================== */

.loading {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	z-index: 3000;
	background: #fff;
	padding: 20px 32px;
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
	font-size: 16px;
	font-weight: 600;
	color: #4b5563;
}

.loading.hidden {
	display: none;
}

/* ===========================
   Custom User Location Marker
   =========================== */

.walking-person-marker {
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	padding: 2px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
