/**
 * Sahakarmi Map Public Stylesheet
 * Handles frontend rendering styles for interactive maps.
 */

.sahakarmi-map-wrapper {
	position: relative;
	width: 100%;
	margin: 20px 0;
}

.sahakarmi-map-hint {
	margin: 6px 0 0 0;
	font-size: 10px;
	font-style: italic;
	color: #94a3b8;
	text-align: right;
	line-height: 1.3;
}

.sahakarmi-leaflet-map {
	width: 100%;
	background: #0f172a;
	border-radius: 20px;
	border: 2px solid var(--sahakarmi-map-border, rgba(148, 163, 184, 0.15));
	box-shadow:
		0 25px 50px -12px rgba(0, 0, 0, 0.25),
		0 0 0 1px rgba(255, 255, 255, 0.05) inset,
		0 0 40px -5px rgba(99, 102, 241, 0.12);
	overflow: hidden;
	z-index: 1;
	transition: box-shadow 0.4s ease;
}

.sahakarmi-leaflet-map:hover {
	box-shadow:
		0 25px 50px -12px rgba(0, 0, 0, 0.3),
		0 0 0 1px rgba(255, 255, 255, 0.05) inset,
		0 0 60px -5px rgba(99, 102, 241, 0.2);
}

/* Custom Zoom Control */
.sahakarmi-leaflet-map .leaflet-control-zoom {
	border: none !important;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
	border-radius: 12px !important;
	overflow: hidden;
}

.sahakarmi-leaflet-map .leaflet-control-zoom a {
	width: 34px !important;
	height: 34px !important;
	line-height: 34px !important;
	font-size: 18px !important;
	font-weight: 600 !important;
	color: #475569 !important;
	background: rgba(255, 255, 255, 0.95) !important;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
	transition: all 0.2s ease !important;
}

.sahakarmi-leaflet-map .leaflet-control-zoom a:hover {
	background: #f1f5f9 !important;
	color: #1e293b !important;
}

.sahakarmi-leaflet-map .leaflet-control-zoom a:first-child {
	border-radius: 12px 12px 0 0 !important;
}

.sahakarmi-leaflet-map .leaflet-control-zoom a:last-child {
	border-radius: 0 0 12px 12px !important;
	border-bottom: none !important;
}

/* Reset view button */
.sahakarmi-reset-view {
	width: 34px;
	height: 34px;
	line-height: 34px;
	text-align: center;
	font-size: 16px;
	font-weight: 600;
	color: #475569;
	background: rgba(255, 255, 255, 0.95);
	border-radius: 12px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	transition: all 0.2s ease;
	user-select: none;
}

.sahakarmi-reset-view:hover {
	background: #f1f5f9;
	color: #1e293b;
}

/* Map tile filter for a premium dark-vibrant look */
.sahakarmi-leaflet-map .leaflet-tile-pane {
	filter: saturate(1.15) brightness(1.05) contrast(1.05);
}

/* Attribution styling */
.sahakarmi-leaflet-map .leaflet-control-attribution {
	font-size: 9px !important;
	opacity: 0.5;
}

/* Loader Styles */
.sahakarmi-map-loader {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(15, 23, 42, 0.88);
	backdrop-filter: blur(8px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 999;
	border-radius: 20px;
}

.loader-spinner {
	width: 44px;
	height: 44px;
	border: 3px solid rgba(148, 163, 184, 0.2);
	border-top-color: #818cf8;
	border-radius: 50%;
	animation: sahakarmi-spin 0.8s linear infinite;
	margin-bottom: 14px;
	box-shadow: 0 0 20px -5px rgba(129, 140, 248, 0.4);
}

.sahakarmi-map-loader p {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 13px;
	color: #94a3b8;
	margin: 0;
	font-weight: 500;
	letter-spacing: 0.3px;
}

@keyframes sahakarmi-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Error message styling */
.sahakarmi-map-error {
	background: hsl(350, 75%, 97%);
	border: 1px solid hsl(350, 75%, 90%);
	color: hsl(350, 75%, 40%);
	padding: 16px;
	border-radius: 8px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	margin: 20px 0;
	font-weight: 500;
}

/* Custom Popup Styling (Leaflet overrides) */
.leaflet-popup-content-wrapper {
	background: transparent !important;
	border-radius: 16px !important;
	box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.06) !important;
	padding: 0 !important;
	overflow: visible;
	border: none !important;
}

