/* Catalog Maps — Store Locator
 * Layout inspired by foxtrot.com.ua/uk/stores. Theming via --cm-accent.
 */

.catalog-maps {
	--cm-accent: #f0532b;
	--cm-text: #1f2430;
	--cm-muted: #6b7280;
	--cm-closed: #d64550;
	--cm-line: #e6e8ee;
	--cm-bg: #ffffff;
	--cm-panel-bg: #ffffff;
	--cm-radius: 14px;
	--cm-height: 660px;
	color: var(--cm-text);
	font-family: inherit;
	box-sizing: border-box;
	width: 100%;
}
.catalog-maps *,
.catalog-maps *::before,
.catalog-maps *::after {
	box-sizing: border-box;
}
/* Атрибут hidden має ховати елементи навіть коли задано display: grid/flex. */
.catalog-maps [hidden] {
	display: none !important;
}

.cm-title {
	text-align: center;
	font-size: clamp(20px, 2.4vw, 28px);
	font-weight: 700;
	margin: 0 0 22px;
	color: var(--cm-text);
}

/* ---- Layout ----
 * Desktop: left column (select + scrollable list) | right column (map).
 * Mobile:  select, then sticky map on top, then scrollable list below.
 */
.cm-layout {
	display: grid;
	grid-template-columns: minmax(320px, 420px) 1fr;
	grid-template-rows: auto minmax(0, 1fr);
	grid-template-areas:
		"select map"
		"list   map";
	column-gap: 22px;
	align-items: start;
}
.cm-select-area { grid-area: select; margin-bottom: 14px; min-width: 0; }
.cm-list-area  { grid-area: list; min-width: 0; min-height: 0; }
.cm-map-col    { grid-area: map; }

.cm-select-label {
	font-size: 15px;
	font-weight: 600;
	margin-bottom: 8px;
	display: block;
}

.cm-select-wrap {
	position: relative;
}
.cm-select {
	width: 100%;
	appearance: none;
	-webkit-appearance: none;
	background: #f5f6f8;
	border: 1px solid var(--cm-line);
	border-radius: 12px;
	padding: 13px 42px 13px 15px;
	font-size: 15px;
	color: var(--cm-text);
	cursor: pointer;
	line-height: 1.3;
}
.cm-select:focus {
	outline: none;
	border-color: var(--cm-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--cm-accent) 18%, transparent);
}
.cm-select-wrap::after {
	content: "";
	position: absolute;
	right: 16px;
	top: 50%;
	width: 10px;
	height: 10px;
	border-right: 2px solid #9aa1ad;
	border-bottom: 2px solid #9aa1ad;
	transform: translateY(-65%) rotate(45deg);
	pointer-events: none;
}

/* ---- List ---- */
.cm-list {
	display: flex;
	flex-direction: column;
	gap: 14px;
	overflow-y: auto;
	max-height: var(--cm-height);
	padding: 2px 10px 2px 2px;
	scrollbar-width: thin;
	scrollbar-color: #cfd3db transparent;
}
.cm-list::-webkit-scrollbar { width: 8px; }
.cm-list::-webkit-scrollbar-thumb { background: #cfd3db; border-radius: 8px; }

.cm-empty-msg {
	color: var(--cm-muted);
	text-align: center;
	padding: 30px 10px;
	font-size: 15px;
}

/* ---- Card ---- */
.cm-card {
	display: grid;
	grid-template-columns: 84px 1fr;
	gap: 14px;
	border: 1px solid var(--cm-line);
	border-radius: var(--cm-radius);
	padding: 14px;
	background: var(--cm-panel-bg);
	cursor: pointer;
	transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cm-card:hover {
	border-color: color-mix(in srgb, var(--cm-accent) 55%, var(--cm-line));
	box-shadow: 0 6px 18px rgba(20, 25, 40, .07);
}
.cm-card.is-active {
	border-color: var(--cm-accent);
	box-shadow: 0 0 0 1px var(--cm-accent), 0 8px 22px rgba(20, 25, 40, .1);
}

.cm-card__media {
	width: 84px;
	height: 84px;
	border-radius: 10px;
	overflow: hidden;
	background: #f1f2f5;
	flex-shrink: 0;
}
.cm-card__media img {
	width: 100%;
	height: 100% !important; /* перебиває можливі обмеження висоти від теми */
	object-fit: cover;
	display: block;
}
.cm-card__media--empty {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--cm-accent);
}
.cm-card__media--empty .cm-ico { width: 34px; height: 34px; opacity: .55; }

.cm-card__body { min-width: 0; }
.cm-card__title {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	margin: 2px 0 10px;
	color: var(--cm-text);
}
.cm-card__row {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	font-size: 13.5px;
	color: var(--cm-muted);
	margin-bottom: 7px;
	line-height: 1.35;
}
.cm-card__row .cm-ico {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	margin-top: 1px;
	color: var(--cm-muted);
}
.cm-card__phones a {
	color: var(--cm-muted);
	text-decoration: none;
}
.cm-card__phones a:hover { color: var(--cm-accent); }

/* Тимчасово не працює — приємний червоний. */
.cm-card__row--closed,
.cm-card__row--closed .cm-ico {
	color: var(--cm-closed);
}
.cm-card__row--closed span { font-weight: 600; }

.cm-card__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 18px;
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid var(--cm-line);
}
.cm-card__action {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	font-size: 13.5px;
	font-weight: 600;
	color: var(--cm-accent);
	text-decoration: none;
}
.cm-card__action .cm-ico { width: 17px; height: 17px; }
.cm-card__action:hover { text-decoration: underline; }
.cm-card__action.cm-more { color: var(--cm-muted); }

