/**
 * Map & Marker Styles
 *
 * Leaflet map customization and marker styles.
 * This file uses plain CSS (no Tailwind @apply) for compatibility.
 *
 * @package Belekaj\Search
 * @since 2.2.0
 */

/* =================================================================
   LEAFLET MAP CUSTOMIZATION
   ================================================================= */

.search-v2__map .leaflet-control-zoom {
	border: none;
	border-radius: 0.75rem;
	overflow: hidden;
	box-shadow: 0 4px 12px rgba(28, 25, 23, 0.08);
}

.search-v2__map .leaflet-control-zoom a {
	width: 36px;
	height: 36px;
	line-height: 36px;
	color: #1c1917;
	border: none;
	background: white;
}

.search-v2__map .leaflet-control-zoom a:hover {
	background: #fafaf9;
	color: #31b7bc;
}

/* =================================================================
   MARKER WRAPPER (Leaflet DivIcon container)
   ================================================================= */

.search-v2__marker-wrapper {
	background: transparent !important;
	border: none !important;
}

/* =================================================================
   TEARDROP MARKER STYLES
   ================================================================= */

.search-v2__marker {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50% 50% 50% 0;
	transform: rotate(-45deg);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
	border: 2px solid rgba(255, 255, 255, 0.9);
	transition: transform 0.15s ease;
}

.search-v2__marker:hover {
	transform: rotate(-45deg) scale(1.1);
}

.search-v2__marker.is-highlighted {
	transform: rotate(-45deg) scale(1.25);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
	z-index: 1000 !important;
}

.search-v2__marker-icon {
	width: 16px;
	height: 16px;
	transform: rotate(45deg);
	filter: brightness(0) invert(1);
}

/* =================================================================
   CLUSTER STYLES
   ================================================================= */

.search-v2__cluster-icon {
	background: transparent;
}

.search-v2__cluster {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	font-family:
		"Plus Jakarta Sans",
		-apple-system,
		BlinkMacSystemFont,
		sans-serif;
	font-size: 0.75rem;
	font-weight: 700;
	color: white;
	background: #31b7bc;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	transition: transform 0.15s ease;
	border: 2px solid rgba(255, 255, 255, 0.9);
}

.search-v2__cluster:hover {
	transform: scale(1.1);
}

.search-v2__cluster span {
	position: relative;
	z-index: 1;
}

/* =================================================================
   MAP POPUP STYLES (Attraction Card in Leaflet Popup)
   ================================================================= */

/* Reset Leaflet popup wrapper for rich card content */
.search-v2__popup-wrapper .leaflet-popup-content-wrapper {
	padding: 0;
	border-radius: 16px;
	overflow: hidden;
	box-shadow:
		0 4px 20px rgba(0, 0, 0, 0.12),
		0 1px 4px rgba(0, 0, 0, 0.06);
}

.search-v2__popup-wrapper .leaflet-popup-content {
	margin: 0;
	padding: 0;
	width: auto !important;
}

/* Close button - positioned outside the popup card */
.leaflet-container .search-v2__popup-wrapper a.leaflet-popup-close-button {
	top: -14px;
	right: -14px;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: white;
	border-radius: 50%;
	font-size: 18px;
	color: #1c1917;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	z-index: 10;
}

.leaflet-container .search-v2__popup-wrapper a.leaflet-popup-close-button:hover {
	background: #fff;
	color: #ef4444;
}

/* Popup card sizing and overrides */
.attraction-card--popup {
	width: 280px;
	box-shadow: none;
	border-radius: 0;
}

.attraction-card--popup .attraction-card__image-wrap {
	aspect-ratio: 16 / 10;
}

.attraction-card--popup .attraction-card__title {
	font-size: 0.9375rem;
}

/* Override Leaflet default blue link color inside popup */
.attraction-card--popup .attraction-card__title a {
	color: #1c1917;
	text-decoration: none;
}

.attraction-card--popup .attraction-card__title a:hover {
	color: #31b7bc;
}

.attraction-card--popup .attraction-card__category-badge {
	color: white;
	text-decoration: none;
	padding: 4px 6px 4px 5px;
	font-size: 10px;
	border-radius: 6px;
	gap: 4px;
}

.attraction-card--popup .attraction-card__content {
	padding: 12px 14px 14px;
	gap: 10px;
}

/* Compact category badges for popup */
.attraction-card--popup .attraction-card__categories {
	gap: 4px;
}

.attraction-card--popup .attraction-card__category-icon {
	width: 12px;
	height: 12px;
}

.attraction-card--popup .attraction-card__category-icon img {
	width: 10px;
	height: 10px;
}

/* Compact meta for popup */
.attraction-card--popup .attraction-card__ages-label,
.attraction-card--popup .attraction-card__pricing-label {
	font-size: 11px;
}

.attraction-card--popup .attraction-card__age-badge {
	min-width: 30px;
	padding: 2px 7px;
	font-size: 11px;
}

.attraction-card--popup .attraction-card__info-row {
	padding-top: 8px;
}

.attraction-card--popup .attraction-card__rating-item {
	font-size: 12px;
}

