/** Shopify CDN: Minification failed

Line 46:0 Unexpected "("
Line 47:2 Comments in CSS use "/* ... */" instead of "//"
Line 69:4 Comments in CSS use "/* ... */" instead of "//"
Line 73:4 Comments in CSS use "/* ... */" instead of "//"
Line 77:4 Comments in CSS use "/* ... */" instead of "//"
Line 92:19 Comments in CSS use "/* ... */" instead of "//"
Line 97:2 Comments in CSS use "/* ... */" instead of "//"
Line 100:2 Comments in CSS use "/* ... */" instead of "//"
Line 105:46 Comments in CSS use "/* ... */" instead of "//"
Line 108:2 Comments in CSS use "/* ... */" instead of "//"

**/
/* ✅ B2Bridge (Prestige): Titel + Preis mittig auf Collection */
.shopify-section--main-collection .b2bridge-card-wrapper{
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  width: 100% !important;
}

/* Titel-Link (bei dir: a.b2bridge-product-link) */
.shopify-section--main-collection a.b2bridge-product-link{
  display: block !important;
  width: 100% !important;
  text-align: center !important;
  margin: 0 auto !important;
}

/* Preis-Wrapper mittig */
.shopify-section--main-collection .b2bridge-price-wrapper{
  width: 100% !important;
  display: flex !important;
  justify-content: center !important;
  align-items: baseline !important;
  margin-top: 6px !important;
}

/* Preis selbst */
.shopify-section--main-collection .b2bridge-product-price{
  display: inline-block !important;
}

(() => {
  // nur Produktseiten
  if (!document.documentElement.classList.contains('template-product')) return;

  const HOST_SEL = 'b2bridge-product-table';
  let done = false;

  const fire = (el, type) => {
    try {
      el.dispatchEvent(new Event(type, { bubbles: true, composed: true }));
    } catch {
      el.dispatchEvent(new Event(type, { bubbles: true }));
    }
  };

  const setQtyToOneAndTouch = (root) => {
    const qty = root.querySelector('input[name="quantity"], input[type="number"], [role="spinbutton"]');
    const btn = root.querySelector('button.b2bridge-product-add-to-cart-btn, button.btn-checkout, button[type="submit"]');
    if (!qty || !btn) return false;

    const current = parseInt(qty.value || qty.getAttribute('aria-valuenow') || '0', 10) || 0;
    const val = current >= 1 ? current : 1;

    // value setzen
    if ('value' in qty) qty.value = String(val);
    qty.setAttribute && qty.setAttribute('aria-valuenow', String(val));

    // "anfassen" wie du es manuell machst
    try { qty.focus(); } catch {}
    try { qty.click(); } catch {}

    // B2Bridge muss input/change sehen
    fire(qty, 'input');
    fire(qty, 'change');

    return true;
  };

  const tryPrime = () => {
    if (done) return;

    const host = document.querySelector(HOST_SEL);
    const root = host && host.shadowRoot;
    if (!root) return;

    if (setQtyToOneAndTouch(root)) {
      done = true; // ✅ danach fertig, nix mehr laufen lassen
      obs && obs.disconnect();
    }
  };

  // 1) schnell versuchen
  tryPrime();

  // 2) kurz warten (B2Bridge rendert verzögert)
  let tries = 0;
  const t = setInterval(() => {
    tries++;
    tryPrime();
    if (done || tries > 40) clearInterval(t); // max ~8s
  }, 200);

  // 3) minimaler Observer (nur bis done)
  const obs = new MutationObserver(tryPrime);
  obs.observe(document.body, { childList: true, subtree: true });
})();