document.addEventListener("DOMContentLoaded", function () {
    const container = document.querySelector(".store-header .navbar-brand");
    if (container) {
        const icons = document.createElement("div");
        icons.className = "custom-icons";
        icons.innerHTML = `
            
            
                
                0
            
            
        `;
        container.parentNode.insertBefore(icons, container);
        setInterval(() => {
            const originalCount = document.querySelector(".s-cart-summary-count");
            const customCount = document.querySelector(".custom-cart-count");
            if (originalCount && customCount) {
                customCount.textContent = originalCount.textContent.trim();
            }
        }, 1000);
        
        document.getElementById("custom-search-btn")?.addEventListener("click", function (e) {
            e.preventDefault();
            salla.event.dispatch('search::open');
        });
        
        const loginBtn = document.getElementById("custom-login-btn");
        if (loginBtn) {
            loginBtn.addEventListener("click", function (e) {
                e.preventDefault();
              if (document.body.classList.contains("customer-logged-in")) {
    document.querySelector(".s-user-menu-trigger")?.click();
} else {
    salla.event.dispatch('login::open');
}
            });
        }
    }
});
document.addEventListener('DOMContentLoaded', function () {
  const paragraphs = document.querySelectorAll('p.ql-align-right, .store-footer p');
  let target = null;
  paragraphs.forEach(p => {
    const txt = (p.textContent || '').trim();
    if (txt.includes('هيرو تصنع لك تجربة تنظيف') || txt.includes('تجربة تنظيف')) {
      target = p;
    }
  });
  if (!target) {
    const col = document.querySelector('.store-footer .container > div');
    if (col) target = col.querySelector('p') || col;
  }
  if (!target) return; 
  const wrapper = document.createElement('div');
  wrapper.className = 'hero-certified-wrapper';
  const link = document.createElement('a');
  link.href = 'https://eauthenticate.saudibusiness.gov.sa/certificate-details/3120971864'; 
  link.target = '_blank';
  link.rel = 'noopener noreferrer';
  link.className = 'hero-certified-link';
  const img = document.createElement('img');
  img.src = 'https://cdn.salla.network/cdn-cgi/image/fit=scale-down,width=58,height=58,onerror=redirect,format=auto/images/sbc.png';
  img.alt = 'موثق لدى منصة الأعمال';
  img.className = 'hero-certified-img';
  img.loading = 'lazy';
  link.appendChild(img);
  const certifiedText = document.createElement('div');
  certifiedText.className = 'hero-certified-text';
  certifiedText.textContent = 'موثق لدى منصة الأعمال';
  wrapper.appendChild(link);
  wrapper.appendChild(certifiedText);
  target.insertAdjacentElement('afterend', wrapper);
});
document.addEventListener("DOMContentLoaded", function() {
    let heroColumn = document.querySelector(".store-footer__inner .lg\\:col-span-2");
    if (heroColumn) {
        let logoLink = document.createElement("a");
        logoLink.href = "https://try-hero.com/";
        logoLink.target = "_blank";
        logoLink.style.display = "inline-block";
        logoLink.style.marginBottom = "10px";
        let logoImg = document.createElement("img");
        logoImg.src = "https://cdn.salla.sa/cdn-cgi/image/fit=scale-down,width=400,height=400,onerror=redirect,format=auto/pQgzQr/f8ftEhVNwgto2N6rx90SnEypVxgPb9p63eHx4Fr2.png";
        logoImg.style.maxWidth = "80px";
        logoImg.style.height = "auto";
        logoLink.appendChild(logoImg);
        heroColumn.insertBefore(logoLink, heroColumn.children[1]);
    }
});
(function changeReviewsTitle() {
  const NEW_TEXT = "وش يقولون الناس عن هيرو؟";
  function apply() {
    const el = document.querySelector(".s-reviews-header-wrapper .s-reviews-header");
    if (el) {
      if (el.textContent.trim() !== NEW_TEXT) {
        el.textContent = NEW_TEXT;
      }
      
      el.style.textAlign = "center";
      el.style.display = "block";
      el.style.margin = "0 auto";     
      el.style.marginTop = "0";       
      el.style.marginBottom = "30px";
      el.style.color = "#015687";        
      return true;
    }
    return false;
  }
  if (apply()) return;
  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", apply);
  } else {
    apply();
  }
  const observer = new MutationObserver(() => apply());
  observer.observe(document.body, { childList: true, subtree: true });
  let tries = 0;
  const timer = setInterval(() => {
    if (apply() || ++tries > 20) clearInterval(timer);
  }, 300);
})();
(function() {
  var meta = document.createElement('meta');
  meta.name = 'theme-color';
  meta.content = '#006a4e';
  document.getElementsByTagName('head')[0].appendChild(meta);
})();