/**
 * WooCommerce BG Places Autocomplete
 *
 * Scoped to .wc-bg-places-* so it cannot leak into theme or Bulgarisation styles.
 * Colours use currentColor / neutral greys to blend with whatever theme is active.
 */

.wc-bg-places-wrapper {
	position: relative;
	display: block;
}

.wc-bg-places-list {
	position: absolute;
	z-index: 9999; /* Above Bulgarisation's shipping widgets and theme overlays. */
	top: 100%;
	left: 0;
	right: 0;
	max-height: 17.5em;
	margin: 2px 0 0;
	padding: 0;
	overflow-y: auto;
	list-style: none;
	background: #fff;
	border: 1px solid #d5d5d5;
	border-radius: 4px;
	box-shadow: 0 6px 18px rgba( 0, 0, 0, 0.12 );
	text-align: left;
	-webkit-overflow-scrolling: touch;
}

.wc-bg-places-list[hidden] {
	display: none;
}

.wc-bg-places-option {
	display: flex;
	flex-direction: column;
	gap: 1px;
	margin: 0;
	padding: 8px 12px;
	cursor: pointer;
	border-bottom: 1px solid #f0f0f0;
	line-height: 1.35;
}

.wc-bg-places-option:last-child {
	border-bottom: 0;
}

.wc-bg-places-option:hover,
.wc-bg-places-option.is-active {
	background: #f2f6fb;
}

.wc-bg-places-name {
	font-size: 14px;
	font-weight: 600;
	color: #222;
}

.wc-bg-places-type {
	font-weight: 400;
	color: #8a8a8a;
}

.wc-bg-places-meta {
	display: flex;
	justify-content: space-between;
	gap: 10px;
	font-size: 12px;
	color: #8a8a8a;
}

.wc-bg-places-postcode {
	flex-shrink: 0;
	font-variant-numeric: tabular-nums;
}

/* --- Status rows (searching / no results / error) ----------------------- */

.wc-bg-places-status {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 10px 12px;
	color: #8a8a8a;
	font-size: 13px;
	cursor: default;
}

.wc-bg-places-status.is-error {
	color: #b32d2e;
}

/* --- Busy state --------------------------------------------------------- */

/*
 * Spinner parked at the right edge of the input. The wrapper is the only
 * positioned ancestor and the dropdown inside it is absolutely positioned,
 * so the wrapper's height stays equal to the input's and 50% is its middle.
 */
.wc-bg-places-wrapper.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 12px;
	width: 15px;
	height: 15px;
	margin-top: -8px;
	box-sizing: border-box;
	border: 2px solid rgba( 0, 0, 0, 0.15 );
	border-top-color: rgba( 0, 0, 0, 0.55 );
	border-radius: 50%;
	pointer-events: none;
	z-index: 2;
	animation: wc-bg-places-spin 0.6s linear infinite;
}

/* Only while busy, so left-aligned text never shifts. */
.wc-bg-places-wrapper.is-loading .wc-bg-places-input {
	padding-right: 36px;
}

.wc-bg-places-spinner {
	flex-shrink: 0;
	width: 13px;
	height: 13px;
	box-sizing: border-box;
	border: 2px solid rgba( 0, 0, 0, 0.15 );
	border-top-color: rgba( 0, 0, 0, 0.5 );
	border-radius: 50%;
	animation: wc-bg-places-spin 0.6s linear infinite;
}

/* Results already on screen while a fresher lookup runs. */
.wc-bg-places-list.is-stale .wc-bg-places-option {
	opacity: 0.55;
}

@keyframes wc-bg-places-spin {
	to {
		transform: rotate( 360deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.wc-bg-places-wrapper.is-loading::after,
	.wc-bg-places-spinner {
		animation: wc-bg-places-pulse 1.1s ease-in-out infinite;
		border-top-color: rgba( 0, 0, 0, 0.15 );
	}

	@keyframes wc-bg-places-pulse {
		50% {
			opacity: 0.25;
		}
	}
}

/* The browser's own autofill dropdown would sit on top of ours. */
.wc-bg-places-input::-webkit-calendar-picker-indicator {
	display: none !important;
}
