/**
 * Writing direction for the actual text controls used by WordPress,
 * Elementor, WooCommerce classic checkout, and WooCommerce Checkout Blocks.
 *
 * The translated layout may already mirror its sections. These rules avoid
 * mirroring layout containers again and correct only text-bearing elements
 * that themes/widgets frequently leave with a hard-coded source alignment.
 */
html[dir="rtl"],
body.sast-dir-rtl {
	direction: rtl;
}

html[dir="ltr"],
body.sast-dir-ltr {
	direction: ltr;
}

body.sast-dir-rtl :is(
	.entry-title,
	.entry-content,
	.site-title,
	.site-description,
	.widget-title,
	.widget_text,
	.elementor-widget-heading .elementor-heading-title,
	.elementor-widget-text-editor .elementor-widget-container,
	.elementor-widget-text-editor p,
	.elementor-widget-text-editor li,
	.elementor-widget-text-editor blockquote,
	.elementor-widget-button .elementor-button,
	.elementor-widget-button .elementor-button-text,
	.elementor-widget-icon-list .elementor-icon-list-item,
	.elementor-widget-icon-list .elementor-icon-list-text,
	.elementor-widget-counter .elementor-counter-number-wrapper,
	.elementor-widget-counter .elementor-counter-title,
	.elementor-widget-price-table .elementor-price-table__heading,
	.elementor-widget-price-table .elementor-price-table__subheading,
	.elementor-widget-price-table .elementor-price-table__price,
	.elementor-widget-price-table .elementor-price-table__features-list,
	.elementor-widget-testimonial .elementor-testimonial-content,
	.elementor-widget-testimonial .elementor-testimonial-name,
	.elementor-widget-accordion .elementor-accordion-title,
	.elementor-widget-tabs .elementor-tab-title,
	.elementor-widget-form .elementor-field-label,
	.elementor-widget-form .elementor-message,
	.elementor-cta__title,
	.elementor-cta__description,
	.woocommerce .woocommerce-breadcrumb,
	.woocommerce .woocommerce-loop-product__title,
	.woocommerce .product_title,
	.woocommerce .woocommerce-product-details__short-description,
	.woocommerce .woocommerce-tabs,
	.woocommerce .price,
	.woocommerce .amount,
	.woocommerce form label,
	.woocommerce .cart_totals,
	.woocommerce .woocommerce-checkout-review-order,
	.woocommerce .woocommerce-billing-fields,
	.woocommerce .woocommerce-shipping-fields,
	.woocommerce .woocommerce-additional-fields,
	.wc-block-cart,
	.wc-block-checkout,
	.wc-block-components-form,
	.wc-block-components-title,
	.wc-block-components-product-name,
	.wc-block-components-product-price,
	.wc-block-components-product-metadata,
	.wc-block-components-totals-item,
	.wc-block-components-address-form,
	.wc-block-components-checkout-step,
	.wc-block-components-checkout-step__description,
	.wc-block-components-order-summary,
	.wc-block-components-order-summary-item__description,
	.wc-block-components-validation-error
) {
	direction: rtl !important;
	text-align: right !important;
}

