/**
 * Manta Distributors Map — frontend styles.
 * Light theme matching montecchio.manta-web.com:
 * primary #020673, accent #C00100, light bg #E7E9F3.
 *
 * NOTE: selectors on interactive elements are intentionally high-specificity
 * (.mdm-wrap button.x / .mdm-wrap input.x) — Hello Elementor's reset.css styles
 * [type=button] / input[type=text] globally (#c36 borders, inline-block display)
 * and would otherwise override the plugin look.
 */

.mdm-wrap {
	--mdm-primary: #020673;
	--mdm-primary-hover: #0a0f9a;
	--mdm-accent: #C00100;
	--mdm-bg: #E7E9F3;
	--mdm-white: #ffffff;
	--mdm-border: #d6d9e6;
	--mdm-text: #1a1a2e;
	--mdm-muted: #5a5e75;
	--mdm-radius: 12px;

	/* direction comes from the dir attribute set by the shortcode (rtl/ltr) */
	display: grid;
	grid-template-columns: 400px 1fr;
	gap: 0;
	height: 680px;
	max-height: 85vh;
	border-radius: var(--mdm-radius);
	overflow: hidden;
	border: 1px solid var(--mdm-border);
	background: var(--mdm-white);
	box-shadow: 0 8px 32px rgba(2, 6, 115, 0.08);
	font-size: 15px;
	color: var(--mdm-text);
	position: relative;
}

/* ---------- Sidebar ---------- */

.mdm-sidebar {
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: var(--mdm-white);
	border-inline-end: 1px solid var(--mdm-border);
}

.mdm-sidebar__header {
	padding: 18px 18px 14px;
	border-bottom: 1px solid var(--mdm-border);
	background: var(--mdm-white);
}

/* ---------- Search ---------- */

.mdm-search {
	position: relative;
	margin-bottom: 12px;
}

.mdm-search__icon {
	position: absolute;
	inset-inline-start: 14px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--mdm-muted);
	pointer-events: none;
	z-index: 1;
}

.mdm-wrap input.mdm-search__input {
	width: 100%;
	padding: 11px 14px;
	padding-inline-start: 42px;
	border: 1px solid var(--mdm-border);
	border-radius: 10px;
	background: var(--mdm-bg);
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	color: var(--mdm-text);
	outline: none;
	box-shadow: none;
	transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
	box-sizing: border-box;
	margin: 0;
}

.mdm-wrap input.mdm-search__input:focus {
	border-color: var(--mdm-primary);
	box-shadow: 0 0 0 3px rgba(2, 6, 115, 0.12);
	background: var(--mdm-white);
	outline: none;
}

.mdm-wrap input.mdm-search__input::placeholder {
	color: #8a8ea3;
}

/* ---------- Region filters: segmented control ---------- */

.mdm-filters {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	gap: 4px;
	background: var(--mdm-bg);
	border-radius: 999px;
	padding: 4px;
	margin-bottom: 12px;
}

