/**
 * Checkout Blocks: selector de comuna Chile (Correos de Chile).
 * Visual alineado con .wc-block-components-text-input de WooCommerce Blocks.
 */

.correos-chile-blocks-comuna {
	position: relative;
	z-index: 2;
}

.correos-chile-blocks-comuna.wc-block-components-text-input {
	margin-top: 12px;
}

/*
 * sync-bsale-v2 usa display:grid + filas fijas (checkout-blocks-bsale.css). flex/order de Woo no aplican.
 * Teléfono columna 1 y comuna columna 2 en la misma fila que sync-bsale asigna al teléfono (facturación fila 3;
 * boleta+retiro fila 2; envío fila 2). Así el teléfono queda “primero” y la comuna en la segunda columna.
 */
@media (min-width: 601px) {
	body.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__phone,
	body.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__phone {
		grid-column: 1 !important;
		grid-row: 3 !important;
	}

	body.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__comuna_correos,
	body.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__comuna_correos {
		grid-column: 2 !important;
		grid-row: 3 !important;
	}

	body.sync-bsale--boleta-pickup.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__phone,
	body.sync-bsale--boleta-pickup.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__phone {
		grid-row: 2 !important;
		grid-column: 1 !important;
	}

	body.sync-bsale--boleta-pickup.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__comuna_correos,
	body.sync-bsale--boleta-pickup.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__comuna_correos {
		grid-row: 2 !important;
		grid-column: 2 !important;
	}

	body.correos-chile-blocks--cl-shipping
		.wc-block-checkout__shipping-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__phone,
	body.correos-chile-blocks--cl-shipping
		.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__phone {
		grid-column: 1 !important;
		grid-row: 2 !important;
	}

	body.correos-chile-blocks--cl-shipping
		.wc-block-checkout__shipping-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__comuna_correos,
	body.correos-chile-blocks--cl-shipping
		.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__comuna_correos {
		grid-column: 2 !important;
		grid-row: 2 !important;
	}
}

/* Checkout Woo por defecto (sin grilla sync-bsale): orden flex — teléfono al inicio del bloque, comuna al final */
@container (min-width: 700px) {
	body.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__phone,
	body.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__phone {
		order: -100 !important;
	}

	body.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	body.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	body.correos-chile-blocks--cl-shipping
		.wc-block-checkout__shipping-fields
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	body.correos-chile-blocks--cl-shipping
		.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna {
		order: 1000 !important;
	}

	body.correos-chile-blocks--cl-shipping
		.wc-block-checkout__shipping-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__phone,
	body.correos-chile-blocks--cl-shipping
		.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__phone {
		order: -100 !important;
	}

	.wc-block-checkout__billing-fields .wc-block-components-address-form .correos-chile-blocks-comuna,
	.wc-block-checkout__shipping-fields .wc-block-components-address-form .correos-chile-blocks-comuna,
	.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna {
		box-sizing: border-box;
		flex: 1 0 calc(50% - 12px);
	}
}

@media (min-width: 700px) {
	body.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__phone,
	body.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__phone {
		order: -100 !important;
	}

	body.correos-chile-blocks--cl-billing
		.wc-block-checkout__billing-fields
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	body.correos-chile-blocks--cl-billing
		.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	body.correos-chile-blocks--cl-shipping
		.wc-block-checkout__shipping-fields
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	body.correos-chile-blocks--cl-shipping
		.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna {
		order: 1000 !important;
	}

	body.correos-chile-blocks--cl-shipping
		.wc-block-checkout__shipping-fields
		.wc-block-components-address-form
		.wc-block-components-address-form__phone,
	body.correos-chile-blocks--cl-shipping
		.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.wc-block-components-address-form__phone {
		order: -100 !important;
	}

	.wc-block-checkout__billing-fields .wc-block-components-address-form .correos-chile-blocks-comuna,
	.wc-block-checkout__shipping-fields .wc-block-components-address-form .correos-chile-blocks-comuna,
	.wp-block-woocommerce-checkout-billing-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna,
	.wp-block-woocommerce-checkout-shipping-address-block
		.wc-block-components-address-form
		.correos-chile-blocks-comuna {
		box-sizing: border-box;
		flex: 1 0 calc(50% - 12px);
	}
}

