/* Interactive City Map — Frontend Styles */

/* ── CSS custom properties (defaults, overridden via inline style) ── */
.icm-map-wrap {
	--icm-primary:        #336c73;
	--icm-hover-bg:       #f0f7fa;
	--icm-sidebar-bg:     #ffffff;
	--icm-card-title-clr: #111827;
	--icm-card-meta-clr:  #6b7280;
	--icm-card-border:    #f3f4f6;
	--icm-sidebar-w:      38%;
	--icm-map-h:          560px;
	--icm-photo-w:        36px;
	--icm-radius:         10px;
	--icm-search-radius:  8px;
	--icm-tab-radius:     999px;
	--icm-btn-radius:     999px;
	--icm-title-sz:       15px;
	--icm-body-sz:        13px;
	--icm-tab-font-sz:    14px;
	--icm-search-font-sz: 15px;
	--icm-tab-pad-v:      7px;
	--icm-tab-pad-h:      18px;

	--icm-card-cat-sz:    13px;
	--icm-card-desc-sz:   12px;
	--icm-card-btn-sz:    13px;
	--icm-card-btn-pad-v: 5px;
	--icm-card-btn-pad-h: 14px;

	--icm-popup-name-sz:  17px;
	--icm-popup-cat-sz:   14px;
	--icm-popup-desc-sz:  14px;
	--icm-popup-btn-sz:   14px;

	--icm-font-family:    inherit;
	--icm-card-title-w:   700;
	--icm-card-cat-w:     600;
	--icm-card-meta-w:    400;
	--icm-card-btn-w:     600;
	--icm-popup-name-w:   700;
	--icm-popup-cat-w:    600;
	--icm-popup-desc-w:   400;
	--icm-card-row-gap:   4px;
	--icm-popup-row-gap:  6px;

	font-family: var(--icm-font-family);
	line-height: 1.5;
	color: #111827;
	box-sizing: border-box;
	border: 1px solid #e2e8f0;
	border-radius: var(--icm-radius);
	overflow: hidden;
	background: #fff;
}

.icm-map-wrap *,
.icm-map-wrap *::before,
.icm-map-wrap *::after {
	box-sizing: inherit;
}

/* ── Top bar: search row + tabs row ───────────────────────────────── */
.icm-top-row {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 10px 14px;
	background: #fff;
	border-bottom: 1px solid #e2e8f0;
}