.mdm-wrap button.mdm-filter {
	appearance: none;
	-webkit-appearance: none;
	display: block;
	width: 100%;
	padding: 8px 2px;
	border: none;
	border-radius: 999px;
	background: transparent;
	color: var(--mdm-muted);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	white-space: nowrap;
	cursor: pointer;
	margin: 0;
	box-shadow: none;
	transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.mdm-wrap button.mdm-filter:hover,
.mdm-wrap button.mdm-filter:focus {
	background: rgba(255, 255, 255, 0.75);
	color: var(--mdm-primary);
	outline: none;
	text-decoration: none;
}

.mdm-wrap button.mdm-filter.is-active,
.mdm-wrap button.mdm-filter.is-active:hover,
.mdm-wrap button.mdm-filter.is-active:focus {
	background: var(--mdm-primary);
	color: var(--mdm-white);
	box-shadow: 0 2px 8px rgba(2, 6, 115, 0.35);
}

/* ---------- Geolocate button ---------- */

.mdm-wrap button.mdm-geolocate {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	padding: 11px 16px;
	border: none;
	border-radius: 10px;
	background: var(--mdm-primary);
	color: var(--mdm-white);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	cursor: pointer;
	margin: 0;
	box-shadow: 0 4px 14px rgba(2, 6, 115, 0.22);
	transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.mdm-wrap button.mdm-geolocate:hover,
.mdm-wrap button.mdm-geolocate:focus {
	background: var(--mdm-primary-hover);
	color: var(--mdm-white);
	box-shadow: 0 6px 18px rgba(2, 6, 115, 0.3);
	transform: translateY(-1px);
	outline: none;
	text-decoration: none;
}

.mdm-wrap button.mdm-geolocate:active {
	transform: translateY(0);
	box-shadow: 0 3px 10px rgba(2, 6, 115, 0.25);
}

.mdm-wrap button.mdm-geolocate.is-loading {
	opacity: 0.7;
	pointer-events: none;
}

.mdm-count {
	margin: 12px 2px 0;
	font-size: 13px;
	color: var(--mdm-muted);
}

/* ---------- List ---------- */

.mdm-list {
	flex: 1;
	overflow-y: auto;
	padding: 12px;
	background: var(--mdm-bg);
	scrollbar-width: thin;
	scrollbar-color: var(--mdm-border) transparent;
}

.mdm-card {
	background: var(--mdm-white);
	border: 1px solid var(--mdm-border);
	border-radius: 10px;
	padding: 14px 16px;
	margin-bottom: 10px;
	cursor: pointer;
	transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.mdm-card:hover {
	border-color: var(--mdm-primary);
	box-shadow: 0 4px 14px rgba(2, 6, 115, 0.1);
	transform: translateY(-1px);
}

.mdm-card.is-active {
	border-color: var(--mdm-accent);
	box-shadow: 0 4px 14px rgba(192, 1, 0, 0.12);
}

.mdm-card.is-hidden {
	display: none;
}

.mdm-card__name {
	margin: 0 0 6px;
	font-size: 15px;
	font-weight: 700;
	color: var(--mdm-primary);
	line-height: 1.35;
}

.mdm-card__city {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--mdm-bg);
	color: var(--mdm-primary);
	font-size: 12px;
	font-weight: 600;
	margin-bottom: 8px;
}

.mdm-card__distance[hidden] {
	display: none;
}

.mdm-card__distance {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	background: rgba(192, 1, 0, 0.08);
	color: var(--mdm-accent);
	font-size: 12px;
	font-weight: 600;
	margin: 0 0 8px;
	margin-inline-start: 6px;
}

.mdm-card__row {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 4px 0;
	font-size: 13.5px;
	color: var(--mdm-muted);
	line-height: 1.45;
}

.mdm-card__row svg {
	flex: 0 0 auto;
	margin-top: 3px;
	color: var(--mdm-primary);
	opacity: 0.65;
}

.mdm-wrap .mdm-card__row a {
	color: var(--mdm-text);
	text-decoration: none;
	transition: color 0.2s;
	word-break: break-all;
}

.mdm-wrap .mdm-card__row a:hover {
	color: var(--mdm-accent);
	text-decoration: none;
}

.mdm-empty {
	text-align: center;
	color: var(--mdm-muted);
	padding: 30px 10px;
	margin: 0;
}

/* ---------- Map ---------- */

.mdm-map-panel {
	position: relative;
	min-height: 0;
}

.mdm-map {
	width: 100%;
	height: 100%;
	background: var(--mdm-bg);
	z-index: 1;
}

/* Custom marker pin */
.mdm-pin {
	background: transparent;
	border: none;
}

.mdm-pin svg {
	filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
	transition: transform 0.15s;
	transform-origin: bottom center;
}

.mdm-pin:hover svg,
.mdm-pin.is-active svg {
	transform: scale(1.18);
}

/* Popup */
.mdm-popup .leaflet-popup-content-wrapper {
	border-radius: 10px;
	box-shadow: 0 6px 24px rgba(2, 6, 115, 0.18);
	direction: rtl;
	text-align: right;
}

.mdm-popup .leaflet-popup-content {
	margin: 14px 16px;
	font-size: 13.5px;
	line-height: 1.5;
	font-family: inherit;
}

.mdm-popup__name {
	font-weight: 700;
	color: #020673;
	font-size: 14.5px;
	margin: 0 0 4px;
}

.mdm-popup__row {
	margin: 2px 0;
	color: #5a5e75;
}

.mdm-popup__row a {
	color: #020673;
	text-decoration: none;
	font-weight: 600;
}

.mdm-popup__row a:hover {
	color: #C00100;
}

/* Cluster theming (blue instead of default green/yellow) */
.mdm-wrap .marker-cluster-small,
.mdm-wrap .marker-cluster-medium,
.mdm-wrap .marker-cluster-large {
	background-color: rgba(2, 6, 115, 0.18);
}

.mdm-wrap .marker-cluster-small div,
.mdm-wrap .marker-cluster-medium div,
.mdm-wrap .marker-cluster-large div {
	background-color: #020673;
	color: #fff;
	font-weight: 700;
	font-family: inherit;
}

/* User-location marker */
.mdm-user-pin {
	background: transparent;
	border: none;
}

.mdm-user-pin .mdm-user-dot {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #C00100;
	border: 3px solid #fff;
	box-shadow: 0 0 0 2px rgba(192, 1, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ---------- Mobile toggle ---------- */

.mdm-wrap button.mdm-toggle {
	display: none;
	position: absolute;
	bottom: 18px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 1000;
	align-items: center;
	gap: 8px;
	padding: 10px 22px;
	border: none;
	border-radius: 999px;
	background: var(--mdm-primary);
	color: var(--mdm-white);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	white-space: nowrap;
	cursor: pointer;
	margin: 0;
	box-shadow: 0 4px 16px rgba(2, 6, 115, 0.35);
	transition: background 0.2s;
}

.mdm-wrap button.mdm-toggle:hover,
.mdm-wrap button.mdm-toggle:focus {
	background: var(--mdm-primary-hover);
	color: var(--mdm-white);
	outline: none;
	text-decoration: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
	.mdm-wrap {
		grid-template-columns: 1fr;
		height: 640px;
	}

	.mdm-sidebar {
		border-inline-end: none;
	}

	.mdm-map-panel {
		display: none;
	}

	.mdm-wrap.is-map-view .mdm-map-panel {
		display: block;
	}

	.mdm-wrap.is-map-view .mdm-sidebar .mdm-list,
	.mdm-wrap.is-map-view .mdm-sidebar .mdm-count {
		display: none;
	}

	.mdm-wrap.is-map-view {
		grid-template-rows: auto 1fr;
	}

	.mdm-wrap button.mdm-toggle {
		display: inline-flex;
	}
}

@media (max-width: 480px) {
	.mdm-wrap {
		height: 600px;
		border-radius: 8px;
	}

	.mdm-sidebar__header {
		padding: 14px 14px 12px;
	}

	.mdm-wrap button.mdm-filter {
		font-size: 12.5px;
	}
}
