/* ==========================================================
   ONEBIO v1.6 responsive + WooCommerce QA hardening
   Loaded last. Avoid overriding WooCommerce/FlexSlider's
   JS-calculated slide widths.
========================================================== */

/* ---------- Global overflow safety ---------- */
html, body { max-width: 100%; }
body { overflow-x: hidden; }
img, video, iframe, canvas { max-width: 100%; }
.onebio-commerce-container,
.onebio-commerce-container > .woocommerce,
.onebio-elementor-page,
.elementor,
.elementor-element,
.elementor-widget-container { min-width: 0; }

/* ---------- Product gallery / FlexSlider ---------- */
body.single-product .woocommerce-product-gallery,
body.single-product .woocommerce-product-gallery .flex-viewport { width: 100%; max-width: 100%; min-width: 0; }
body.single-product .woocommerce-product-gallery .flex-viewport { overflow: hidden !important; }
body.single-product .woocommerce-product-gallery__wrapper { margin: 0 !important; }
/* IMPORTANT: do not set width on .woocommerce-product-gallery__image.
   FlexSlider writes that width inline and needs to own it. */
body.single-product .woocommerce-product-gallery__image { min-width: 0; margin: 0 !important; }
body.single-product .woocommerce-product-gallery__image a { display: grid; width: 100%; place-items: center; }
body.single-product .woocommerce-product-gallery__image img { display: block; height: auto !important; }
body.single-product .woocommerce-product-gallery .flex-control-thumbs { width: 100%; min-width: 0; }
body.single-product .woocommerce-product-gallery .flex-control-thumbs img { display: block; width: 100% !important; height: auto !important; margin: 0; cursor: pointer !important; }
body.single-product .woocommerce-product-gallery .flex-control-thumbs img.flex-active { opacity: 1; outline: 2px solid var(--color-green-deep); outline-offset: -2px; }

/* Keep sale badge tied to the gallery/card rather than a separate page row. */
body.single-product .woocommerce div.product > span.onsale { z-index: 12 !important; }

/* ---------- Woo notices ---------- */
body.onebio-commerce-page .woocommerce-notices-wrapper { width: 100%; min-width: 0; }
body.onebio-commerce-page .woocommerce-message,
body.onebio-commerce-page .woocommerce-info,
body.onebio-commerce-page .woocommerce-error { width: 100%; max-width: 100%; box-sizing: border-box; }

/* ---------- Forms ---------- */
.woocommerce input.input-text,
.woocommerce textarea,
.woocommerce select,
.woocommerce form .form-row,
.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea { max-width: 100%; box-sizing: border-box; }
.select2-container { max-width: 100% !important; }

/* ---------- Cart ---------- */
body.woocommerce-cart .woocommerce-cart-form,
body.woocommerce-cart .cart-collaterals,
body.woocommerce-cart .cart_totals { min-width: 0; }
body.woocommerce-cart table.shop_table { width: 100%; max-width: 100%; }
body.woocommerce-cart table.shop_table .product-thumbnail img { width: 82px; height: 82px; object-fit: contain; }
body.woocommerce-cart .coupon { display: flex; flex-wrap: wrap; gap: 8px; }
body.woocommerce-cart .coupon .input-text { min-height: 50px; flex: 1 1 170px; }

/* ---------- Checkout ---------- */
body.woocommerce-checkout #customer_details,
body.woocommerce-checkout #order_review,
body.woocommerce-checkout #order_review_heading { min-width: 0; max-width: 100%; }
body.woocommerce-checkout .woocommerce-checkout-review-order-table { width: 100%; table-layout: auto; }

/* ---------- My account ---------- */
body.woocommerce-account .woocommerce-MyAccount-navigation,
body.woocommerce-account .woocommerce-MyAccount-content { min-width: 0; max-width: 100%; }
body.woocommerce-account .woocommerce-MyAccount-content table { max-width: 100%; }

/* ---------- Shop / category ---------- */
body.woocommerce-shop ul.products,
body.tax-product_cat ul.products,
.onebio-wc-grid { min-width: 0; }
.onebio-shop-hero > * { min-width: 0; }