body.sast-dir-ltr :is(
	.entry-title,
	.entry-content,
	.site-title,
	.site-description,
	.widget-title,
	.widget_text,
	.elementor-widget-heading .elementor-heading-title,
	.elementor-widget-text-editor .elementor-widget-container,
	.elementor-widget-text-editor p,
	.elementor-widget-text-editor li,
	.elementor-widget-text-editor blockquote,
	.elementor-widget-button .elementor-button,
	.elementor-widget-button .elementor-button-text,
	.elementor-widget-icon-list .elementor-icon-list-item,
	.elementor-widget-icon-list .elementor-icon-list-text,
	.elementor-widget-counter .elementor-counter-number-wrapper,
	.elementor-widget-counter .elementor-counter-title,
	.elementor-widget-price-table .elementor-price-table__heading,
	.elementor-widget-price-table .elementor-price-table__subheading,
	.elementor-widget-price-table .elementor-price-table__price,
	.elementor-widget-price-table .elementor-price-table__features-list,
	.elementor-widget-testimonial .elementor-testimonial-content,
	.elementor-widget-testimonial .elementor-testimonial-name,
	.elementor-widget-accordion .elementor-accordion-title,
	.elementor-widget-tabs .elementor-tab-title,
	.elementor-widget-form .elementor-field-label,
	.elementor-widget-form .elementor-message,
	.elementor-cta__title,
	.elementor-cta__description,
	.woocommerce .woocommerce-breadcrumb,
	.woocommerce .woocommerce-loop-product__title,
	.woocommerce .product_title,
	.woocommerce .woocommerce-product-details__short-description,
	.woocommerce .woocommerce-tabs,
	.woocommerce .price,
	.woocommerce .amount,
	.woocommerce form label,
	.woocommerce .cart_totals,
	.woocommerce .woocommerce-checkout-review-order,
	.woocommerce .woocommerce-billing-fields,
	.woocommerce .woocommerce-shipping-fields,
	.woocommerce .woocommerce-additional-fields,
	.wc-block-cart,
	.wc-block-checkout,
	.wc-block-components-form,
	.wc-block-components-title,
	.wc-block-components-product-name,
	.wc-block-components-product-price,
	.wc-block-components-product-metadata,
	.wc-block-components-totals-item,
	.wc-block-components-address-form,
	.wc-block-components-checkout-step,
	.wc-block-components-checkout-step__description,
	.wc-block-components-order-summary,
	.wc-block-components-order-summary-item__description,
	.wc-block-components-validation-error
) {
	direction: ltr !important;
	text-align: left !important;
}

body.sast-dir-rtl :is(
	input:not([type="email"]):not([type="url"]):not([type="tel"]):not([type="number"]),
	textarea,
	select,
	.select2-selection,
	.wc-block-components-text-input
),
body.sast-dir-rtl :is(
	input:not([type="email"]):not([type="url"]):not([type="tel"]):not([type="number"]),
	textarea,
	select
)::placeholder {
	direction: rtl !important;
	text-align: right !important;
}

body.sast-dir-ltr :is(input, textarea, select, .select2-selection, .wc-block-components-text-input),
body.sast-dir-ltr :is(input, textarea, select)::placeholder {
	direction: ltr !important;
	text-align: left !important;
}

body.sast-dir-rtl :is(.select2-container, .select2-dropdown, .select2-results, .woocommerce form.checkout, .wc-block-checkout) {
	direction: rtl !important;
}

body.sast-dir-ltr :is(.select2-container, .select2-dropdown, .select2-results, .woocommerce form.checkout, .wc-block-checkout) {
	direction: ltr !important;
}

/* Preserve explicit centered or justified design choices in either language. */
body.sast-dir-ltr :is(.elementor-align-center, .elementor-align-center *, .has-text-align-center, .has-text-align-center *),
body.sast-dir-rtl :is(.elementor-align-center, .elementor-align-center *, .has-text-align-center, .has-text-align-center *) {
	text-align: center !important;
}

body.sast-dir-ltr :is(.elementor-align-justify, .elementor-align-justify *, .has-text-align-justify, .has-text-align-justify *),
body.sast-dir-rtl :is(.elementor-align-justify, .elementor-align-justify *, .has-text-align-justify, .has-text-align-justify *) {
	text-align: justify !important;
}

/* Keep amounts and contact values readable inside a line that follows the
 * surrounding page direction. */
body :is(
	.woocommerce .amount,
	.woocommerce .price,
	.wc-block-components-product-price,
	.wc-block-formatted-money-amount,
	input[type="email"],
	input[type="url"],
	input[type="tel"],
	input[type="number"]
) {
	unicode-bidi: isolate;
}
