/*
 * DYWA v12.1 – Arabic content-only RTL mode
 * ------------------------------------------------------------
 * Client requirement:
 * - Keep the physical/layout structure exactly like the English site.
 * - Apply RTL only to Arabic writing/content.
 * - Product names remain English/LTR.
 * - Prices, quantities, SKUs and technical numbers keep LTR isolation.
 *
 * v12.1 sets the Arabic content-only layout state on <html> server-side before
 * first paint; dywa-arabic-frontend.js then keeps that state synchronized after
 * AJAX/language changes. Theme/Elementor/WooCommerce RTL rules cannot mirror grids,
 * columns, menus or controls. These rules then opt text back into RTL.
 */

html.dywa-arabic-rtl,
html.dywa-global-arabic,
html.dywa-arabic-rtl body,
html.dywa-global-arabic body {
  text-rendering: optimizeLegibility;
}

/* ============================================================
   1. LAYOUT LOCK — never mirror the English structure
   ============================================================ */
html.dywa-arabic-rtl body,
html.dywa-global-arabic body,
html.dywa-arabic-rtl .elementor,
html.dywa-global-arabic .elementor,
html.dywa-arabic-rtl .elementor-section,
html.dywa-global-arabic .elementor-section,
html.dywa-arabic-rtl .elementor-container,
html.dywa-global-arabic .elementor-container,
html.dywa-arabic-rtl .e-con,
html.dywa-global-arabic .e-con,
html.dywa-arabic-rtl .dywa-section,
html.dywa-global-arabic .dywa-section,
html.dywa-arabic-rtl .dywa-section .dywa-main,
html.dywa-global-arabic .dywa-section .dywa-main,
html.dywa-arabic-rtl .dywa-section .dywa-sidebar,
html.dywa-global-arabic .dywa-section .dywa-sidebar,
html.dywa-arabic-rtl body.single-product .dysp-section,
html.dywa-global-arabic body.single-product .dysp-section,
html.dywa-arabic-rtl body.single-product .dysp-wrap,
html.dywa-global-arabic body.single-product .dysp-wrap,
html.dywa-arabic-rtl body.single-product .dysp-main,
html.dywa-global-arabic body.single-product .dysp-main,
html.dywa-arabic-rtl body.single-product .dysp-gallery-col,
html.dywa-global-arabic body.single-product .dysp-gallery-col,
html.dywa-arabic-rtl body.single-product .dysp-summary-col,
html.dywa-global-arabic body.single-product .dysp-summary-col,
html.dywa-arabic-rtl .dyx-related,
html.dywa-global-arabic .dyx-related,
html.dywa-arabic-rtl .dyx-rp-track,
html.dywa-global-arabic .dyx-rp-track,
html.dywa-arabic-rtl .dywa-cart-page,
html.dywa-global-arabic .dywa-cart-page,
html.dywa-arabic-rtl .dywa-checkout-page,
html.dywa-global-arabic .dywa-checkout-page,
html.dywa-arabic-rtl .dywa-checkout-shortcode,
html.dywa-global-arabic .dywa-checkout-shortcode,
html.dywa-arabic-rtl .dywa-modern-wishlist,
html.dywa-global-arabic .dywa-modern-wishlist,
html.dywa-arabic-rtl .woocommerce-cart-form,
html.dywa-global-arabic .woocommerce-cart-form,
html.dywa-arabic-rtl form.checkout,
html.dywa-global-arabic form.checkout,
html.dywa-arabic-rtl .dywa-product-search,
html.dywa-global-arabic .dywa-product-search,
html.dywa-arabic-rtl .dywa-search-results,
html.dywa-global-arabic .dywa-search-results,
html.dywa-arabic-rtl .dywa-mobile-search-panel,
html.dywa-global-arabic .dywa-mobile-search-panel,
html.dywa-arabic-rtl .dywa-categories-menu,
html.dywa-global-arabic .dywa-categories-menu,
html.dywa-arabic-rtl .dywa-cat-dropdown,
html.dywa-global-arabic .dywa-cat-dropdown,
html.dywa-arabic-rtl .dywa-sidecart-root,
html.dywa-global-arabic .dywa-sidecart-root {
  direction: ltr !important;
}

