/* IH Maps — front-end + admin styles */

/* ---- front-end ---- */
.ihmaps-wrap { width: 100%; }
.ihmaps-map { width: 100%; min-height: 300px; }

.ihmaps-filters {
	display: flex;
	flex-wrap: nowrap;
	gap: 6px;
	margin-top: 10px;
}
.ihmaps-filter-btn {
	cursor: pointer;
	flex: 1 1 auto;
	min-width: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	border: 1px solid #ccc;
	background: #fff;
	color: #222;
	padding: 5px 8px;
	border-radius: 4px;
	font: inherit;
	font-size: 13px;
	line-height: 1.3;
	white-space: nowrap;
	/* Override theme button transition: it animates the active-color change and
	   leaves a stale frame next to the map's GL canvas until the button is hovered. */
	transition: none !important;
}
/* Force readable text over both hover and theme button styles */
.ihmaps-filters .ihmaps-filter-btn:hover { background: #f0f0f0; color: #222 !important; }
/* Theme reset.css paints button:focus maroon — after a click the button stays
   focused, so a deselected button looked stuck in a red state until refocus. */
.ihmaps-filters .ihmaps-filter-btn:focus:not(.ihmaps-active) { background: #fff; color: #222 !important; }
.ihmaps-filters .ihmaps-filter-btn.ihmaps-active {
	background: var(--cat-color, #C19501);
	border-color: var(--cat-color, #C19501);
	color: #fff !important;
	font-weight: 600;
}
.ihmaps-filter-icon { flex: 0 0 auto; display: inline-flex; width: 16px; height: 16px; object-fit: contain; }
.ihmaps-filter-icon svg { width: 16px; height: 16px; }

@media (max-width: 600px) {
	.ihmaps-filters { flex-direction: column; }
	.ihmaps-filter-btn { flex: 1 1 auto; justify-content: flex-start; }
}

/* Map name/address card (top-left overlay) */
.ihmaps-map-card {
	margin: 10px;
	padding: 8px 12px;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 1px 4px rgba(0,0,0,.3);
	max-width: 260px;
}
.ihmaps-map-card-title { font-weight: 600; font-size: 14px; color: #1a1a1a; }
.ihmaps-map-card-addr { font-size: 12px; color: #555; margin-top: 2px; }

.ihmaps-infowindow { font-size: 14px; line-height: 1.4; max-width: 240px; }
.ihmaps-iw-address { color: #555; margin: 4px 0; }
.ihmaps-iw-link { display: inline-block; margin-top: 2px; }

.ihmaps-notice {
	padding: 12px 16px;
	background: #fff3cd;
	border: 1px solid #ffe69c;
	border-radius: 4px;
	color: #664d03;
}

/* ---- admin editor ---- */
.ihmaps-editor-grid { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.ihmaps-editor-forms { flex: 1 1 560px; min-width: 0; }
.ihmaps-editor-preview { flex: 1 1 380px; position: sticky; top: 40px; }
#ihmaps-preview-map { width: 100%; height: 480px; border: 1px solid #ccd0d4; border-radius: 4px; }

.ihmaps-icon-preview img { max-width: 28px; height: auto; vertical-align: middle; margin-left: 6px; }
.ihmaps-status { margin-left: 8px; color: #46b450; }

.ihmaps-loc-add {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	margin-bottom: 12px;
}
.ihmaps-loc-add #ihmaps-loc-autocomplete { flex: 1 1 260px; }
.ihmaps-base-autocomplete, #ihmaps-base-autocomplete { max-width: 400px; }

/* ---- admin: custom Places autocomplete (WP-native input + dropdown) ---- */
.ihmaps-ac { position: relative; }
.ihmaps-ac input { width: 100%; }
.ihmaps-ac-list {
	position: absolute;
	z-index: 100;
	left: 0; right: 0;
	margin: 2px 0 0;
	padding: 0;
	list-style: none;
	max-height: 320px;
	overflow-y: auto;
	background: #fff;
	border: 1px solid #8c8f94;
	border-radius: 4px;
	box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.ihmaps-ac-item {
	padding: 8px 12px;
	cursor: pointer;
	font-size: 13px;
	line-height: 1.4;
	color: #1d2327;
}
.ihmaps-ac-item:hover,
.ihmaps-ac-item.ihmaps-ac-active { background: #f0f6fc; }

.ihmaps-loc-search-wrap { margin: 4px 0 12px; }
#ihmaps-loc-search { max-width: 320px; }

/* ---- admin: tabs & panels ---- */
.ihmaps-tabs { margin-bottom: 16px; }
.ihmaps-count {
	display: inline-block;
	min-width: 18px;
	padding: 0 5px;
	margin-left: 4px;
	border-radius: 9px;
	background: #dcdcde;
	color: #1d2327;
	font-size: 11px;
	line-height: 18px;
	text-align: center;
	vertical-align: middle;
}
.nav-tab-active .ihmaps-count { background: #2271b1; color: #fff; }
/* the hidden attribute must win over the display rules below (equal specificity, source order) */
.ihmaps-editor [hidden] { display: none !important; }

/* ---- admin: read-only category rows ---- */
.ihmaps-swatch {
	display: inline-block;
	width: 16px; height: 16px;
	border-radius: 3px;
	border: 1px solid rgba(0,0,0,.2);
	vertical-align: middle;
	margin-right: 4px;
}
.ihmaps-row-icon { max-width: 24px; height: auto; vertical-align: middle; }

/* ---- admin: dirty badge ---- */
.ihmaps-dirty-badge {
	display: inline-block;
	margin-left: 10px;
	padding: 2px 10px;
	border-radius: 10px;
	background: #f6e5b3;
	color: #6a4b00;
	font-size: 12px;
	font-weight: 600;
}
.ihmaps-save-map.ihmaps-unsaved, #ihmaps-save-map.ihmaps-unsaved { box-shadow: 0 0 0 1px #dba617; }

/* ---- admin: guidance / empty states ---- */
.ihmaps-guide { margin: 0 0 14px; }
.ihmaps-empty {
	padding: 24px;
	text-align: center;
	color: #646970;
	background: #f6f7f7;
	border: 1px dashed #c3c4c7;
	border-radius: 4px;
	margin-top: 8px;
}

/* ---- admin: numbered location steps ---- */
.ihmaps-loc-add { align-items: center; }
.ihmaps-step { display: flex; align-items: center; gap: 8px; }
.ihmaps-step-num {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px; height: 22px;
	border-radius: 50%;
	background: #2271b1;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
}

/* ---- admin: modals (native <dialog>) ---- */
dialog.ihmaps-modal {
	padding: 0;
	width: 460px;
	max-width: calc(100vw - 40px);
	border: 1px solid #c3c4c7;
	border-radius: 6px;
	box-shadow: 0 8px 40px rgba(0,0,0,.25);
	color: #1d2327;
}
dialog.ihmaps-modal::backdrop { background: rgba(0,0,0,.5); }
.ihmaps-modal-head {
	padding: 14px 20px;
	border-bottom: 1px solid #dcdcde;
}
.ihmaps-modal-head h2 { margin: 0; font-size: 16px; }
.ihmaps-modal-body { padding: 16px 20px; }
.ihmaps-modal-body p { margin: 0 0 14px; }
.ihmaps-modal-foot {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 20px;
	border-top: 1px solid #dcdcde;
	background: #f6f7f7;
}
.ihmaps-modal-hint { margin-right: auto; color: #d63638; font-size: 12px; }
.ihmaps-btn-danger.button-primary {
	background: #d63638;
	border-color: #b32d2e;
}
.ihmaps-btn-danger.button-primary:hover { background: #b32d2e; border-color: #b32d2e; }

/* ---- admin: toasts ---- */
#ihmaps-toasts {
	position: fixed;
	right: 20px; bottom: 30px;
	z-index: 200000;
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.ihmaps-toast {
	min-width: 220px;
	max-width: 360px;
	padding: 12px 16px;
	border-radius: 4px;
	background: #fff;
	color: #1d2327;
	box-shadow: 0 3px 16px rgba(0,0,0,.2);
	border-left: 4px solid #00a32a;
	cursor: pointer;
	animation: ihmaps-toast-in .25s ease;
}
.ihmaps-toast-error { border-left-color: #d63638; }
.ihmaps-toast-out { opacity: 0; transform: translateY(8px); transition: opacity .3s, transform .3s; }
@keyframes ihmaps-toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- admin: row flash + button spinner ---- */
.ihmaps-flash { animation: ihmaps-flash 1.5s ease; }
@keyframes ihmaps-flash { from { background: #fff8c4; } to { background: transparent; } }

.ihmaps-busy { position: relative; color: transparent !important; pointer-events: none; }
.ihmaps-busy::after {
	content: "";
	position: absolute;
	top: 50%; left: 50%;
	width: 14px; height: 14px;
	margin: -7px 0 0 -7px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	color: #2271b1;
	animation: ihmaps-spin .6s linear infinite;
}
.button-primary.ihmaps-busy::after { color: #fff; }
@keyframes ihmaps-spin { to { transform: rotate(360deg); } }
