/* ==========================================================================
   Interactive Event Map - Premium Frontend Styles
   ========================================================================== */

:root {
	--iem-primary: #6366f1;
	--iem-primary-hover: #4f46e5;
	--iem-accent: #ec4899;
	--iem-card-bg: #ffffff;
	--iem-text: #1e293b;
	--iem-text-muted: #64748b;
	--iem-border: #e2e8f0;
	--iem-radius: 16px;
	--iem-font: inherit;
	--iem-height: 580px;
	--iem-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
	--iem-shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
	--iem-shadow-lg: 0 20px 30px -10px rgba(15, 23, 42, 0.15);
}

.iem-container {
	font-family: var(--iem-font) !important;
	color: var(--iem-text);
	width: 100%;
	max-width: 100%;
	margin: 20px 0;
	position: relative;
	box-sizing: border-box;
}

.iem-container *,
.iem-container *::before,
.iem-container *::after {
	box-sizing: border-box;
	font-family: var(--iem-font) !important;
}

/* --------------------------------------------------------------------------
   Controls Bar (Filter Pills & Search Box)
   -------------------------------------------------------------------------- */
.iem-controls-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
}

.iem-search-box {
	position: relative;
	flex: 1 1 260px;
	max-width: 380px;
}

.iem-search-icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	font-size: 15px;
	pointer-events: none;
	opacity: 0.6;
}

.iem-search-input {
	width: 100% !important;
	padding: 10px 36px 10px 40px !important;
	background: #ffffff !important;
	border: 1.5px solid var(--iem-border) !important;
	border-radius: 50px !important;
	font-size: 14px !important;
	color: var(--iem-text) !important;
	outline: none !important;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
	box-shadow: var(--iem-shadow-sm) !important;
}

.iem-search-input:focus {
	border-color: var(--iem-primary) !important;
	box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15) !important;
}

.iem-search-clear {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	background: #cbd5e1;
	color: #ffffff;
	border: none;
	border-radius: 50%;
	width: 20px;
	height: 20px;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s;
}

.iem-search-clear:hover {
	background: #94a3b8;
}

.iem-filter-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

.iem-pill {
	background: #ffffff;
	border: 1.5px solid var(--iem-border);
	color: var(--iem-text);
	padding: 7px 16px;
	border-radius: 50px;
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	box-shadow: var(--iem-shadow-sm);
	display: inline-flex;
	align-items: center;
	gap: 6px;
	user-select: none;
}

.iem-pill:hover {
	border-color: var(--iem-primary);
	transform: translateY(-2px);
	box-shadow: var(--iem-shadow-md);
}

