.factendec-buyer-fields,
.factendec-city,
.factendec-buyer-fields *,
.factendec-city * {
	box-sizing: border-box;
}

/* The core city remains active for Store API validation while the
 * province-aware WooCommerce control is the visible city surface. */
.wp-block-woocommerce-checkout .wc-block-components-address-form__city {
	display: none;
}

.factendec-buyer-fields {
	margin-top: 24px;
}

.factendec-buyer-fields__grid {
	display: flex;
	flex-wrap: wrap;
	gap: 0 12px;
	justify-content: space-between;
}

.factendec-buyer-fields__identity,
.factendec-buyer-fields__number,
.factendec-buyer-fields__foreign-type,
.factendec-buyer-fields__consumer-final-checkbox {
	flex: 0 0 100%;
	min-width: 0;
}

.factendec-buyer-fields__classification {
	margin: 4px 0 0;
}

.factendec-buyer-fields__foreign-type,
.factendec-buyer-fields__consumer-final-checkbox {
	margin-top: 16px;
}

.factendec-buyer-fields__consumer-final {
	flex: 0 0 100%;
	margin: 0;
}

.factendec-buyer-fields__consumer-final-limit {
	margin: 8px 0 0;
}

/* Flatten only an address while it is being edited. This lets the forced
 * city inner block participate in WooCommerce's native address flex layout
 * without moving or replacing any DOM node. */
.wc-block-checkout__shipping-fields .wc-block-components-checkout-step__content,
.wc-block-checkout__billing-fields .wc-block-components-checkout-step__content {
	display: flex;
	flex-wrap: wrap;
	gap: 0 12px;
	justify-content: space-between;
}

.wc-block-checkout__shipping-fields .wc-block-components-address-address-wrapper.is-editing,
.wc-block-checkout__shipping-fields .wc-block-components-address-address-wrapper.is-editing > .wc-block-components-address-form-wrapper,
.wc-block-checkout__shipping-fields .wc-block-components-address-address-wrapper.is-editing .wc-block-components-address-form,
.wc-block-checkout__billing-fields .wc-block-components-address-address-wrapper.is-editing,
.wc-block-checkout__billing-fields .wc-block-components-address-address-wrapper.is-editing > .wc-block-components-address-form-wrapper,
.wc-block-checkout__billing-fields .wc-block-components-address-address-wrapper.is-editing .wc-block-components-address-form {
	display: contents;
}

.wc-block-checkout__shipping-fields .wc-block-components-notices,
.wc-block-checkout__shipping-fields .wc-block-components-notices__snackbar,
.wc-block-checkout__shipping-fields .wc-block-components-address-card-wrapper,
.wc-block-checkout__billing-fields .wc-block-components-notices,
.wc-block-checkout__billing-fields .wc-block-components-notices__snackbar,
.wc-block-checkout__billing-fields .wc-block-components-address-card-wrapper {
	flex: 0 0 100%;
}

.wc-block-checkout__shipping-fields .wc-block-components-address-form__state,
.wc-block-checkout__billing-fields .wc-block-components-address-form__state {
	order: 70;
}

.factendec-city--shipping,
.factendec-city--billing {
	flex: 1 0 calc(50% - 12px);
	min-width: 0;
	order: 80;
	padding-top: 12px;
}

.wc-block-checkout__shipping-fields .wc-block-components-address-form__phone,
.wc-block-checkout__billing-fields .wc-block-components-address-form__phone {
	flex: 0 0 100%;
	order: 90;
}

.wc-block-checkout__use-address-for-billing {
	flex: 0 0 100%;
	margin-top: 12px;
	order: 100;
}

.factendec-city__control {
	position: relative;
	width: 100%;
}

.factendec-city__input {
	width: 100%;
}

.factendec-buyer-fields__foreign-type .wc-blocks-components-select__expand,
.factendec-city__expand {
	height: 24px;
	pointer-events: none;
	position: absolute;
	right: 8px;
	top: 13px;
	transform: none;
	width: 24px;
}

.factendec-city__options {
	background: var(--wp--preset--color--base, Canvas);
	border: 1px solid currentColor;
	color: var(--wp--preset--color--contrast, CanvasText);
	left: 0;
	list-style: none;
	margin: 4px 0 0;
	max-height: 240px;
	overflow-y: auto;
	padding: 4px;
	position: absolute;
	right: 0;
	top: 100%;
	z-index: 30;
}

.factendec-city__options li {
	margin: 0;
	padding: 0;
}

.factendec-city__option {
	background: transparent;
	border: 0;
	color: inherit;
	cursor: pointer;
	display: block;
	padding: 9px 10px;
	text-align: left;
	width: 100%;
}

.factendec-city__option:hover,
.factendec-city__option:focus-visible,
.factendec-city__option.is-selected {
	background: color-mix(in srgb, currentColor 10%, transparent);
	outline: 1px solid currentColor;
}

.factendec-city__empty {
	padding: 10px;
}

@media (max-width: 600px) {
	.wc-block-checkout__shipping-fields .wc-block-components-address-form__state,
	.wc-block-checkout__billing-fields .wc-block-components-address-form__state,
	.factendec-city {
		flex-basis: 100%;
	}
}
