/**
 * Xemry v3.9.12 — Product-page responsive overflow repair.
 * RTL/LTR-neutral and strictly scoped to single product pages.
 * Preserve gallery controls, purchase actions, product data and theme layout.
 */

/* Grid/flex items must be allowed to shrink below their content's intrinsic width.
   A translated label, supplier image or long URL must never widen the whole page. */
body.xm-refined.single-product :is(
  .site-main, .luania-main, .woocommerce, .woocommerce div.product,
  .luania-product-main, .woocommerce-product-gallery, .summary.entry-summary,
  .xm-product-details, .xm-product-accordions, .xm-accordion-body,
  .xm-product-reviews, .xm-review-inner, .xm-product-category-sections,
  .xm-cat-body, .xm-products-grid, .xm-admin-arabic-copy,
  .xm-full-description-content, .woocommerce-Tabs-panel--description,
  .woocommerce-product-details__short-description
) {
  min-inline-size: 0 !important;
  max-inline-size: 100%;
  box-sizing: border-box;
}
body.xm-refined.single-product .woocommerce div.product,
body.xm-refined.single-product .luania-product-main {
  inline-size: 100%;
}
body.xm-refined.single-product .luania-product-main {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr) !important;
}
body.xm-refined.single-product .luania-product-main > :is(.woocommerce-product-gallery, .summary.entry-summary) {
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
}

/* Both description render paths (theme accordion and normal WooCommerce tabs),
   including content saved in Products > Arabic Product Descriptions. */
body.xm-refined.single-product :is(
  .xm-admin-arabic-copy, .xm-full-description-content,
  .woocommerce-Tabs-panel--description, .woocommerce-product-details__short-description
) {
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}
/* Imported supplier HTML can set `style="width: 900px"` on nested wrappers.
   Bound rich-content blocks, not interactive gallery/variation components. */
body.xm-refined.single-product :is(
  .xm-admin-arabic-copy, .xm-full-description-content,
  .woocommerce-Tabs-panel--description, .woocommerce-product-details__short-description
) :is(div, section, article, p, ul, ol, dl, blockquote, figure, table) {
  max-inline-size: 100% !important;
  min-inline-size: 0;
  box-sizing: border-box;
}
body.xm-refined.single-product :is(
  .xm-admin-arabic-copy, .xm-full-description-content,
  .woocommerce-Tabs-panel--description, .woocommerce-product-details__short-description
) :is(figure, .wp-block-image, .wp-block-gallery, .wp-block-columns, .wp-block-column) {
  max-inline-size: 100% !important;
  min-inline-size: 0;
}
body.xm-refined.single-product :is(
  .xm-admin-arabic-copy, .xm-full-description-content,
  .woocommerce-Tabs-panel--description, .woocommerce-product-details__short-description
) :is(img, video, iframe, embed, object) {
  max-inline-size: 100% !important;
  box-sizing: border-box;
}
body.xm-refined.single-product :is(
  .xm-admin-arabic-copy, .xm-full-description-content,
  .woocommerce-Tabs-panel--description, .woocommerce-product-details__short-description
) img {
  block-size: auto !important;
}
/* Scroll an oversized comparison table or code sample *within its own area*;
   do not hide/clamp the entire viewport or interfere with image sliders. */
body.xm-refined.single-product :is(
  .xm-admin-arabic-copy, .xm-full-description-content,
  .woocommerce-Tabs-panel--description, .woocommerce-product-details__short-description
) :is(table, pre) {
  display: block;
  max-inline-size: 100% !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Supplier galleries and review media: permit their outer grid to shrink. */
body.xm-refined.single-product .woocommerce-product-gallery,
body.xm-refined.single-product .woocommerce-product-gallery .flex-viewport,
body.xm-refined.single-product .woocommerce-product-gallery__wrapper,
body.xm-refined.single-product .woocommerce-product-gallery__image,
body.xm-refined.single-product .woocommerce-product-gallery__image a,
body.xm-refined.single-product .woocommerce-product-gallery .flex-control-thumbs {
  max-inline-size: 100% !important;
  min-inline-size: 0;
}
body.xm-refined.single-product .woocommerce-product-gallery__image img {
  max-inline-size: 100% !important;
  block-size: auto;
  object-fit: contain;
}
body.xm-refined.single-product .xm-review-inner :is(img, input, textarea, select) {
  max-inline-size: 100%;
}
body.xm-refined.single-product .xm-products-grid {
  min-inline-size: 0;
  max-inline-size: 100%;
}
body.xm-refined.single-product .xm-products-grid > * {
  min-inline-size: 0;
  max-inline-size: 100%;
}

/* Variable-product labels and swatches can become much longer in Arabic. */
body.xm-refined.single-product .summary :is(
  form.cart, .variations_form, .variations, .single_variation_wrap,
  .woocommerce-variation-add-to-cart, .luania-option-buttons,
  .variable-items-wrapper, .luania-variation-options, .luania-variation-values
) {
  max-inline-size: 100% !important;
  min-inline-size: 0;
}
body.xm-refined.single-product .summary :is(
  .luania-option-buttons, .variable-items-wrapper,
  .luania-variation-options, .luania-variation-values
) {
  flex-wrap: wrap;
}
body.xm-refined.single-product .summary :is(select, input, button) {
  max-inline-size: 100%;
  box-sizing: border-box;
}
body.xm-refined.single-product .summary :is(.luania-option-button, .variable-item, .luania-option) {
  max-inline-size: 100%;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  /* A one-column product is mandatory on narrow screens, even if the parent
     WooCommerce theme sets a fixed two-column min-width at tablet sizes. */
  body.xm-refined.single-product .luania-product-main {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    grid-template-columns: minmax(0, 1fr) !important;
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    inline-size: 100% !important;
    box-sizing: border-box;
  }
  body.xm-refined.single-product .luania-product-main > :is(.woocommerce-product-gallery, .summary.entry-summary) {
    flex: 0 1 auto !important;
    inline-size: 100% !important;
    min-inline-size: 0 !important;
    margin-inline: 0 !important;
  }
  body.xm-refined.single-product .summary :is(table.variations, .variations select) {
    inline-size: 100%;
    max-inline-size: 100%;
  }
  body.xm-refined.single-product .summary table.variations :is(tbody, tr, th, td) {
    box-sizing: border-box;
    max-inline-size: 100%;
  }
  body.xm-refined.single-product .summary table.variations :is(th,td) {
    display: block;
    inline-size: 100%;
    text-align: start;
    padding-inline: 0;
  }
  body.xm-refined.single-product .summary .woocommerce-variation-add-to-cart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }
  body.xm-refined.single-product .summary :is(.single_add_to_cart_button, .button, .quantity) {
    max-inline-size: 100%;
  }
  body.xm-refined.single-product .xm-products-grid,
  body.xm-refined.single-product .woocommerce ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
@media (max-width: 360px) {
  body.xm-refined.single-product .xm-products-grid,
  body.xm-refined.single-product .woocommerce ul.products {
    gap: 8px;
  }
  body.xm-refined.single-product .xm-product-accordions summary,
  body.xm-refined.single-product .xm-category-accordion > summary {
    min-inline-size: 0;
    overflow-wrap: anywhere;
  }
}