.correos-chile-blocks-comuna .wc-block-components-text-input__wrapper {
	position: relative;
}

.correos-chile-blocks-comuna__list {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 4px);
	max-height: 280px;
	overflow-y: auto;
	margin: 0;
	padding: 0.25rem 0;
	list-style: none;
	background: hsl(0, 0%, 100%);
	border: 1px solid color-mix(in srgb, currentColor 80%, transparent);
	border-radius: 4px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	z-index: 50;
}

.correos-chile-blocks-comuna__list[hidden] {
	display: none !important;
}

.correos-chile-blocks-comuna__item {
	margin: 0;
	padding: 0;
}

.correos-chile-blocks-comuna__btn {
	display: block;
	width: 100%;
	text-align: left;
	padding: 0.55rem 0.75rem;
	border: none;
	background: transparent;
	font-size: 0.9375em;
	line-height: 1.35;
	cursor: pointer;
	color: inherit;
}

.correos-chile-blocks-comuna__btn:hover,
.correos-chile-blocks-comuna__btn:focus {
	background: color-mix(in srgb, currentColor 8%, transparent);
	outline: none;
}

.correos-chile-blocks-comuna__btn.is-active {
	background: color-mix(in srgb, currentColor 12%, transparent);
}

.correos-chile-blocks-comuna__region {
	display: block;
	font-size: 0.8em;
	opacity: 0.75;
	margin-top: 0.15em;
}

.correos-chile-blocks-comuna__empty {
	padding: 0.6rem 0.75rem;
	font-size: 0.875em;
	color: color-mix(in srgb, currentColor 55%, transparent);
}

/* Ocultar región y comuna nativas cuando Chile + nuestro control está activo */
body.correos-chile-blocks--cl-billing .wc-block-checkout__billing-fields .wc-block-components-address-form .wc-block-components-address-form__state,
body.correos-chile-blocks--cl-billing .wc-block-checkout__billing-fields .wc-block-components-address-form .wc-block-components-address-form__city,
body.correos-chile-blocks--cl-billing .wp-block-woocommerce-checkout-billing-address-block .wc-block-components-address-form .wc-block-components-address-form__state,
body.correos-chile-blocks--cl-billing .wp-block-woocommerce-checkout-billing-address-block .wc-block-components-address-form .wc-block-components-address-form__city {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	border: 0 !important;
}

body.correos-chile-blocks--cl-shipping .wc-block-checkout__shipping-fields .wc-block-components-address-form .wc-block-components-address-form__state,
body.correos-chile-blocks--cl-shipping .wc-block-checkout__shipping-fields .wc-block-components-address-form .wc-block-components-address-form__city,
body.correos-chile-blocks--cl-shipping .wp-block-woocommerce-checkout-shipping-address-block .wc-block-components-address-form .wc-block-components-address-form__state,
body.correos-chile-blocks--cl-shipping .wp-block-woocommerce-checkout-shipping-address-block .wc-block-components-address-form .wc-block-components-address-form__city {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	border: 0 !important;
}

/* Aviso sin envío: enlace a WhatsApp de soporte */
.cv-no-shipping-whatsapp {
	margin: 0.75em 0 0;
	padding: 0;
}

.cv-no-shipping-whatsapp__link {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	color: #25d366;
	text-decoration: none;
	font-weight: 600;
	line-height: 1.4;
}

.cv-no-shipping-whatsapp__link:hover,
.cv-no-shipping-whatsapp__link:focus {
	color: #1da851;
	text-decoration: underline;
}

.cv-no-shipping-whatsapp__icon {
	display: inline-flex;
	flex-shrink: 0;
	color: #25d366;
}

.cv-no-shipping-whatsapp__icon svg {
	display: block;
}

.wc-block-components-shipping-rates-control__no-results-notice .cv-no-shipping-whatsapp {
	margin-top: 1em;
}
