/**
 * PH Checkout Address — Flatsome & WooCommerce Classic Checkout / My Account Styles
 */

/* Hide fixed country row when phca_fixed_country is enabled */
.woocommerce-checkout .form-row.phca-hidden-country,
.woocommerce-account .form-row.phca-hidden-country {
	display: none !important;
}

/* Hidden manual rows until "__not_listed__" is selected */
.form-row.phca-hidden {
	display: none !important;
}

/* Force full-width rows on Street, Address 2, Manual fields, Phone, Email (always 100%) and State/City/Barangay/ZIP in 1-col mode */
body:not(.phca-layout-2col) .woocommerce form .form-row.phca-field-state,
body:not(.phca-layout-2col) .woocommerce form .form-row.phca-field-city,
body:not(.phca-layout-2col) .woocommerce form .form-row.phca-field-barangay,
body:not(.phca-layout-2col) .woocommerce form .form-row.phca-field-postcode,
.woocommerce form .form-row.phca-field-state-manual,
.woocommerce form .form-row.phca-field-city-manual,
.woocommerce form .form-row.phca-field-barangay-manual,
.woocommerce form .form-row.phca-field-address-1,
.woocommerce form .form-row.phca-field-address-2,
.woocommerce form .form-row.phca-field-phone,
.woocommerce form .form-row.phca-field-email,
html body.woocommerce-checkout form.checkout #billing_address_1_field,
html body.woocommerce-checkout form.checkout #shipping_address_1_field,
html body.woocommerce-checkout #billing_address_1_field,
html body.woocommerce-checkout #shipping_address_1_field,
html body.woocommerce-account form #billing_address_1_field,
html body.woocommerce-account form #shipping_address_1_field,
body.woocommerce-checkout #billing_address_1_field,
body.woocommerce-checkout #shipping_address_1_field {
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	clear: both !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	box-sizing: border-box !important;
}

/* 2-Column Desktop Grid Mode (min-width: 769px) */
@media (min-width: 769px) {
	body.phca-layout-2col .woocommerce form .form-row.phca-field-state.form-row-first,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-barangay.form-row-first,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-state,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-barangay {
		width: 48% !important;
		max-width: 48% !important;
		float: left !important;
		clear: both !important;
		margin-right: 4% !important;
		box-sizing: border-box !important;
	}

	body.phca-layout-2col .woocommerce form .form-row.phca-field-city.form-row-last,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-postcode.form-row-last,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-city,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-postcode {
		width: 48% !important;
		max-width: 48% !important;
		float: right !important;
		clear: none !important;
		margin-right: 0 !important;
		box-sizing: border-box !important;
	}
}

html body.woocommerce-checkout form.checkout #billing_address_1_field input,
html body.woocommerce-checkout form.checkout #shipping_address_1_field input,
html body.woocommerce-account form #billing_address_1_field input,
html body.woocommerce-account form #shipping_address_1_field input,
.woocommerce form .form-row.phca-field-address-1 input {
	width: 100% !important;
	max-width: 100% !important;
	box-sizing: border-box !important;
}

/* Ensure Select2 / SelectWoo containers never truncate or shrink below 100% width */
.woocommerce form .form-row.phca-field-state .select2-container,
.woocommerce form .form-row.phca-field-city .select2-container,
.woocommerce form .form-row.phca-field-barangay .select2-container,
.woocommerce form .form-row .select2-container {
	width: 100% !important;
	max-width: 100% !important;
	box-sizing: border-box !important;
}

.woocommerce form .form-row .select2-container .select2-selection--single {
	height: 2.75em;
	display: flex;
	align-items: center;
	border: 1px solid #ddd;
	border-radius: 0;
	background-color: #fff;
}

.woocommerce form .form-row .select2-container .select2-selection--single .select2-selection__rendered {
	line-height: 2.6em;
	padding-left: 0.75em;
	padding-right: 2em;
	width: 100%;
	text-overflow: ellipsis;
	white-space: nowrap;
	overflow: hidden;
}

.woocommerce form .form-row .select2-container .select2-selection--single .select2-selection__arrow {
	height: 100%;
	top: 0;
	right: 6px;
}

/* Disabled cascading select state */
.woocommerce form .form-row select.phca-select:disabled + .select2-container .select2-selection--single,
.woocommerce form .form-row select.phca-select:disabled {
	background-color: #f7f7f7 !important;
	color: #888 !important;
	cursor: not-allowed;
}

/* Fallback notice banner if static JSON fails to load */
.phca-fallback-notice {
	margin: 0 0 1em 0;
	padding: 0.75em 1em;
	background: #fff8e5;
	border-left: 4px solid #dba617;
	color: #333;
	font-size: 0.9em;
	line-height: 1.4;
}

/* ==========================================================================
   Mobile Touch & iOS Safari Auto-Zoom Prevention (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
	/* Always force 100% width on mobile even in 2-col mode */
	body.phca-layout-2col .woocommerce form .form-row.phca-field-state,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-city,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-barangay,
	body.phca-layout-2col .woocommerce form .form-row.phca-field-postcode {
		width: 100% !important;
		max-width: 100% !important;
		float: none !important;
		clear: both !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
	}

	/* Enforce 16px font-size to prevent iOS Safari auto-zooming on focus */
	.woocommerce form .form-row input.input-text,
	.woocommerce form .form-row select,
	.woocommerce form .form-row .select2-container .select2-selection--single,
	.woocommerce form .form-row .select2-container .select2-selection--single .select2-selection__rendered,
	.woocommerce-checkout input[type="text"],
	.woocommerce-checkout input[type="tel"],
	.woocommerce-checkout input[type="email"],
	.woocommerce-checkout select {
		font-size: 16px !important;
	}

	/* Touch-Friendly Heights (min 44px) */
	.woocommerce form .form-row .select2-container .select2-selection--single {
		height: 44px !important;
		min-height: 44px !important;
	}

	.woocommerce form .form-row .select2-container .select2-selection--single .select2-selection__rendered {
		line-height: 42px !important;
		padding-left: 12px !important;
	}

	.woocommerce form .form-row input.input-text {
		min-height: 44px !important;
		padding: 10px 12px !important;
		box-sizing: border-box !important;
	}

	/* Select2 / SelectWoo Dropdown Results on Mobile */
	.select2-container--default .select2-results__option {
		min-height: 44px !important;
		display: flex !important;
		align-items: center !important;
		padding: 10px 14px !important;
		font-size: 15px !important;
	}
}