.attraction-card--popup .attraction-card__rating-item svg {
	width: 14px;
	height: 14px;
}

.attraction-card--popup .attraction-card__location-city {
	font-size: 12px;
}

.attraction-card--popup .attraction-card__location-region {
	font-size: 10px;
}

/* Favorite button: slightly smaller for popup */
.attraction-card--popup .attraction-card__favorite {
	width: 32px;
	height: 32px;
	top: 8px;
	right: 8px;
}

.attraction-card--popup .attraction-card__favorite svg {
	width: 16px;
	height: 16px;
}

/* Disable hover effects inside popup */
.attraction-card--popup:hover {
	transform: none;
	box-shadow: none;
}

.attraction-card--popup::before {
	display: none;
}

.attraction-card--popup:hover .attraction-card__img {
	transform: none;
}

/* =================================================================
   MAP CONTAINER
   ================================================================= */

.search-v2__map-container {
	position: relative;
}

/* =================================================================
   MAP CONTROLS & TOGGLE
   ================================================================= */

.search-v2__map-controls {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 0.75rem 1rem;
	background: white;
	border-top: 1px solid #e7e5e4;
	display: flex;
	align-items: center;
	gap: 1rem;
	z-index: 1000;
}

.search-v2__map-toggle {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	cursor: pointer;
}

.search-v2__map-toggle input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.search-v2__map-toggle-slider {
	position: relative;
	width: 44px;
	height: 24px;
	background: #e7e5e4;
	border-radius: 9999px;
	transition: background 0.15s ease;
}

.search-v2__map-toggle-slider::after {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 20px;
	height: 20px;
	background: white;
	border-radius: 50%;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
	transition: transform 0.15s ease-out;
}

.search-v2__map-toggle input:checked + .search-v2__map-toggle-slider {
	background: #31b7bc;
}

.search-v2__map-toggle input:checked + .search-v2__map-toggle-slider::after {
	transform: translateX(20px);
}

.search-v2__map-toggle input:focus-visible + .search-v2__map-toggle-slider {
	box-shadow: 0 0 0 3px rgba(49, 183, 188, 0.3);
}

.search-v2__map-toggle-label {
	font-size: 0.8125rem;
	font-weight: 500;
	color: #1c1917;
}

/* =================================================================
   MAP LOADING
   ================================================================= */

.search-v2__map-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.8);
	z-index: 1001;
}

.search-v2__map-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid #e7e5e4;
	border-top-color: #31b7bc;
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

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

@keyframes map-loader-fadein {
	from {
		opacity: 0;
		transform: translate(-50%, -50%) scale(0.92);
	}

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

.search-v2__map-loading-badge {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	align-items: center;
	gap: 8px;
	background: rgba(255, 255, 255, 0.92);
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 20px;
	padding: 8px 14px;
	font-size: 13px;
	font-weight: 500;
	color: #44403c;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
	z-index: 1001;
	pointer-events: none;
	animation: map-loader-fadein 0.15s ease-out forwards;
}

/* =================================================================
   ACCESSIBILITY
   ================================================================= */

@media (prefers-reduced-motion: reduce) {
	.search-v2__marker,
	.search-v2__cluster,
	.search-v2__map-toggle-slider,
	.search-v2__map-toggle-slider::after,
	.search-v2__map-spinner,
	.search-v2__map-loading-badge {
		transition: none;
		animation: none;
	}
}

/* =================================================================
   SWIMMING LOCATION MARKERS
   ================================================================= */

.search-v2__marker--swimming-location {
	background-color: #2563eb;
	border-color: #1d4ed8;
}

/* =================================================================
   VOIVODESHIP REGION CLUSTER MARKERS (zoom < 8)
   ================================================================= */

.region-cluster-marker {
	background: transparent !important;
	border: none !important;
}

.region-cluster-marker__inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	background: var(--color-primary, #31b7bc);
	color: white;
	border-radius: 8px;
	padding: 6px 12px;
	font-family:
		"Plus Jakarta Sans",
		-apple-system,
		BlinkMacSystemFont,
		sans-serif;
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
	cursor: pointer;
	min-width: 80px;
	text-align: center;
	transition: transform 0.15s ease;
}

.region-cluster-marker__inner:hover {
	transform: scale(1.05);
}

.region-cluster-marker__count {
	font-size: 18px;
	line-height: 1.2;
}

.region-cluster-marker__name {
	font-size: 11px;
	font-weight: 400;
	opacity: 0.9;
}

@media (prefers-reduced-motion: reduce) {
	.region-cluster-marker__inner {
		transition: none;
	}
}

/* =================================================================
   TOUCH/SCROLL ISOLATION BETWEEN RESULTS AND MAP
   ================================================================= */

/* Stop scroll chaining from results to body/map (desktop + mobile) */
.search-v2__results {
	overscroll-behavior: contain;
}

@media (width <= 1279px) {
	/* Let Leaflet fully control touch on mobile map overlay */
	.search-v2__map-container.is-visible {
		touch-action: none;
	}

	/* Hide results when map tab is active (is-visible removed but no display:none rule existed) */
	.search-v2__results:not(.is-visible) {
		display: none;
	}
}