/* Flex/grid rows that must retain the English physical order. */
html.dywa-arabic-rtl body.single-product .dysp-main,
html.dywa-global-arabic body.single-product .dysp-main,
html.dywa-arabic-rtl body.single-product .dysp-top-meta,
html.dywa-global-arabic body.single-product .dysp-top-meta,
html.dywa-arabic-rtl body.single-product form.cart,
html.dywa-global-arabic body.single-product form.cart,
html.dywa-arabic-rtl .dywa-filter-actions,
html.dywa-global-arabic .dywa-filter-actions,
html.dywa-arabic-rtl .dywa-section .dywa-tools,
html.dywa-global-arabic .dywa-section .dywa-tools,
html.dywa-arabic-rtl .dywa-sidecart-item,
html.dywa-global-arabic .dywa-sidecart-item,
html.dywa-arabic-rtl .dywa-sidecart-subtotal,
html.dywa-global-arabic .dywa-sidecart-subtotal,
html.dywa-arabic-rtl .dywa-sidecart-coupon-form,
html.dywa-global-arabic .dywa-sidecart-coupon-form {
  direction: ltr !important;
}

/* ============================================================
   2. GENERAL ARABIC WRITING — content only, no layout reversal
   ============================================================ */
html.dywa-arabic-rtl body :where(
  .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-icon-list .elementor-icon-list-text,
  .woocommerce-notices-wrapper .woocommerce-message,
  .woocommerce-notices-wrapper .woocommerce-error,
  .woocommerce-notices-wrapper .woocommerce-info
),
html.dywa-global-arabic body :where(
  .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-icon-list .elementor-icon-list-text,
  .woocommerce-notices-wrapper .woocommerce-message,
  .woocommerce-notices-wrapper .woocommerce-error,
  .woocommerce-notices-wrapper .woocommerce-info
) {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}

/* UI text gets Arabic writing direction without changing control positions. */
html.dywa-arabic-rtl body :where(
  button,
  .button,
  .elementor-button-text,
  .elementor-nav-menu a,
  input[type="submit"],
  input[type="button"]
),
html.dywa-global-arabic body :where(
  button,
  .button,
  .elementor-button-text,
  .elementor-nav-menu a,
  input[type="submit"],
  input[type="button"]
) {
  direction: rtl;
  unicode-bidi: plaintext;
}

/* ============================================================
   3. ARCHIVE / FILTER TEXT
   ============================================================ */
html.dywa-arabic-rtl :where(
  .dywa-filter-title,
  .dywa-filter-name,
  .dywa-price-label,
  .dywa-count,
  .dywa-sidebar label,
  .dywa-topbar label,
  .dywa-empty,
  .dywa-no-results
),
html.dywa-global-arabic :where(
  .dywa-filter-title,
  .dywa-filter-name,
  .dywa-price-label,
  .dywa-count,
  .dywa-sidebar label,
  .dywa-topbar label,
  .dywa-empty,
  .dywa-no-results
) {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}

html.dywa-arabic-rtl :where(.dywa-apply-btn,.dywa-reset-btn,.dywa-mobile-filter-toggle),
html.dywa-global-arabic :where(.dywa-apply-btn,.dywa-reset-btn,.dywa-mobile-filter-toggle) {
  direction: rtl !important;
  white-space: normal !important;
  line-height: 1.35 !important;
}

/* ============================================================
   4. PRODUCT NAMES — ALWAYS ENGLISH / LTR
   ============================================================ */