.iem-pill.active {
	background: var(--iem-primary);
	border-color: var(--iem-primary);
	color: #ffffff;
	box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
	transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Main Map Area & Layouts
   -------------------------------------------------------------------------- */
.iem-main-area {
	display: flex;
	gap: 16px;
	height: var(--iem-height);
	position: relative;
	border-radius: var(--iem-radius);
	overflow: hidden;
	box-shadow: var(--iem-shadow-md);
	background: #f8fafc;
	border: 1px solid var(--iem-border);
}

.iem-map-canvas {
	flex: 1;
	height: 100%;
	min-height: 100%;
	z-index: 1;
	background: #e2e8f0;
}

/* Sidebar Layout Mode */
.iem-layout-sidebar .iem-cards-panel {
	width: 360px;
	max-width: 40%;
	background: #ffffff;
	display: flex;
	flex-direction: column;
	border-left: 1px solid var(--iem-border);
	z-index: 2;
}

.iem-cards-header {
	padding: 14px 18px;
	border-bottom: 1px solid var(--iem-border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: #ffffff;
}

.iem-count-badge {
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	background: #f1f5f9;
	color: var(--iem-text-muted);
	padding: 4px 10px;
	border-radius: 20px;
}

.iem-cards-list {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}

/* Bottom Slider Layout Mode */
.iem-layout-bottom_slider .iem-main-area {
	flex-direction: column;
}

.iem-layout-bottom_slider .iem-map-canvas {
	height: calc(100% - 170px);
}

.iem-layout-bottom_slider .iem-cards-panel {
	height: 170px;
	width: 100%;
	background: #ffffff;
	border-top: 1px solid var(--iem-border);
	z-index: 2;
	overflow: hidden;
}

.iem-layout-bottom_slider .iem-cards-header {
	display: none;
}

.iem-layout-bottom_slider .iem-cards-list {
	flex-direction: row;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 12px;
	gap: 14px;
}

.iem-layout-bottom_slider .iem-event-card {
	min-width: 280px;
	max-width: 300px;
	flex-shrink: 0;
}

/* Map Only Layout */
.iem-layout-map_only .iem-cards-panel {
	display: none;
}

/* --------------------------------------------------------------------------
   Event Cards (Sidebar / Slider)
   -------------------------------------------------------------------------- */
.iem-event-card {
	background: var(--iem-card-bg);
	border: 1.5px solid var(--iem-border);
	border-radius: calc(var(--iem-radius) * 0.75);
	padding: 14px;
	cursor: pointer;
	transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	box-shadow: var(--iem-shadow-sm);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.iem-event-card:hover {
	border-color: var(--iem-primary);
	transform: translateY(-3px);
	box-shadow: var(--iem-shadow-md);
}

.iem-event-card.active {
	border-color: var(--iem-primary);
	background: #fdfefe;
	box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), var(--iem-shadow-md);
}

.iem-card-top {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
}

.iem-card-title {
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	color: var(--iem-text);
	line-height: 1.3;
}

.iem-card-emoji {
	font-size: 20px;
	flex-shrink: 0;
}

.iem-card-meta {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 12.5px;
	color: var(--iem-text-muted);
}

.iem-card-meta-item {
	display: flex;
	align-items: center;
	gap: 6px;
}

.iem-card-badge {
	align-self: flex-start;
	font-size: 11px;
	font-weight: 700;
	color: var(--iem-accent);
	background: rgba(236, 72, 153, 0.1);
	padding: 3px 8px;
	border-radius: 12px;
	text-transform: capitalize;
}

.iem-card-footer {
	margin-top: 4px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.iem-card-btn {
	font-size: 12px;
	font-weight: 600;
	padding: 6px 12px;
	border-radius: 50px;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 4px;
	transition: all 0.2s;
	border: none;
	cursor: pointer;
}

.iem-card-btn-primary {
	background: var(--iem-primary);
	color: #ffffff;
}

.iem-card-btn-primary:hover {
	background: var(--iem-primary-hover);
}

.iem-card-btn-link {
	background: #f1f5f9;
	color: var(--iem-text);
}

.iem-card-btn-link:hover {
	background: #e2e8f0;
}

/* --------------------------------------------------------------------------
   Fun Custom Markers & Pin Animations
   -------------------------------------------------------------------------- */
.iem-custom-pin {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	position: relative;
	transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.iem-pin-wrapper {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
}

/* Bouncy Teardrop Pin */
.iem-pin-body {
	width: 38px;
	height: 38px;
	border-radius: 50% 50% 50% 0;
	background: var(--pin-color, #ff4757);
	transform: rotate(-45deg);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.iem-pin-body-inner {
	transform: rotate(45deg);
	font-size: 18px;
	line-height: 1;
	user-select: none;
}

/* Hover Wobble & Bounce Animation */
.iem-custom-pin:hover .iem-pin-body {
	transform: rotate(-45deg) scale(1.18);
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
	animation: iemWobble 0.6s ease-in-out;
}

@keyframes iemWobble {
	0%, 100% { transform: rotate(-45deg) scale(1.18); }
	30% { transform: rotate(-55deg) scale(1.22); }
	60% { transform: rotate(-35deg) scale(1.2); }
}

/* Radar Pulse Halo for Active / Featured Pin */
.iem-custom-pin.active .iem-pin-body {
	transform: rotate(-45deg) scale(1.25);
}

.iem-custom-pin.active::after {
	content: '';
	position: absolute;
	bottom: -4px;
	left: 50%;
	transform: translateX(-50%);
	width: 24px;
	height: 10px;
	background: rgba(0,0,0,0.3);
	border-radius: 50%;
	filter: blur(2px);
	z-index: -1;
}

.iem-pulse-ring {
	position: absolute;
	top: -6px;
	left: -6px;
	right: -6px;
	bottom: -6px;
	border-radius: 50%;
	border: 3px solid var(--pin-color, #ff4757);
	animation: iemPulse 1.8s infinite cubic-bezier(0.25, 0.46, 0.45, 0.94);
	opacity: 0;
	pointer-events: none;
}

@keyframes iemPulse {
	0% {
		transform: scale(0.6);
		opacity: 0.8;
	}
	100% {
		transform: scale(1.8);
		opacity: 0;
	}
}

/* --------------------------------------------------------------------------
   Popups (Rich & Playful Leaflet Overlay)
   -------------------------------------------------------------------------- */
.leaflet-popup-content-wrapper {
	background: var(--iem-card-bg) !important;
	border-radius: var(--iem-radius) !important;
	padding: 0 !important;
	box-shadow: var(--iem-shadow-lg) !important;
	overflow: hidden !important;
	border: 1px solid var(--iem-border) !important;
}

.leaflet-popup-content {
	margin: 0 !important;
	line-height: 1.4 !important;
	width: 290px !important;
}

.leaflet-popup-tip {
	background: var(--iem-card-bg) !important;
}

.iem-popup-card {
	display: flex;
	flex-direction: column;
	font-family: var(--iem-font);
	color: var(--iem-text);
}

.iem-popup-image {
	width: 100%;
	height: 130px;
	object-fit: cover;
	display: block;
}

.iem-popup-body {
	padding: 14px 16px 16px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.iem-popup-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
}

.iem-popup-title {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	color: var(--iem-text);
	line-height: 1.25;
}

.iem-popup-meta {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 13px;
	color: var(--iem-text-muted);
}

.iem-popup-desc {
	font-size: 12.5px;
	color: var(--iem-text);
	line-height: 1.4;
	margin: 2px 0 0;
}

.iem-popup-actions {
	display: flex;
	gap: 8px;
	margin-top: 6px;
}

.iem-popup-btn {
	flex: 1;
	text-align: center;
	padding: 8px 12px;
	font-size: 12.5px;
	font-weight: 600;
	border-radius: 50px;
	text-decoration: none !important;
	transition: all 0.2s;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
}

.iem-popup-btn-primary {
	background: var(--iem-primary);
	color: #ffffff !important;
}

.iem-popup-btn-primary:hover {
	background: var(--iem-primary-hover);
}

.iem-popup-btn-secondary {
	background: #f1f5f9;
	color: var(--iem-text) !important;
	border: 1px solid var(--iem-border);
}

.iem-popup-btn-secondary:hover {
	background: #e2e8f0;
}

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */
.iem-no-results {
	padding: 40px 20px;
	text-align: center;
	color: var(--iem-text-muted);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
}

.iem-no-results-icon {
	font-size: 32px;
}

/* --------------------------------------------------------------------------
   Mobile View Switcher & Responsive Breakpoints
   -------------------------------------------------------------------------- */
.iem-mobile-view-bar {
	display: none; /* Hidden on desktop */
}

@media (max-width: 768px) {
	.iem-container {
		margin: 10px 0;
	}

	/* Controls Bar */
	.iem-controls-bar {
		flex-direction: column;
		align-items: stretch;
		gap: 10px;
		margin-bottom: 12px;
	}

	.iem-search-box {
		max-width: 100%;
		flex: 1 1 auto;
	}

	.iem-search-input {
		font-size: 15px !important; /* Prevents iOS auto-zoom on input focus */
		padding: 12px 38px 12px 42px !important;
		min-height: 46px;
	}

	.iem-filter-pills {
		overflow-x: auto;
		flex-wrap: nowrap;
		padding-bottom: 6px;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		-ms-overflow-style: none;
	}

	.iem-filter-pills::-webkit-scrollbar {
		display: none;
	}

	.iem-pill {
		flex-shrink: 0;
		padding: 8px 16px;
		font-size: 14px;
		min-height: 40px;
	}

	/* Mobile Floating Map/List Switcher */
	.iem-mobile-view-bar {
		display: flex;
		background: rgba(255, 255, 255, 0.92);
		backdrop-filter: blur(12px);
		-webkit-backdrop-filter: blur(12px);
		border: 1px solid var(--iem-border);
		border-radius: 50px;
		padding: 4px;
		box-shadow: var(--iem-shadow-md);
		margin-bottom: 10px;
		gap: 4px;
	}

	.iem-mobile-btn {
		flex: 1;
		border: none;
		background: transparent;
		color: var(--iem-text-muted);
		padding: 9px 14px;
		border-radius: 50px;
		font-size: 13.5px;
		font-weight: 700;
		cursor: pointer;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		gap: 6px;
		transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
		min-height: 40px;
	}

	.iem-mobile-btn.active {
		background: var(--iem-primary);
		color: #ffffff;
		box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
	}

	/* Main Area on Mobile */
	.iem-main-area {
		height: auto;
		min-height: 0;
		max-height: none;
		position: relative;
		border: none;
		box-shadow: none;
		background: transparent;
	}

	/* Map Mode on Mobile (Default) */
	.iem-container:not(.iem-mobile-show-list) .iem-main-area {
		height: 400px; /* fixed size for map */
	}

	.iem-container:not(.iem-mobile-show-list) .iem-map-canvas {
		width: 100% !important;
		height: 100% !important;
		display: block !important;
		border-radius: var(--iem-radius);
		border: 1px solid var(--iem-border);
		box-shadow: var(--iem-shadow-md);
	}

	/* Hide Cards in Map Mode for Simplified Mobile View */
	.iem-container:not(.iem-mobile-show-list) .iem-cards-panel {
		display: none !important;
	}

	/* List Mode on Mobile */
	.iem-container.iem-mobile-show-list .iem-map-canvas {
		display: none !important;
	}

	.iem-container.iem-mobile-show-list .iem-cards-panel {
		width: 100% !important;
		max-width: 100% !important;
		height: auto !important;
		border: none !important;
		display: flex !important;
		background: transparent;
	}

	.iem-container.iem-mobile-show-list .iem-cards-list {
		flex-direction: column;
		overflow-y: visible;
		gap: 12px;
		padding: 4px;
	}

	.iem-container.iem-mobile-show-list .iem-event-card {
		width: 100%;
		max-width: 100%;
		min-width: 100%;
	}

	/* Mobile Popups */
	.leaflet-popup-content {
		width: calc(100vw - 50px) !important;
		max-width: 290px !important;
	}

	.iem-popup-btn {
		min-height: 42px;
		font-size: 13.5px;
	}

	/* Marker Touch Target Area */
	.iem-custom-pin {
		touch-action: manipulation;
	}

	.iem-custom-pin::before {
		content: '';
		position: absolute;
		top: -10px;
		left: -10px;
		right: -10px;
		bottom: -10px;
	}
}