/* ── Search box ──────────────────────────────────────────────────── */
.icm-search-box {
	display: flex;
	align-items: center;
	gap: 10px;
	border: 1px solid #d1d5db;
	border-radius: var(--icm-search-radius);
	padding: 11px 14px;
	background: #f9fafb;
	width: 100%;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.icm-search-box:focus-within {
	border-color: var(--icm-primary);
	box-shadow: 0 0 0 2px rgba(51,108,115,0.1);
	background: #fff;
}

.icm-search-icon {
	color: #9ca3af;
	flex-shrink: 0;
	width: 15px;
	height: 15px;
}

.icm-search-input {
	border: none;
	background: transparent;
	font-size: var(--icm-search-font-sz);
	font-family: inherit;
	color: #111827;
	width: 100%;
	outline: none;
	padding: 0;
}

.icm-search-input::placeholder { color: #9ca3af; }

/* ── Category tabs ────────────────────────────────────────────────── */
.icm-tabs {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	width: 100%;
}

.icm-tab {
	display: inline-flex;
	align-items: center;
	padding: var(--icm-tab-pad-v) var(--icm-tab-pad-h);
	border: 1px solid #e5e7eb;
	border-radius: var(--icm-tab-radius);
	font-size: var(--icm-tab-font-sz);
	font-family: inherit;
	font-weight: 500;
	color: #374151;
	background: #fff;
	cursor: pointer;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
	white-space: nowrap;
	user-select: none;
	line-height: 1.3;
}

.icm-tab:hover {
	background: var(--icm-hover-bg);
	border-color: var(--icm-primary);
	color: var(--icm-primary);
}

.icm-tab.is-active {
	background: var(--icm-primary);
	border-color: var(--icm-primary);
	color: #fff;
	font-weight: 600;
}

/* ── Main content area ────────────────────────────────────────────── */
.icm-content {
	display: flex;
	height: var(--icm-map-h);
	overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.icm-sidebar {
	width: var(--icm-sidebar-w);
	min-width: 180px;
	background: var(--icm-sidebar-bg);
	overflow-y: auto;
	border-right: 1px solid #e2e8f0;
	flex-shrink: 0;
}

.icm-sidebar::-webkit-scrollbar { width: 4px; }
.icm-sidebar::-webkit-scrollbar-track { background: transparent; }
.icm-sidebar::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 999px; }
.icm-sidebar::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

/* ── Listing card ─────────────────────────────────────────────────── */
.icm-card {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 13px 14px;
	border-bottom: 1px solid var(--icm-card-border);
	cursor: pointer;
	transition: background 0.12s;
}

.icm-card:last-child { border-bottom: none; }

.icm-card:hover {
	background: var(--icm-hover-bg);
}

.icm-card.is-active {
	background: var(--icm-hover-bg);
}

/* ── Card photo ──────────────────────────────────────────────────── */
.icm-card__photo {
	width: var(--icm-photo-w);
	min-width: var(--icm-photo-w);
	height: var(--icm-photo-w);
	max-height: 120px;
	object-fit: cover;
	border-radius: 7px;
	background: #f3f4f6;
	flex-shrink: 0;
}

.icm-card__photo--placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	color: #cbd5e1;
}

/* ── Card body ────────────────────────────────────────────────────── */
.icm-card__body {
	flex: 1;
	min-width: 0;
	padding-top: 1px;
}

.icm-card__name {
	font-size: var(--icm-title-sz);
	font-weight: var(--icm-card-title-w);
	color: var(--icm-card-title-clr);
	margin: 0 0 var(--icm-card-row-gap) 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.3;
}

.icm-card__category {
	font-size: var(--icm-card-cat-sz);
	color: var(--icm-primary);
	font-weight: var(--icm-card-cat-w);
	margin: 0 0 var(--icm-card-row-gap) 0;
	line-height: 1.3;
}

.icm-card__meta {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: var(--icm-card-desc-sz);
	font-weight: var(--icm-card-meta-w);
	color: var(--icm-card-meta-clr);
	margin: 0 0 var(--icm-card-row-gap) 0;
	line-height: 1.3;
}

.icm-card__meta svg {
	flex-shrink: 0;
	opacity: 0.6;
}

.icm-card__desc {
	font-size: var(--icm-card-desc-sz);
	font-weight: var(--icm-card-meta-w);
	color: var(--icm-card-meta-clr);
	margin: 0 0 var(--icm-card-row-gap) 0;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	line-height: 1.4;
}

/* "View on Map" — pill button matching category tab style */
.icm-card__btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: var(--icm-card-btn-sz);
	font-family: inherit;
	font-weight: var(--icm-card-btn-w);
	color: var(--icm-primary);
	background: transparent;
	border: 1px solid var(--icm-primary);
	border-radius: var(--icm-tab-radius);
	padding: var(--icm-card-btn-pad-v) var(--icm-card-btn-pad-h);
	text-decoration: none !important;
	line-height: 1.4;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

.icm-card__btn:hover,
.icm-card__btn:focus,
.icm-card__btn:active {
	background: var(--icm-primary);
	color: #fff;
	text-decoration: none !important;
}

/* ── Empty state ──────────────────────────────────────────────────── */
.icm-empty {
	padding: 40px 16px;
	text-align: center;
	color: #9ca3af;
	font-size: 0.84rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.icm-empty svg { opacity: 0.3; }

/* ── Map column ───────────────────────────────────────────────────── */
.icm-map-col {
	flex: 1;
	position: relative;
	min-width: 0;
}

.icm-map {
	width: 100%;
	height: 100%;
	position: relative;
}

/* ── Loading overlay ─────────────────────────────────────────────── */
.icm-map-loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: #f8fafc;
	color: #94a3b8;
	font-size: 0.84rem;
	z-index: 10;
}

.icm-spinner {
	display: block;
	width: 30px;
	height: 30px;
	border: 3px solid #e2e8f0;
	border-top-color: var(--icm-primary);
	border-radius: 50%;
	animation: icm-spin 0.7s linear infinite;
}

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

/* ── Google Maps Info Window ──────────────────────────────────────── */

/* Strip native top padding / header row that creates blank space */
.icm-map .gm-style .gm-style-iw-c {
	padding: 0 !important;
	border-radius: 10px !important;
	box-shadow: 0 4px 20px rgba(0,0,0,0.12) !important;
}
.icm-map .gm-style .gm-style-iw-d {
	overflow: auto !important;
	padding: 0 !important;
}
.icm-map .gm-style .gm-style-iw-chr {
	height: 0 !important;
	overflow: visible !important;
}
.icm-map .gm-style .gm-ui-hover-effect {
	position: absolute !important;
	top: 4px !important;
	right: 4px !important;
	z-index: 2 !important;
	opacity: 0.6 !important;
}

.icm-info-win {
	font-family: inherit;
	width: 240px;
	padding: 16px 16px 14px;
	box-sizing: border-box;
}

.icm-info-win__name {
	font-size: var(--icm-popup-name-sz);
	font-weight: var(--icm-popup-name-w);
	color: #111827;
	margin: 0 0 var(--icm-popup-row-gap) 0;
	line-height: 1.3;
	padding-right: 28px; /* keep text clear of the floating close button */
}

.icm-info-win__meta {
	font-size: var(--icm-popup-cat-sz);
	color: var(--icm-primary);
	font-weight: var(--icm-popup-cat-w);
	margin: 0 0 var(--icm-popup-row-gap) 0;
	display: flex;
	align-items: center;
	gap: 4px;
}

.icm-info-win__walk {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: var(--icm-popup-cat-sz);
	color: #6b7280;
	margin: 0 0 var(--icm-popup-row-gap) 0;
	line-height: 1.3;
}

.icm-info-win__desc {
	font-size: var(--icm-popup-desc-sz);
	font-weight: var(--icm-popup-desc-w);
	color: #6b7280;
	margin: 0 0 calc(var(--icm-popup-row-gap) * 2) 0;
	line-height: 1.55;
}

/* "Get Directions" filled teal button */
.icm-info-win__btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 10px 22px;
	background: var(--icm-primary);
	color: #fff !important;
	font-size: var(--icm-popup-btn-sz);
	font-family: inherit;
	font-weight: 600;
	border-radius: var(--icm-btn-radius);
	text-decoration: none !important;
	transition: background 0.15s;
	white-space: nowrap;
}

