:root {
	--medisync-popup-pink: #ef3fa5;
	--medisync-popup-blue: #0f63ff;
	--medisync-popup-navy: #06184f;
}

.medisync-pharmacy-map-popup {
	position: relative;
	width: min(19rem, calc(100vw - 3.5rem));
	min-width: min(17rem, calc(100vw - 3.5rem));
	max-width: 19rem;
	border-radius: 1rem;
	background: rgba(255, 255, 255, 0.99);
	color: var(--medisync-popup-navy);
	font-family: Inter, "Space Grotesk", Poppins, system-ui, sans-serif;
	line-height: 1.35;
	box-shadow: 0 18px 38px rgba(61, 89, 132, 0.2), 0 0 22px rgba(239, 63, 165, 0.12);
	isolation: isolate;
	transition:
		width 240ms cubic-bezier(0.22, 1, 0.36, 1),
		min-width 240ms cubic-bezier(0.22, 1, 0.36, 1),
		max-width 240ms cubic-bezier(0.22, 1, 0.36, 1),
		border-radius 240ms ease,
		box-shadow 240ms ease;
}

.medisync-pharmacy-map-popup button {
	font-family: inherit;
}

.medisync-pharmacy-map-popup__close {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	z-index: 5;
	display: inline-grid;
	width: 2.5rem;
	height: 2.5rem;
	place-items: center;
	padding: 0;
	border: 1px solid rgba(6, 24, 79, 0.14);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.94);
	box-shadow: 0 7px 16px rgba(6, 24, 79, 0.18);
	color: #0f172a;
	font-size: 1.65rem;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	transition: opacity 180ms ease, visibility 180ms ease, transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.medisync-pharmacy-map-popup__close:hover,
.medisync-pharmacy-map-popup__close:focus-visible {
	transform: scale(1.05);
	background: #fff;
	box-shadow: 0 8px 19px rgba(239, 63, 165, 0.25);
	outline: 3px solid rgba(239, 63, 165, 0.22);
	outline-offset: 1px;
}