/* ---------- Mobile menu ---------- */
@media (max-width: 1120px) {
  .mobile-menu { z-index: 101 !important; inset: 0 !important; width: 100vw; max-width: 100vw; overflow-x: hidden; overflow-y: auto; }
  .mobile-menu__inner { width: min(calc(100% - 32px), var(--container-width)); max-width: 100%; min-width: 0; }
  .mobile-menu nav,
  .mobile-menu nav a,
  .mobile-menu nav a > strong { min-width: 0; max-width: 100%; }
  .mobile-menu nav a { overflow: hidden; }
}

/* ---------- Tablet ---------- */
@media (max-width: 980px) {
  body.single-product .woocommerce div.product { width: 100%; }
  body.single-product .woocommerce div.product > .images,
  body.single-product .woocommerce div.product > .summary { width: 100% !important; min-width: 0; }
  body.single-product .woocommerce div.product div.images { position: relative !important; top: auto !important; }
  body.single-product .woocommerce div.product div.images .woocommerce-product-gallery__image a { min-height: clamp(380px, 72vw, 620px); }
  body.single-product .woocommerce div.product div.images img { width: min(78%, 540px) !important; }

  body.woocommerce-cart .cart-collaterals .cart_totals,
  body.woocommerce-checkout #order_review,
  body.woocommerce-account .woocommerce-MyAccount-navigation { position: static !important; }

  .onebio-shop-hero { grid-template-columns: 1fr !important; }
}

