document.addEventListener('DOMContentLoaded', function() {
    function updateSallaText() {
        const headers = document.querySelectorAll('h2');
        
        headers.forEach(el => {
            const text = el.textContent.trim();
            
            if (text.toLowerCase().includes('usually purchased together')) {
                el.textContent = 'COMPLETE THE LOOK';
            }
            
            if (text.includes('شراؤها') || text.includes('معا') || text.includes('معاً')) {
                el.textContent = 'أكملي إطلالتك';
            }
        });
    }
    updateSallaText();
    window.onload = updateSallaText;
    const observer = new MutationObserver(() => {
        updateSallaText();
    });
    
    observer.observe(document.body, { 
        childList: true, 
        subtree: true 
    });
});

document.addEventListener('DOMContentLoaded', function () {
  const description = document.querySelector('article.full-description');
  const stickyBar = document.querySelector('section.sticky-product-bar');
  if (description && stickyBar) {
    stickyBar.after(description);
  }

  // إخفاء التابات (الوصف/الأسئلة)
  const reviewsTabs = document.querySelector('#product-tabs');
  if (reviewsTabs) {
    reviewsTabs.style.display = 'none';
  }

  // ✅ إخفاء التقييمات من صفحة المنتج
  const productFaqsTab = document.querySelector('#product-tabs-faqs');
  if (productFaqsTab) {
    productFaqsTab.style.display = 'none';
  }
  const sallaComments = document.querySelectorAll('salla-comments[type="product"]');
  sallaComments.forEach(el => {
    el.style.display = 'none';
  });
  const reviewsSummary = document.querySelectorAll('salla-reviews-summary');
  reviewsSummary.forEach(el => {
    el.style.display = 'none';
  });

  // نقل قسم "أكملي إطلالتك" تحت الوصف
  const completeTheLook = document.querySelector('div.buy-with');
  if (completeTheLook && description) {
    description.after(completeTheLook);
    completeTheLook.style.marginTop = '40px';
  }
});

document.addEventListener("DOMContentLoaded", function () {
  if (document.documentElement.dir === "ltr") {
    const options = document.querySelectorAll('.s-product-options-digital-card-option');
    options.forEach(el => {
      el.style.display = "inline-flex";
      el.style.visibility = "visible";
      el.style.opacity = "1";
    });
  }
});