.leaflet-popup-content {
	margin: 0 !important;
	line-height: inherit !important;
	width: 300px !important;
	animation: sahakarmi-popup-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sahakarmi-popup-enter {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.96);
	}

	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.leaflet-popup-tip-container {
	margin-top: -2px;
}

.leaflet-popup-tip {
	background: #ffffff !important;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

/* Modern Popup Card */
.sahakarmi-popup-card {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	background: #ffffff;
	border-radius: 16px;
	overflow: hidden;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

/* Header with glass overlay effect */
.sahakarmi-popup-header {
	position: relative;
	padding: 18px 20px 16px;
	color: #ffffff;
	overflow: hidden;
}

.sahakarmi-popup-header::before {
	content: '';
	position: absolute;
	top: -50%;
	right: -30%;
	width: 120px;
	height: 120px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 50%;
	pointer-events: none;
}

.sahakarmi-popup-header::after {
	content: '';
	position: absolute;
	bottom: -40%;
	left: -20%;
	width: 100px;
	height: 100px;
	background: rgba(255, 255, 255, 0.06);
	border-radius: 50%;
	pointer-events: none;
}

.sahakarmi-popup-title {
	font-size: 17px;
	font-weight: 700;
	margin: 0 0 6px 0;
	line-height: 1.2;
	position: relative;
	z-index: 1;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.sahakarmi-popup-meta-row {
	display: flex;
	align-items: center;
	gap: 8px;
	position: relative;
	z-index: 1;
}

.sahakarmi-popup-meta-icon {
	font-size: 13px;
	line-height: 1;
}

.sahakarmi-popup-meta-column {
	font-size: 10px;
	opacity: 0.85;
	text-transform: uppercase;
	letter-spacing: 1px;
	font-weight: 600;
	background: rgba(255, 255, 255, 0.2);
	padding: 3px 10px;
	border-radius: 20px;
}

/* Body */
.sahakarmi-popup-body {
	padding: 18px 20px;
	display: flex;
	flex-direction: column;
	gap: 14px;
	background: #ffffff;
}

/* Status Badge - pill shaped with subtle glow */
.sahakarmi-popup-status-badge {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border-radius: 50px;
	font-size: 12px;
	font-weight: 700;
	justify-content: center;
	position: relative;
}

.sahakarmi-popup-status-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	flex-shrink: 0;
	animation: sahakarmi-pulse-dot 2s ease-in-out infinite;
}

@keyframes sahakarmi-pulse-dot {

	0%,
	100% {
		box-shadow: 0 0 0 0 currentColor;
	}

	50% {
		box-shadow: 0 0 0 6px transparent;
	}
}

.sahakarmi-popup-section-title {
	font-size: 10px;
	font-weight: 700;
	color: hsl(215, 16%, 47%);
	text-transform: uppercase;
	letter-spacing: 1px;
	margin: 0 0 2px 0;
	display: flex;
	align-items: center;
	gap: 6px;
}

.sahakarmi-popup-section-title .section-icon {
	font-size: 12px;
}

/* Projects List - card style rows */
.sahakarmi-popup-projects-list {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.sahakarmi-popup-project-item {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 10px;
	padding: 10px 12px;
	background: hsl(220, 20%, 98%);
	border-radius: 10px;
	border: 1px solid hsl(214, 32%, 94%);
	transition: all 0.2s ease;
}

.sahakarmi-popup-project-item:hover {
	background: hsl(220, 25%, 95%);
	border-color: hsl(214, 32%, 88%);
	transform: translateX(2px);
}

.sahakarmi-popup-project-name {
	font-size: 11px;
	font-weight: 600;
	color: hsl(215, 28%, 17%);
	line-height: 1.4;
	flex: 1;
	min-width: 0;
	word-break: break-word;
}

.sahakarmi-popup-project-donor {
	font-size: 11px;
	font-weight: 500;
	color: hsl(215, 16%, 47%);
	text-align: right;
	line-height: 1.4;
	background: rgba(148, 163, 184, 0.1);
	padding: 3px 8px;
	border-radius: 6px;
	flex-shrink: 0;
	max-width: 50%;
	word-break: break-word;
}

/* Empty state */
.sahakarmi-popup-empty {
	text-align: center;
	padding: 16px 12px;
}

.sahakarmi-popup-empty-icon {
	font-size: 28px;
	margin-bottom: 6px;
	opacity: 0.5;
}

.sahakarmi-popup-empty-text {
	font-size: 12px;
	color: hsl(215, 16%, 60%);
	font-style: italic;
	margin: 0;
}

/* Unmapped region header */
.sahakarmi-popup-header-unmapped {
	background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

/* Map Legend Styles */
.sahakarmi-map-legend {
	background: rgba(15, 23, 42, 0.88);
	backdrop-filter: blur(16px);
	border-radius: 12px;
	border: 1px solid rgba(148, 163, 184, 0.15);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
	padding: 14px 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 11px;
	line-height: 1.5;
	min-width: 175px;
}

.legend-toggle-btn {
	display: none;
	cursor: pointer;
	user-select: none;
	font-weight: 700;
	color: #e2e8f0;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	justify-content: space-between;
	align-items: center;
	padding: 4px 0;
}

.legend-toggle-btn .toggle-icon {
	font-size: 10px;
	transition: transform 0.3s ease;
	opacity: 0.7;
	margin-left: 8px;
}

.sahakarmi-map-legend h4 {
	margin: 0 0 10px 0;
	font-size: 12px;
	font-weight: 700;
	color: #e2e8f0;
	text-align: center;
	text-transform: uppercase;
	letter-spacing: 0.8px;
}

.sahakarmi-map-legend .legend-item {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 7px;
}

.sahakarmi-map-legend .legend-item:last-child {
	margin-bottom: 0;
}

.sahakarmi-map-legend .legend-color {
	width: 16px;
	height: 16px;
	border-radius: 4px;
	border: 1.5px solid rgba(255, 255, 255, 0.15);
	flex-shrink: 0;
	box-shadow: 0 0 8px -2px currentColor;
}

.sahakarmi-map-legend .legend-label {
	font-size: 11px;
	font-weight: 500;
	color: #cbd5e1;
}

/* District name label inside polygon for current & past districts */
.sahakarmi-district-tooltip {
	background: rgba(0, 0, 0, 0.7) !important;
	border: none !important;
	border-radius: 3px !important;
	color: #ffffff !important;
	font-size: 9px !important;
	font-weight: 600 !important;
	padding: 2px 5px !important;
	box-shadow: none !important;
	pointer-events: none !important;
	text-shadow: none;
	white-space: nowrap;
	letter-spacing: 0.02em;
}

.sahakarmi-district-tooltip::before {
	display: none !important;
}

/* Responsive layouts & mobile touch optimization */
@media (max-width: 768px) {
	/* Touch target size increase for mobile zoom and reset buttons */
	.sahakarmi-leaflet-map .leaflet-control-zoom a {
		width: 42px !important;
		height: 42px !important;
		line-height: 42px !important;
		font-size: 20px !important;
	}
	.sahakarmi-reset-view {
		width: 42px;
		height: 42px;
		line-height: 42px;
		font-size: 18px;
	}

	/* Responsive Popup Width on Mobile */
	.leaflet-popup-content {
		width: 260px !important;
	}

	/* Collapsible Mobile Legend */
	.sahakarmi-map-legend.collapsible-legend {
		min-width: 130px;
		padding: 10px 14px;
		cursor: pointer;
		transition: all 0.3s ease;
	}

	.legend-toggle-btn {
		display: flex;
	}

	.legend-content {
		max-height: 0;
		overflow: hidden;
		opacity: 0;
		transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, margin-top 0.3s ease;
		margin-top: 0;
	}

	.sahakarmi-map-legend.expanded .legend-content {
		max-height: 200px;
		opacity: 1;
		margin-top: 10px;
	}

	.sahakarmi-map-legend.expanded .legend-toggle-btn .toggle-icon {
		transform: rotate(180deg);
	}
}