.icm-info-win__btn:hover,
.icm-info-win__btn:focus,
.icm-info-win__btn:active {
	background: #0f3c45;
	color: #fff !important;
	text-decoration: none !important;
}

/* ── Notice ───────────────────────────────────────────────────────── */
.icm-notice {
	padding: 10px 14px;
	border-radius: 6px;
	font-size: 0.84rem;
	margin: 10px;
}

.icm-notice--warn {
	background: #fffbeb;
	border: 1px solid #fbbf24;
	color: #78350f;
}

/* ── Leaflet overrides ────────────────────────────────────────────── */
.icm-map .leaflet-container {
	height: 100%;
	width: 100%;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.icm-map .leaflet-popup-content-wrapper {
	border-radius: 10px;
	box-shadow: 0 4px 20px rgba(0,0,0,0.12);
	padding: 0;
	border: none;
	min-width: 240px;
	max-width: 260px;
}

.icm-map .leaflet-popup-content {
	margin: 0;
	padding: 0;
	min-width: 240px;
}

.icm-map .leaflet-popup-tip-container { margin-top: -1px; }

/* ── Responsive ───────────────────────────────────────────────────── */

/* Tablet: narrow the sidebar a bit */
@media (max-width: 900px) {
	.icm-sidebar {
		width: max(220px, 38%);
	}
}

/* Mobile: stack vertically — tabs → cards → map */
@media (max-width: 767px) {

	/* Full bleed on small screens */
	.icm-map-wrap {
		border-radius: 0;
		border-left: none;
		border-right: none;
	}

	/* ── Category tabs: single row, no wrap, horizontally scrollable ── */
	.icm-tabs {
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;          /* Firefox */
		padding-bottom: 2px;
		gap: 6px;
	}
	.icm-tabs::-webkit-scrollbar { display: none; }

	/* Top bar stays as column (search above tabs) */
	.icm-top-row {
		gap: 6px;
		padding: 8px 10px;
	}

	/* ── Main area: column layout ─────────────────────────────────── */
	/* Order: cards first, map second */
	.icm-content {
		flex-direction: column;
		height: auto;
		overflow: visible;
	}

	/* ── Cards (sidebar) ──────────────────────────────────────────── */
	.icm-sidebar {
		width: 100%;
		min-width: 0;
		max-width: none;
		/* Scrollable height so cards and map are both visible. Viewport-relative
		   so taller phones surface more cards before scrolling, with a floor for
		   small screens and a ceiling so the map below always stays in view. */
		height: 65vh;
		min-height: 420px;
		max-height: 600px;
		overflow-y: auto;
		border-right: none;
		border-bottom: 2px solid #d1d5db;
		order: 1;
	}

	/* ── Map ──────────────────────────────────────────────────────── */
	.icm-map-col {
		order: 2;
		height: 300px;
		flex-shrink: 0;
	}

	.icm-map {
		height: 300px;
	}

	/* Tighten card layout on mobile */
	.icm-card {
		padding: 10px 12px;
		gap: 10px;
	}

	/* Info window: slightly narrower on small screens */
	.icm-info-win {
		width: 210px;
		padding: 14px 14px 12px;
	}

	/* Google Maps InfoWindow: override the JS-injected max-height so the
	   button is never clipped when the map is short on mobile. */
	.icm-map .gm-style .gm-style-iw-c {
		max-height: none !important;
	}
	.icm-map .gm-style .gm-style-iw-d {
		max-height: none !important;
		overflow: visible !important;
	}
}