.medisync-pharmacy-map-popup__cover {
	position: relative;
	height: 8.1rem;
	overflow: hidden;
	border-radius: 1rem 1rem 0 0;
	background: linear-gradient(135deg, #d9ecff, #fce5f2);
	opacity: 1;
	transition: height 240ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease;
}

.medisync-pharmacy-map-popup__cover::after {
	position: absolute;
	inset: auto 0 0;
	height: 3.5rem;
	background: linear-gradient(180deg, transparent, rgba(6, 24, 79, 0.24));
	content: "";
	pointer-events: none;
}

.medisync-pharmacy-map-popup__cover-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.medisync-pharmacy-map-popup__body {
	position: relative;
	padding: 0.82rem 0.9rem 0.9rem;
	transition: padding 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.medisync-pharmacy-map-popup__heading {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.8rem;
}

.medisync-pharmacy-map-popup__title {
	min-width: 0;
}

.medisync-pharmacy-map-popup__name-row {
	display: flex;
	min-width: 0;
	align-items: flex-start;
	gap: 0.38rem;
}

.medisync-pharmacy-map-popup__owner-icon {
	display: none;
	flex: 0 0 auto;
	margin-top: 0.08rem;
	color: #ff3ca6;
	font-size: 1rem;
	filter: drop-shadow(0 0 5px rgba(255, 60, 166, 0.3));
}

.medisync-pharmacy-map-popup__owner-icon[hidden],
.medisync-pharmacy-map-popup__claimed-label[hidden] {
	display: none !important;
}

.medisync-pharmacy-map-popup__claimed-label {
	display: none;
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.medisync-pharmacy-map-popup__name {
	display: block;
	margin: 0;
	color: var(--medisync-popup-navy);
	font-size: 0.98rem;
	font-weight: 800;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.medisync-pharmacy-map-popup__rating {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.28rem;
	margin-top: 0.28rem;
	color: #526487;
	font-size: 0.72rem;
	font-weight: 700;
}

.medisync-pharmacy-map-popup__rating[hidden],
.medisync-pharmacy-map-popup__directions[hidden],
.medisync-pharmacy-map-popup__license[hidden],
.medisync-pharmacy-map-popup__meta[hidden] {
	display: none !important;
}

.medisync-pharmacy-map-popup__stars {
	display: inline-flex;
	align-items: center;
	gap: 0.04rem;
	color: #c9d4e5;
	font-size: 0.84rem;
	line-height: 1;
}

.medisync-pharmacy-map-popup__stars .is-filled {
	color: #f6b800;
}

.medisync-pharmacy-map-popup__rating-count {
	color: #7182a0;
	font-weight: 600;
}

.medisync-pharmacy-map-popup__directions {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 0.3rem;
	min-height: 2.35rem;
	padding: 0.56rem 0.72rem;
	border: 1px solid rgba(15, 99, 255, 0.2);
	border-radius: 0.72rem;
	background: #eaf3ff;
	color: var(--medisync-popup-navy);
	font-size: 0.72rem;
	font-weight: 800;
	line-height: 1;
	cursor: pointer;
	transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.medisync-pharmacy-map-popup__directions-icon {
	font-size: 0.95rem;
}

.medisync-pharmacy-map-popup__directions:hover,
.medisync-pharmacy-map-popup__directions:focus-visible {
	transform: translateY(-1px);
	background: #dcecff;
	box-shadow: 0 8px 18px rgba(15, 99, 255, 0.18);
	outline: 3px solid rgba(15, 99, 255, 0.16);
	outline-offset: 1px;
}

.medisync-pharmacy-map-popup__directions:disabled {
	cursor: not-allowed;
	opacity: 0.48;
}

.medisync-pharmacy-map-popup__address-wrap {
	position: relative;
	margin-top: 0.62rem;
}

.medisync-pharmacy-map-popup__address {
	display: flex;
	width: 100%;
	min-width: 0;
	align-items: center;
	gap: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #526487;
	font-size: 0.75rem;
	line-height: 1.35;
	text-align: left;
	cursor: help;
}

.medisync-pharmacy-map-popup__address:focus-visible {
	border-radius: 0.35rem;
	outline: 3px solid rgba(15, 99, 255, 0.17);
	outline-offset: 2px;
}

.medisync-pharmacy-map-popup__address-text {
	display: block;
	min-width: 0;
	overflow: hidden;
	font-style: italic;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.medisync-pharmacy-map-popup__address-wrap.is-expanded .medisync-pharmacy-map-popup__address {
	align-items: flex-start;
	cursor: zoom-out;
}

.medisync-pharmacy-map-popup__address-wrap.is-expanded .medisync-pharmacy-map-popup__address-text {
	overflow: visible;
	text-overflow: clip;
	white-space: normal;
}

.medisync-pharmacy-map-popup__address-tooltip {
	position: absolute;
	top: calc(100% + 0.35rem);
	left: 0;
	z-index: 8;
	display: block;
	width: 100%;
	padding: 0.48rem 0.58rem;
	border: 1px solid rgba(15, 99, 255, 0.16);
	border-radius: 0.55rem;
	background: rgba(6, 24, 79, 0.96);
	box-shadow: 0 8px 22px rgba(6, 24, 79, 0.22);
	color: #fff;
	font-size: 0.7rem;
	font-style: italic;
	line-height: 1.4;
	opacity: 0;
	pointer-events: none;
	transform: translateY(-0.2rem);
	transition: opacity 130ms ease, transform 130ms ease;
}

.medisync-pharmacy-map-popup__address-wrap:hover:not(.is-expanded) .medisync-pharmacy-map-popup__address-tooltip,
.medisync-pharmacy-map-popup__address-wrap:focus-within:not(.is-expanded) .medisync-pharmacy-map-popup__address-tooltip {
	opacity: 1;
	transform: translateY(0);
}

.medisync-pharmacy-map-popup__license {
	margin: 0.45rem 0 0;
	color: #7a88a1;
	font-size: 0.68rem;
	font-weight: 600;
	line-height: 1.3;
}

.medisync-pharmacy-map-popup__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.38rem;
	margin-top: 0.72rem;
}

.medisync-pharmacy-map-popup__status {
	display: inline-flex;
	align-items: center;
	gap: 0.32rem;
	min-height: 1.55rem;
	padding: 0.27rem 0.5rem;
	border: 1px solid rgba(82, 100, 135, 0.18);
	border-radius: 999px;
	background: rgba(82, 100, 135, 0.07);
	color: #526487;
	font-size: 0.66rem;
	font-weight: 800;
	line-height: 1.15;
}

.medisync-pharmacy-map-popup__status.is-open {
	border-color: rgba(10, 169, 135, 0.2);
	background: rgba(10, 169, 135, 0.09);
	color: #087f68;
}

.medisync-pharmacy-map-popup__status.is-closed {
	border-color: rgba(239, 47, 99, 0.2);
	background: rgba(239, 47, 99, 0.08);
	color: #c1154b;
}

.medisync-pharmacy-map-popup__status.is-pending {
	border-color: rgba(193, 125, 0, 0.2);
	background: rgba(246, 184, 0, 0.1);
	color: #8f6400;
}

/* Application and dashboard maps open a compact preview and expand the same DOM card on click. */
.medisync-pharmacy-map-popup[data-presentation="preview"] {
	width: min(15.5rem, calc(100vw - 3.5rem));
	min-width: min(13.75rem, calc(100vw - 3.5rem));
	max-width: 15.5rem;
	border-radius: 0.82rem;
	box-shadow: 0 12px 28px rgba(61, 89, 132, 0.18), 0 0 16px rgba(239, 63, 165, 0.1);
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__close {
	display: none !important;
	opacity: 0;
	pointer-events: none;
	transform: scale(0.82);
	visibility: hidden;
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__cover {
	height: 0;
	opacity: 0;
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__body {
	max-height: none;
	overflow: visible;
	padding: 0.66rem 0.74rem 0.7rem;
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__heading {
	display: flex;
	gap: 0;
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__title {
	width: 100%;
}

.medisync-pharmacy-map-popup--application[data-presentation="preview"] .medisync-pharmacy-map-popup__owner-icon:not([hidden]) {
	display: inline-block;
}

.medisync-pharmacy-map-popup--application[data-presentation="preview"] .medisync-pharmacy-map-popup__claimed-label:not([hidden]) {
	display: block;
}

.medisync-pharmacy-map-popup--application[data-presentation="full"] .medisync-pharmacy-map-popup__owner-icon,
.medisync-pharmacy-map-popup--application[data-presentation="full"] .medisync-pharmacy-map-popup__claimed-label {
	display: none !important;
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__rating,
.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__directions,
.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__license,
.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__meta {
	max-width: 0;
	max-height: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border-width: 0;
	opacity: 0;
	overflow: hidden;
	pointer-events: none;
	transform: translateY(-0.28rem);
	visibility: hidden;
}

.medisync-pharmacy-map-popup__rating,
.medisync-pharmacy-map-popup__directions,
.medisync-pharmacy-map-popup__license,
.medisync-pharmacy-map-popup__meta {
	transition:
		max-width 240ms cubic-bezier(0.22, 1, 0.36, 1),
		max-height 240ms cubic-bezier(0.22, 1, 0.36, 1),
		margin 240ms cubic-bezier(0.22, 1, 0.36, 1),
		padding 240ms cubic-bezier(0.22, 1, 0.36, 1),
		opacity 160ms ease 60ms,
		transform 240ms cubic-bezier(0.22, 1, 0.36, 1),
		visibility 0ms linear 0ms;
}

.medisync-pharmacy-map-popup__rating {
	max-width: 14rem;
	max-height: 3rem;
}

.medisync-pharmacy-map-popup__directions {
	max-width: 8rem;
	max-height: 4rem;
}

.medisync-pharmacy-map-popup__license,
.medisync-pharmacy-map-popup__meta {
	max-width: 19rem;
	max-height: 3rem;
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__address-wrap {
	margin-top: 0.1rem;
}

.medisync-pharmacy-map-popup[data-presentation="preview"] .medisync-pharmacy-map-popup__address {
	font-size: 0.72rem;
}

/* Provider shells are scoped so non-pharmacy location popups keep their native styling. */
.gm-style .gm-style-iw-c:has(.medisync-pharmacy-map-popup) {
	padding: 0 !important;
	border: 1px solid rgba(190, 207, 232, 0.86) !important;
	border-radius: 1rem !important;
	background: transparent !important;
	box-shadow: none !important;
	max-height: none !important;
}

.gm-style .gm-style-iw-d:has(.medisync-pharmacy-map-popup) {
	overflow: visible !important;
	height: auto !important;
	max-height: none !important;
}

.gm-style .gm-style-iw-t:has(.medisync-pharmacy-map-popup) > .gm-style-iw-tc::after {
	background: rgba(255, 255, 255, 0.98);
}

.medisync-pharmacy-popup-host.leaflet-popup {
	margin-bottom: 20px;
}

.medisync-pharmacy-popup-host .leaflet-popup-content-wrapper {
	overflow: visible;
	padding: 0;
	border: 1px solid rgba(190, 207, 232, 0.86);
	border-radius: 1rem;
	background: transparent;
	box-shadow: none;
}

.medisync-pharmacy-popup-host .leaflet-popup-content {
	width: auto !important;
	margin: 0;
	overflow: visible;
}

.medisync-pharmacy-popup-host .leaflet-popup-tip {
	background: rgba(255, 255, 255, 0.99);
	box-shadow: 2px 2px 5px rgba(61, 89, 132, 0.14);
}

@media (max-width: 640px) {
	.medisync-pharmacy-map-popup {
		width: min(17.5rem, calc(100vw - 4rem));
		min-width: 0;
		max-width: calc(100vw - 4rem);
		max-height: min(17rem, calc(100dvh - 2rem));
	}

	.medisync-pharmacy-map-popup__cover {
		height: 5.5rem;
	}

	.medisync-pharmacy-map-popup__body {
		max-height: min(11.5rem, calc(100dvh - 7.5rem));
		overflow-x: hidden;
		overflow-y: auto;
		padding: 0.76rem 0.8rem 0.82rem;
		scrollbar-color: rgba(15, 99, 255, 0.32) transparent;
		scrollbar-width: thin;
	}

	.medisync-pharmacy-map-popup__heading {
		gap: 0.5rem;
	}

	.medisync-pharmacy-map-popup__directions {
		min-height: 2.2rem;
		padding: 0.5rem 0.6rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.medisync-pharmacy-map-popup,
	.medisync-pharmacy-map-popup *,
	.medisync-pharmacy-map-popup *::before,
	.medisync-pharmacy-map-popup *::after {
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
	}
}