/* ---- Map ---- */
.cm-map-col {
	position: sticky;
	top: 16px;
}
.cm-map {
	width: 100%;
	height: var(--cm-height);
	border-radius: var(--cm-radius);
	overflow: hidden;
	background: #e9edf2;
	position: relative;
}
.cm-map img { max-width: none; } /* Google tiles fix */

.cm-map-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--cm-muted);
	text-align: center;
	padding: 24px;
	font-size: 15px;
	line-height: 1.5;
}
.cm-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid #cfd6df;
	border-top-color: var(--cm-accent);
	border-radius: 50%;
	animation: cm-spin .8s linear infinite;
}
@keyframes cm-spin { to { transform: rotate(360deg); } }

/* ---- Google InfoWindow content ---- */
.cm-iw { max-width: 240px; font-family: inherit; }
.cm-iw__title { font-weight: 700; font-size: 14px; margin: 0 0 6px; color: var(--cm-text); }
.cm-iw__meta { font-size: 12.5px; color: #555; margin: 0 0 4px; }
.cm-iw__meta--closed { color: var(--cm-closed); font-weight: 600; }
.cm-iw__link { display: inline-block; margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--cm-accent); text-decoration: none; }

.catalog-maps--empty { padding: 40px; text-align: center; color: var(--cm-muted); }

/* ---- Responsive: карта зафіксована зверху, список скролиться сторінкою ---- */
@media (max-width: 900px) {
	.cm-layout {
		grid-template-columns: 1fr;
		grid-template-rows: auto auto auto;
		grid-template-areas:
			"select"
			"map"
			"list";
		column-gap: 0;
	}
	.cm-select-area { margin-bottom: 12px; }

	.cm-map-col {
		position: sticky;
		top: 0;
		z-index: 5;
		background: var(--cm-bg);
		/* Більший відступ під картою: чіткий проміжок між картою і списком,
		   який лишається видимим під зафіксованою картою під час скролу. */
		padding-bottom: 24px;
		margin: 0 -2px 8px;
	}
	.cm-map {
		height: 300px;
		border-radius: 12px;
	}

	/* Список іде природним потоком — скролиться разом зі сторінкою під картою.
	   Запас знизу, щоб сторінку завжди можна було прокрутити (навіть за короткого списку). */
	.cm-list-area {
		min-height: 0;
		padding-bottom: 40vh;
	}
	.cm-list {
		max-height: none;
		overflow: visible;
		padding: 0;
	}
}

@media (max-width: 420px) {
	.cm-card { grid-template-columns: 68px 1fr; gap: 12px; padding: 12px; }
	.cm-card__media { width: 68px; height: 68px; }
	.cm-card__actions { gap: 8px 14px; }
}