/* ---------- Phones ---------- */
@media (max-width: 700px) {
  :root { --section-space-lg: 68px; --section-space-sm: 54px; }
  .container { width: calc(100% - 30px) !important; max-width: none !important; }
  .section-padding { padding-block: var(--section-space-lg); }

  /* Prevent decorative desktop offsets from making the homepage feel clipped. */
  .hero-product { width: 100% !important; margin-right: 0 !important; margin-left: 0 !important; }
  .source-section__overlay::after,
  .community-section::before { max-width: 100vw; }

  /* Single product */
  body.single-product .onebio-commerce-main { padding-top: 28px !important; }
  body.single-product .woocommerce .woocommerce-breadcrumb { overflow-wrap: anywhere; }
  body.single-product .woocommerce div.product div.images .woocommerce-product-gallery__image a {
    min-height: 0 !important;
    aspect-ratio: 1 / 1.03;
    padding: 20px 10px;
  }
  body.single-product .woocommerce div.product div.images img { width: min(86%, 390px) !important; max-height: 430px; }
  body.single-product .woocommerce div.product .flex-control-thumbs { display: grid !important; grid-template-columns: repeat(3,minmax(0,1fr)) !important; gap: 8px; }
  body.single-product .woocommerce div.product .product_title { overflow-wrap: anywhere; }
  body.single-product .woocommerce div.product p.price,
  body.single-product .woocommerce div.product span.price { overflow-wrap: anywhere; }
  body.single-product .woocommerce div.product form.cart { width: 100%; grid-template-columns: 82px minmax(0,1fr) !important; }
  body.single-product .woocommerce div.product form.cart .quantity,
  body.single-product .woocommerce div.product form.cart .single_add_to_cart_button { min-width: 0; }
  body.single-product .woocommerce div.product form.cart .single_add_to_cart_button { white-space: normal; line-height: 1.25 !important; }
  body.single-product .woocommerce div.product .woocommerce-tabs ul.tabs { display: flex !important; width: 100%; gap: 16px !important; overflow-x: auto; scrollbar-width: none; }
  body.single-product .woocommerce div.product .woocommerce-tabs ul.tabs::-webkit-scrollbar { display: none; }
  body.single-product .woocommerce div.product .woocommerce-tabs ul.tabs li { flex: 0 0 auto; }
  .onebio-trust-badges--product { width: 100%; }
  .onebio-product-accordions { width: 100%; }

  /* Reviews */
  .woocommerce div.product #reviews,
  .woocommerce div.product #reviews #commentform { display: grid !important; grid-template-columns: 1fr !important; }
  .woocommerce div.product #reviews #comments,
  .woocommerce div.product #reviews #review_form_wrapper { width: 100%; min-width: 0; }
  .woocommerce div.product #reviews .commentlist li .comment_container { grid-template-columns: 40px minmax(0,1fr) !important; }
  .woocommerce div.product #reviews .commentlist li img.avatar { width: 40px !important; height: 40px !important; }

  /* Cart */
  body.woocommerce-cart .onebio-commerce-container > .woocommerce { display: block !important; }
  body.woocommerce-cart .cart-collaterals { margin-top: 28px !important; }
  body.woocommerce-cart table.shop_table_responsive tr { display: block; margin-bottom: 14px; border: 1px solid var(--border-light); border-radius: 10px; overflow: hidden; }
  body.woocommerce-cart table.shop_table_responsive tr td { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; text-align: right !important; }
  body.woocommerce-cart table.shop_table_responsive tr td::before { flex: 0 0 auto; }
  body.woocommerce-cart table.shop_table_responsive tr td.product-thumbnail { display: none; }
  body.woocommerce-cart table.shop_table_responsive tr td.actions { display: block; text-align: left !important; }
  body.woocommerce-cart .coupon { display: grid !important; grid-template-columns: 1fr; }
  body.woocommerce-cart .coupon .input-text,
  body.woocommerce-cart .coupon .button,
  body.woocommerce-cart table.shop_table_responsive tr td.actions > .button { width: 100% !important; }

  /* Checkout */
  body.woocommerce-checkout form.checkout { display: block !important; }
  body.woocommerce-checkout #order_review_heading { margin-top: 28px !important; }
  body.woocommerce-checkout #order_review { margin-top: 0 !important; padding: 18px !important; }
  body.woocommerce-checkout .form-row-first,
  body.woocommerce-checkout .form-row-last { width: 100% !important; float: none !important; }
  body.woocommerce-checkout .woocommerce-checkout-review-order-table th,
  body.woocommerce-checkout .woocommerce-checkout-review-order-table td { padding-inline: 6px; overflow-wrap: anywhere; }

  /* Account */
  body.woocommerce-account .onebio-commerce-container > .woocommerce { display: block !important; }
  body.woocommerce-account .woocommerce-MyAccount-navigation { margin-bottom: 24px !important; }
  body.woocommerce-account .woocommerce-MyAccount-navigation ul { display: grid; grid-template-columns: 1fr; }
  body.woocommerce-account .woocommerce-MyAccount-content { padding: 0 !important; }
  body.woocommerce-account .woocommerce-orders-table,
  body.woocommerce-account .woocommerce-table { font-size: .78rem; }

  /* Shop/categories */
  .onebio-shop-hero { gap: 18px !important; margin-bottom: 32px !important; }
  .onebio-shop-hero h1 { font-size: clamp(2.55rem, 13vw, 4.1rem) !important; }
  .onebio-trust-badges--shop { grid-template-columns: 1fr !important; }
  .onebio-category-directory { grid-template-columns: 1fr !important; }
  .onebio-category-directory__card { min-height: 280px; }
  .woocommerce .woocommerce-ordering,
  .woocommerce .woocommerce-result-count { float: none !important; width: 100%; margin: 0 0 14px !important; }
  .woocommerce .woocommerce-ordering select { width: 100%; }

  /* Generic page/footer QA */
  .site-footer__grid { grid-template-columns: 1fr 1fr !important; }
  .footer-brand { grid-column: 1 / -1; }
  .footer-links { min-width: 0; }
  .footer-links a { overflow-wrap: anywhere; }
  .policy-document,
  .form-panel,
  .inquiry-form,
  .community-form,
  .split-copy { width: 100%; max-width: 100%; min-width: 0; }
}

@media (max-width: 480px) {
  .container { width: calc(100% - 24px) !important; }
  .site-footer__grid { grid-template-columns: 1fr !important; }
  .footer-brand { grid-column: auto; }
  body.single-product .woocommerce div.product form.cart { grid-template-columns: 76px minmax(0,1fr) !important; gap: 8px !important; }
  body.single-product .woocommerce div.product form.cart .button { padding-inline: 12px !important; font-size: .64rem !important; }
  body.single-product .woocommerce div.product .flex-control-thumbs { grid-template-columns: repeat(3,minmax(0,1fr)) !important; }
  body.onebio-commerce-page .woocommerce-message,
  body.onebio-commerce-page .woocommerce-info,
  body.onebio-commerce-page .woocommerce-error { padding: 16px !important; }
}
