/* Elementor add-to-cart overrides to prevent specification textarea overlapping quantity/button */
:is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .wc-item-specification{order:1;flex-basis:100%;width:100%;margin-top:.5rem}
:is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .wc-item-specification textarea{max-width:100%;padding:10px 140px 10px 10px !important;box-sizing:border-box;min-height:64px;resize:vertical}
:is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .quantity{z-index:6;position:relative;flex:0 0 72px;margin:0 12px}
:is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .quantity .qty{width:56px;text-align:center;border-radius:28px;padding:6px 10px}
:is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .single_add_to_cart_button{z-index:6;position:relative;flex:0 0 140px}

/* Additional safety: constrain spec field so qty/button have reserved space */
:is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .wc-item-specification{max-width:calc(100% - 220px) !important}

/* Mobile: stack cleanly */
@media (max-width:720px){
  :is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart{display:block}
  :is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .wc-item-specification{width:100%;max-width:100% !important;padding-right:12px !important}
  :is(.elementor-widget-woocommerce-product-add-to-cart,.woocommerce div.product .elementor-widget-woocommerce-product-add-to-cart) form.cart .quantity{margin:8px 0}
}

/* Specific targeting for the actual textarea element (ID and wrapper) */
#item_specification,
.wc-item-specification textarea {
  width: 320px !important;
  max-width: 100% !important;
  min-width: 220px !important;
  min-height: 76px !important;
  padding: 10px 160px 10px 10px !important; /* reserve space on right for qty+button */
  box-sizing: border-box !important;
  border: 1px solid #ddd !important;
  border-radius: 6px !important;
  font-size: 14px !important;
  line-height: 1.3 !important;
  resize: vertical !important;
}

/* When variations are present, reserve extra space */
.single-product form.cart.variations_form #item_specification,
.single-product form.cart.variations_form .wc-item-specification textarea {
  padding-right: 180px !important;
  max-width: calc(100% - 260px) !important;
}

@media (max-width:720px){
  #item_specification,
  .wc-item-specification textarea {
    width:100% !important;
    padding-right:12px !important;
    min-width:0 !important;
  }
}

/* PDF icon fallback styling: ensure small icon size when image exists */
img[src*="pdf-icon"], img[src*=".pdf"]{height:20px !important; width:auto !important; max-width:none !important; display:inline-block}

/* If the PDF image fails to load, show a small SVG fallback inline via background */
img[src*="pdf-icon"]{background-repeat:no-repeat;background-position:center;background-size:contain;background-image:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="100%" height="100%" fill="none"/><path fill="%23d33" d="M6 2h7l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2z"/><text x="50%" y="62%" font-size="9" text-anchor="middle" fill="%23fff" font-family="Arial,Helvetica,sans-serif">PDF</text></svg>')}

/* User-provided exact sizing/padding for the specification textarea */
.wc-item-specification { display:inline-block; }
#item_specification,
.wc-item-specification textarea {
  padding-right: 24px !important;
  box-sizing: border-box !important;
  min-width: 20px !important;
  max-width: 430px !important;
  height: 114px !important;
  width: auto !important;
}

