/**
 * Frontend styles for BR Checkout Fields for WooCommerce.
 *
 * @package BR_Checkout_Fields
 * @version 1.0.0
 */

/* --------------------------------------------------------------------------
   Checkout billing fields — flex-based column layout.
   Replaces WooCommerce's legacy float + clear:left approach so that 50%-wide
   fields pair correctly even when conditional fields (CPF, RG, CNPJ…) between
   them are hidden via display:none.
   -------------------------------------------------------------------------- */
.woocommerce-checkout .woocommerce-billing-fields__field-wrapper {
	display: flex;
	flex-wrap: wrap;
	column-gap: 12px;
	align-items: flex-start;
}

.woocommerce-checkout .woocommerce-billing-fields__field-wrapper > .form-row {
	float: none !important;
	clear: none !important;
	margin-right: 0 !important;
	margin-left: 0 !important;
	width: 100%;
	box-sizing: border-box;
}

.woocommerce-checkout .woocommerce-billing-fields__field-wrapper > .form-row.form-row-first,
.woocommerce-checkout .woocommerce-billing-fields__field-wrapper > .form-row.form-row-last {
	width: calc(50% - 6px);
	margin-right: 0 !important;
	margin-left: 0 !important;
}

/* My Account — edit billing/shipping address */
.woocommerce-account .woocommerce-address-fields__field-wrapper {
	display: flex;
	flex-wrap: wrap;
	column-gap: 12px;
	align-items: flex-start;
}

.woocommerce-account .woocommerce-address-fields__field-wrapper > .form-row {
	float: none !important;
	clear: none !important;
	margin-right: 0 !important;
	margin-left: 0 !important;
	width: 100%;
	box-sizing: border-box;
}

.woocommerce-account .woocommerce-address-fields__field-wrapper > .form-row.form-row-first,
.woocommerce-account .woocommerce-address-fields__field-wrapper > .form-row.form-row-last {
	width: calc(50% - 6px);
	margin-right: 0 !important;
	margin-left: 0 !important;
}

/* --------------------------------------------------------------------------
   Generic opt-in container — .brcf-fields
   A custom checkout plugin (e.g. a multi-step checkout that splits the
   identification and delivery fields into separate panels) can add the class
   "brcf-fields" to ANY field container to inherit this same column layout —
   widths (form-row-first/last = 50%), pairing and mobile stacking — driven by
   BR Checkout Fields, without depending on WooCommerce's native
   .woocommerce-billing-fields__field-wrapper markup. Purely additive: it has no
   effect anywhere the class is not present.
   -------------------------------------------------------------------------- */
.brcf-fields {
	display: flex;
	flex-wrap: wrap;
	column-gap: 12px;
	row-gap: 14px;
	align-items: flex-start;
}
.brcf-fields > .form-row {
	float: none !important;
	clear: none !important;
	margin-right: 0 !important;
	margin-left: 0 !important;
	width: 100%;
	box-sizing: border-box;
}
.brcf-fields > .form-row.form-row-first,
.brcf-fields > .form-row.form-row-last {
	width: calc(50% - 6px);
	margin-right: 0 !important;
	margin-left: 0 !important;
}

/* --------------------------------------------------------------------------
   Conditionally-required person-type fields (CPF, CNPJ, IE, Razão Social…).
   These are registered as optional in the WC fields array — the WC core
   required flag would demand them on every order regardless of the selected
   person type — while the plugin enforces requiredness server-side for the
   selected type only. Restore the required-field look: hide "(optional)"
   and show the asterisk (mirrors WC core's .required styling).
   -------------------------------------------------------------------------- */
.form-row.brcf-conditionally-required label .optional {
	display: none;
}

.form-row.brcf-conditionally-required label::after {
	content: " *";
	color: red;
	font-weight: 700;
}

/* Country field hidden (keeps field in DOM for payment gateways) */
.brcf-country-hidden {
	display: none !important;
}

/* Email typo hint */
.brcf-email-hint {
	display: block;
	margin: 3px 0 0;
	font-size: 0.82em;
	color: #c07800;
}

/* Stack to full width on small screens.
   NOTE: .brcf-fields is intentionally NOT stacked here — an opt-in checkout
   plugin keeps its columns on mobile by default and exposes its own
   "mobile: full width" option (see brcf_mobile_full_width) to force a single
   column when a store prefers it. Native billing/address wrappers keep the
   traditional mobile stacking. */
@media (max-width: 600px) {
	.woocommerce-checkout .woocommerce-billing-fields__field-wrapper > .form-row.form-row-first,
	.woocommerce-checkout .woocommerce-billing-fields__field-wrapper > .form-row.form-row-last,
	.woocommerce-account .woocommerce-address-fields__field-wrapper > .form-row.form-row-first,
	.woocommerce-account .woocommerce-address-fields__field-wrapper > .form-row.form-row-last {
		width: 100%;
	}

	/* Prevent iOS auto-zoom on focused inputs */
	#billing_postcode,
	#billing_cpf,
	#billing_cnpj,
	#billing_rg,
	#billing_birthdate,
	#billing_cellphone,
	#billing_neighborhood,
	#billing_number {
		font-size: 16px;
	}
}