html.dywa-arabic-rtl :where(
  .dywa-product-title,
  .dysp-title,
  h1.product_title,
  .dyx-rp-name,
  .dywa-wishlist-name,
  .dywa-search-result-title,
  .dywa-sidecart-product-name,
  .woocommerce-cart-form .product-name,
  .woocommerce-checkout-review-order-table .product-name,
  .dywa-product-name-notranslate,
  [translate="no"].notranslate
),
html.dywa-global-arabic :where(
  .dywa-product-title,
  .dysp-title,
  h1.product_title,
  .dyx-rp-name,
  .dywa-wishlist-name,
  .dywa-search-result-title,
  .dywa-sidecart-product-name,
  .woocommerce-cart-form .product-name,
  .woocommerce-checkout-review-order-table .product-name,
  .dywa-product-name-notranslate,
  [translate="no"].notranslate
) {
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

/* Single product title follows the SAME alignment as English layout. */
html.dywa-arabic-rtl body.single-product :where(.dysp-title,h1.product_title),
html.dywa-global-arabic body.single-product :where(.dysp-title,h1.product_title) {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  text-align: left !important;
}

/* Related-product names are centered in BOTH languages. */
.dyx-related .dyx-rp-name,
html.dywa-arabic-rtl .dyx-related .dyx-rp-name,
html.dywa-global-arabic .dyx-related .dyx-rp-name {
  width: 100% !important;
  text-align: center !important;
  justify-content: center !important;
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

/* ============================================================
   5. SINGLE PRODUCT — Arabic writing inside fixed English layout
   ============================================================ */
html.dywa-arabic-rtl body.single-product :where(
  .dysp-breadcrumbs,
  .dysp-short-description,
  .woocommerce-product-details__short-description,
  .dysp-service-box p,
  .dysp-service-box span:not(.dysp-service-icon),
  .dysp-support-box p,
  .dysp-support-box span:not(.dysp-support-icon),
  .dypt-panel,
  .dypt-faq-answer,
  .dyx-add-info,
  .woocommerce-Tabs-panel,
  .dysp-product-files .dysp-product-files-title
),
html.dywa-global-arabic body.single-product :where(
  .dysp-breadcrumbs,
  .dysp-short-description,
  .woocommerce-product-details__short-description,
  .dysp-service-box p,
  .dysp-service-box span:not(.dysp-service-icon),
  .dysp-support-box p,
  .dysp-support-box span:not(.dysp-support-icon),
  .dypt-panel,
  .dypt-faq-answer,
  .dyx-add-info,
  .woocommerce-Tabs-panel,
  .dysp-product-files .dysp-product-files-title
) {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}

/* Meta labels/text are RTL, but the meta flex row stays LTR. */
html.dywa-arabic-rtl body.single-product :where(
  .dysp-stock,
  .dysp-rating,
  .dysp-sku,
  .dysp-meta > span,
  .dysp-share-label
),
html.dywa-global-arabic body.single-product :where(
  .dysp-stock,
  .dysp-rating,
  .dysp-sku,
  .dysp-meta > span,
  .dysp-share-label
) {
  direction: rtl !important;
  unicode-bidi: plaintext;
}

/* Lists are writing-level RTL only. The product columns do not move. */
html.dywa-arabic-rtl body.single-product :where(
  .dysp-short-description,
  .woocommerce-product-details__short-description,
  .dypt-panel,
  .dypt-faq-answer,
  .woocommerce-Tabs-panel
) :where(ul,ol),
html.dywa-global-arabic body.single-product :where(
  .dysp-short-description,
  .woocommerce-product-details__short-description,
  .dypt-panel,
  .dypt-faq-answer,
  .woocommerce-Tabs-panel
) :where(ul,ol) {
  direction: rtl !important;
  text-align: right !important;
  list-style-position: outside !important;
  padding-left: 0 !important;
  padding-right: 1.45em !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ============================================================
   6. CART / CHECKOUT / WISHLIST — structure LTR, words RTL
   ============================================================ */
html.dywa-arabic-rtl :where(
  .dywa-checkout-shortcode label,
  .dywa-checkout-shortcode .woocommerce-privacy-policy-text,
  .dywa-checkout-shortcode .dywa-checkout-privacy-text,
  .dywa-checkout-shortcode .dywa-checkout-agreement-text,
  .dywa-checkout-shortcode .woocommerce-error,
  .dywa-checkout-shortcode .woocommerce-message,
  .dywa-checkout-shortcode .woocommerce-info,
  .dywa-checkout-shortcode #payment .payment_box,
  .dywa-checkout-shortcode .woocommerce-billing-fields > h3,
  .dywa-checkout-shortcode .woocommerce-additional-fields > h3,
  .dywa-checkout-shortcode #order_review_heading,
  .dywa-cart-page .cart_totals h2,
  .dywa-modern-wishlist .dywa-wishlist-empty,
  .dywa-modern-wishlist .dywa-wishlist-heading
),
html.dywa-global-arabic :where(
  .dywa-checkout-shortcode label,
  .dywa-checkout-shortcode .woocommerce-privacy-policy-text,
  .dywa-checkout-shortcode .dywa-checkout-privacy-text,
  .dywa-checkout-shortcode .dywa-checkout-agreement-text,
  .dywa-checkout-shortcode .woocommerce-error,
  .dywa-checkout-shortcode .woocommerce-message,
  .dywa-checkout-shortcode .woocommerce-info,
  .dywa-checkout-shortcode #payment .payment_box,
  .dywa-checkout-shortcode .woocommerce-billing-fields > h3,
  .dywa-checkout-shortcode .woocommerce-additional-fields > h3,
  .dywa-checkout-shortcode #order_review_heading,
  .dywa-cart-page .cart_totals h2,
  .dywa-modern-wishlist .dywa-wishlist-empty,
  .dywa-modern-wishlist .dywa-wishlist-heading
) {
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: plaintext;
}

/* Keep checkbox/radio + label order exactly like English. */
html.dywa-arabic-rtl :where(
  .dywa-checkout-agreement,
  .woocommerce-checkout-payment .wc_payment_method,
  .woocommerce-form__label-for-checkbox
),
html.dywa-global-arabic :where(
  .dywa-checkout-agreement,
  .woocommerce-checkout-payment .wc_payment_method,
  .woocommerce-form__label-for-checkbox
) {
  direction: ltr !important;
}

html.dywa-arabic-rtl .dywa-checkout-agreement .dywa-checkout-agreement-text,
html.dywa-global-arabic .dywa-checkout-agreement .dywa-checkout-agreement-text,
html.dywa-arabic-rtl .woocommerce-checkout-payment .wc_payment_method > label,
html.dywa-global-arabic .woocommerce-checkout-payment .wc_payment_method > label {
  direction: rtl !important;
  unicode-bidi: plaintext;
}

/* Text inputs can contain Arabic; technical input types remain LTR. */
html.dywa-arabic-rtl :where(textarea,input[type="text"],input[type="search"]),
html.dywa-global-arabic :where(textarea,input[type="text"],input[type="search"]) {
  direction: rtl;
  text-align: right;
}
html.dywa-arabic-rtl :where(input[type="email"],input[type="tel"],input[type="number"]),
html.dywa-global-arabic :where(input[type="email"],input[type="tel"],input[type="number"]) {
  direction: ltr !important;
  text-align: left;
}

/* ============================================================
   7. SEARCH / HEADER TEXT — fixed English positions
   ============================================================ */
html.dywa-arabic-rtl :where(
  .dywa-search-results .dywa-search-result-meta,
  .dywa-mobile-search-panel .dywa-mobile-search-title,
  .dywa-cat-dropdown .dywa-cat-label
),
html.dywa-global-arabic :where(
  .dywa-search-results .dywa-search-result-meta,
  .dywa-mobile-search-panel .dywa-mobile-search-title,
  .dywa-cat-dropdown .dywa-cat-label
) {
  direction: rtl !important;
  text-align: right !important;
}

/* ============================================================
   8. NUMBERS / PRICES / SKUs — unchanged and stable
   ============================================================ */
html.dywa-arabic-rtl :where(
  .woocommerce-Price-amount,
  .quantity,
  .quantity input,
  .sku,
  .dysp-price,
  .dyx-rp-price,
  .dywa-sidecart-line-price,
  .dywa-sidecart-title-count,
  .dywa-sidecart-count,
  .dysp-cart-count-highlight
),
html.dywa-global-arabic :where(
  .woocommerce-Price-amount,
  .quantity,
  .quantity input,
  .sku,
  .dysp-price,
  .dyx-rp-price,
  .dywa-sidecart-line-price,
  .dywa-sidecart-title-count,
  .dywa-sidecart-count,
  .dysp-cart-count-highlight
) {
  direction: ltr !important;
  unicode-bidi: isolate !important;
}

/* ============================================================
   9. RESPONSIVE — same breakpoint behaviour as English
   ============================================================ */
@media (max-width:1024px) {
  html.dywa-arabic-rtl .dywa-section .dywa-tools,
  html.dywa-global-arabic .dywa-section .dywa-tools,
  html.dywa-arabic-rtl body.single-product .dysp-wrap,
  html.dywa-global-arabic body.single-product .dysp-wrap {
    width: 100% !important;
    max-width: 100% !important;
  }
}

@media (max-width:767px) {
  html.dywa-arabic-rtl .dywa-section,
  html.dywa-global-arabic .dywa-section {
    overflow-x: hidden !important;
  }

  html.dywa-arabic-rtl .dywa-sidebar,
  html.dywa-global-arabic .dywa-sidebar {
    max-width: min(92vw,380px) !important;
  }

  html.dywa-arabic-rtl .dywa-sidebar-inner,
  html.dywa-global-arabic .dywa-sidebar-inner,
  html.dywa-arabic-rtl body.single-product .dysp-main,
  html.dywa-global-arabic body.single-product .dysp-main,
  html.dywa-arabic-rtl body.single-product .dysp-gallery-col,
  html.dywa-global-arabic body.single-product .dysp-gallery-col,
  html.dywa-arabic-rtl body.single-product .dysp-summary-col,
  html.dywa-global-arabic body.single-product .dysp-summary-col {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  html.dywa-arabic-rtl .dywa-filter-actions,
  html.dywa-global-arabic .dywa-filter-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  html.dywa-arabic-rtl :where(.dywa-apply-btn,.dywa-reset-btn),
  html.dywa-global-arabic :where(.dywa-apply-btn,.dywa-reset-btn),
  html.dywa-arabic-rtl body.single-product .dysp-product-file-btn,
  html.dywa-global-arabic body.single-product .dysp-product-file-btn {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
  }

  html.dywa-arabic-rtl body.single-product .dysp-title,
  html.dywa-global-arabic body.single-product .dysp-title {
    font-size: clamp(22px,7vw,30px) !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere !important;
    text-align: left !important;
  }

  html.dywa-arabic-rtl body.single-product .dysp-breadcrumbs,
  html.dywa-global-arabic body.single-product .dysp-breadcrumbs {
    line-height: 1.6 !important;
    overflow-wrap: anywhere !important;
  }

  html.dywa-arabic-rtl .dywa-checkout-shortcode .form-row,
  html.dywa-global-arabic .dywa-checkout-shortcode .form-row,
  html.dywa-arabic-rtl .dywa-checkout-shortcode :where(.woocommerce-error,.woocommerce-message,.woocommerce-info),
  html.dywa-global-arabic .dywa-checkout-shortcode :where(.woocommerce-error,.woocommerce-message,.woocommerce-info),
  html.dywa-arabic-rtl .dywa-mobile-search-inner,
  html.dywa-global-arabic .dywa-mobile-search-inner {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

@media (max-width:480px) {
  html.dywa-arabic-rtl body.single-product .dysp-title,
  html.dywa-global-arabic body.single-product .dysp-title {
    font-size: clamp(20px,7vw,26px) !important;
  }
  html.dywa-arabic-rtl body.single-product .dysp-breadcrumbs,
  html.dywa-global-arabic body.single-product .dysp-breadcrumbs {
    font-size: 11px !important;
  }
}
