/* ============================================================ COZY STYLE — Salla Raed Theme JavaScript v7 الصقه في: محرر الثيم ← تخصيص متقدم ← تخصيص باستخدام JavaScript ============================================================ */ (function(){ 'use strict'; var GH = 'https://raw.githubusercontent.com/ALIWOSABY/sallah-store_orig/main/images/'; /* ── helper: run after DOM ready ───────────────────────────── */ function ready(fn){ if(document.readyState!=='loading') fn(); else document.addEventListener('DOMContentLoaded',fn); } /* ══ 1. CUSTOM HEADER ══════════════════════════════════════ */ function injectHeader(){ if(document.getElementById('cozy-header')) return; var hdr = document.createElement('div'); hdr.id = 'cozy-header'; hdr.innerHTML = /* Announcement bar */ '
'+ ''+ 'شحن مجاني على الطلبات التي تزيد عن 200 ريال'+ '
'+ /* Header strip — logo only (no text), clickable → homepage */ '
'+ '
'+ ''+ ''+ ''+ '
'+ '
'; document.body.insertBefore(hdr, document.body.firstChild); } /* ══ 2. CUSTOM HERO ════════════════════════════════════════ */ function injectHero(){ if(document.getElementById('cozy-hero')) return; var hdr = document.getElementById('cozy-header'); if(!hdr){ setTimeout(injectHero, 600); return; } var hero = document.createElement('div'); hero.id = 'cozy-hero'; hero.innerHTML = '
'+ /* Topbar */ '
'+ '
'+ ''+ ''+ ''+ ''+ ''+ ''+ '
'+ ''+ '
'+ /* 2-col grid */ '
'+ '
'+ '

بيتك
يستاهل
الأفضل

'+ '

مستلزمات منزلية بجودة عالية

'+ '

أدوات مطبخ،
ديكور، منظمات، ومستلزمات سفر —
شحن سريع لجميع المناطق

'+ '
'+ '
'+ /* Search */ ''+ /* Glass carousel */ '
'+ '
'+ ''+ ''+ '
'+ '
'+ '
'+ '
'; hdr.insertAdjacentElement('afterend', hero); /* Search enter key */ var inp = document.getElementById('cozySearchInput'); if(inp) inp.addEventListener('keydown', function(e){ if(e.key==='Enter' && this.value) window.location = '/search?q=' + encodeURIComponent(this.value); }); /* Menu button */ var menuBtn = document.getElementById('cozy-menu-open-btn'); if(menuBtn) menuBtn.addEventListener('click', openMenuOverlay); initCarousel(); } /* ── Glass Peek Carousel ────────────────────────────────── */ function initCarousel(){ var stage = document.getElementById('pkStage'); var prev = document.getElementById('pkPrev'); var next = document.getElementById('pkNext'); if(!stage || !prev || !next) return; var LABELS = ['%','Sale','New','🛋️','🪴','🏠']; var cur = 0, N = LABELS.length; function mod(v){ return (v % N + N) % N; } function render(){ stage.innerHTML = ''; var lEl = document.createElement('div'); lEl.className = 'pk-card pk-side pk-left'; lEl.textContent = LABELS[mod(cur - 1)]; stage.appendChild(lEl); var rEl = document.createElement('div'); rEl.className = 'pk-card pk-side pk-right'; rEl.textContent = LABELS[mod(cur + 1)]; stage.appendChild(rEl); var cEl = document.createElement('div'); cEl.className = 'pk-card pk-center'; cEl.textContent = LABELS[cur]; stage.appendChild(cEl); } prev.addEventListener('click', function(){ cur = mod(cur - 1); render(); }); next.addEventListener('click', function(){ cur = mod(cur + 1); render(); }); setInterval(function(){ cur = mod(cur + 1); render(); }, 3900); render(); } /* ══ 3. BANNER SLIDER ══════════════════════════════════════ */ function injectSlider(){ if(document.getElementById('cozy-slider')) return; var hero = document.getElementById('cozy-hero'); if(!hero){ setTimeout(injectSlider, 600); return; } var sl = document.createElement('div'); sl.id = 'cozy-slider'; sl.innerHTML = '
'+ '
'+ '
'; hero.insertAdjacentElement('afterend', sl); initSlider(); } function initSlider(){ var track = document.getElementById('slTrack'); var stage = document.getElementById('slVp'); if(!track || !stage) return; var SLIDES = ['New In','Sale','Decor','Offer','Banar']; var cur = 0, n = SLIDES.length; SLIDES.forEach(function(label, i){ var card = document.createElement('div'); card.className = 'sl-card' + (i === 0 ? ' active' : ''); var span = document.createElement('span'); span.className = 'sl-label'; span.textContent = label; card.appendChild(span); (function(idx){ card.addEventListener('click', function(){ goTo(idx); }); })(i); track.appendChild(card); }); var cards = track.querySelectorAll('.sl-card'); function getW(){ var c = cards[0]; var s = getComputedStyle(c); return c.offsetWidth + parseFloat(s.marginLeft) + parseFloat(s.marginRight); } function goTo(idx){ cur = (idx + n) % n; track.style.transform = 'translateX(calc(-50% + ' + (-cur * getW()) + 'px))'; cards.forEach(function(c, i){ c.classList.toggle('active', i === cur); }); } stage.addEventListener('touchstart', function(e){ stage._tx = e.touches[0].clientX; }, {passive:true}); stage.addEventListener('touchend', function(e){ var dx = e.changedTouches[0].clientX - (stage._tx || 0); if(dx > 50) goTo(cur - 1); if(dx < -50) goTo(cur + 1); }, {passive:true}); setInterval(function(){ goTo(cur + 1); }, 4000); track.style.transition = 'none'; goTo(0); requestAnimationFrame(function(){ requestAnimationFrame(function(){ track.style.transition = ''; }); }); } /* ══ 4. ACC PILL — before products ═════════════════════════ */ function injectAccPill(){ if(document.getElementById('cozy-acc')) return; var target = document.querySelector( 'salla-product-card, .s-product-card, [class*="products-grid"], [class*="product-list"]' ); if(!target){ setTimeout(injectAccPill, 1000); return; } var section = target.closest('section, [class*="section"], [class*="products"]') || target.parentElement; var wrap = document.createElement('div'); wrap.id = 'cozy-acc'; wrap.style.cssText = 'padding:clamp(4px,1.2vw,8px) clamp(12px,3vw,20px) 0'; wrap.innerHTML = '
'+ 'Home Accessories'+ '
'+ ''; section.parentNode.insertBefore(wrap, section); } /* ══ 5. CONTACT SECTION — before footer ════════════════════ */ function injectContactSection(){ if(document.getElementById('cozy-cs')) return; var footer = document.querySelector('footer, salla-footer, .s-footer, #footer'); if(!footer){ setTimeout(injectContactSection, 1000); return; } var cs = document.createElement('div'); cs.id = 'cozy-cs'; cs.className = 'cozy-cs'; cs.innerHTML = '
'+ '
'+ '

تابعنا على:

'+ '
'+ /* Instagram */ ''+ /* TikTok */ ''+ /* Facebook */ ''+ /* WhatsApp */ ''+ '
'+ '
'+ /* Phone CTA */ ''+ '+966 503 676 809'+ '
'+ ''+ ''+ ''+ '
'+ '
'+ /* Info panel */ '
'+ '
'+ ''+ '
'+ 'وزارة التجارة'+ '
'+ '
'+ '
'+ '
STC Bank
'+ '
mada
'+ '
Apple Pay
'+ '
VISA
'+ '
'+ '
'; footer.parentNode.insertBefore(cs, footer); } /* ══ 6. TRANSPARENT BACKGROUNDS ════════════════════════════ */ function fixBackgrounds(){ var els = document.querySelectorAll( 'main, #main, .s-layout, [class*="layout"],[class*="page-wrapper"],[class*="main-content"]' ); els.forEach(function(el){ el.style.background = 'transparent'; el.style.backgroundColor = 'transparent'; el.style.backgroundImage = 'none'; }); } /* ══ 7. FLOATING BOTTOM NAV (all pages) ════════════════════ */ function injectBottomNav(){ if(document.getElementById('cozy-bottom-nav')) return; var nav = document.createElement('nav'); nav.id = 'cozy-bottom-nav'; nav.setAttribute('aria-label','Main navigation'); nav.innerHTML = /* Profile */ ''+ ''+ ''+ /* Home */ ''+ ''+ ''+ /* Cart */ ''+ ''+ ''+ /* Menu toggle */ ''; document.body.appendChild(nav); /* bind menu button after appended */ var mb = document.getElementById('cnb-menu-btn'); if(mb) mb.addEventListener('click', openMenuOverlay); } /* ══ 8. MENU OVERLAY ═══════════════════════════════════════ */ var _menuItems = null; /* Default fallback nav items */ var DEFAULT_MENU = [ { icon:'🏠', name:'الرئيسية', url:'/' }, { icon:'🛋️', name:'أثاث', url:'/categories' }, { icon:'🪴', name:'إكسسوارات', url:'/categories' }, { icon:'✨', name:'وصل حديثاً', url:'/products/new' }, { icon:'🔥', name:'عروض خاصة', url:'/products/sale'}, { icon:'❤️', name:'المفضلة', url:'/wishlist' } ]; function buildMenuItems(items){ return items.map(function(item){ return ''+ '
'+ ''+(item.icon||'🏷️')+''+ ''+item.name+''+ '
'+ ''+ '
'; }).join(''); } /* ── Icon mapper for Arabic category names ──────────────── */ function getCategoryIcon(name){ var n = (name || '').trim(); var exact = { 'حيواناتك':'🐾','منزلك':'🏠','مطبخك':'🍳','حمامك':'🚿', 'حديقتك':'🌿','اطفالك':'👶','سيارتك':'🚗','كهربائياتك':'⚡', 'جوالك':'📱','تخفيضاتك':'🔥','الرئيسية':'🏠','اكسسوارات':'🪴', 'إكسسوارات':'🪴','أثاث':'🛋️','أثاث منزلي':'🛋️','وصل حديثاً':'✨', 'عروض خاصة':'🔥','المفضلة':'❤️','تخفيضات':'🔥' }; if(exact[n]) return exact[n]; var l = n; if(/حيوان|pet/i.test(l)) return '🐾'; if(/منزل|home|بيت/i.test(l)) return '🏠'; if(/مطبخ|kitchen/i.test(l)) return '🍳'; if(/حمام|bath/i.test(l)) return '🚿'; if(/حديق|garden|نبات/i.test(l)) return '🌿'; if(/طفل|child|baby/i.test(l)) return '👶'; if(/سيار|car/i.test(l)) return '🚗'; if(/كهرب|electric/i.test(l)) return '⚡'; if(/جوال|mobile|phone/i.test(l)) return '📱'; if(/تخفيض|sale|خصم/i.test(l)) return '🏷️'; if(/أثاث|furniture/i.test(l)) return '🛋️'; if(/اكسسوار|إكسسوار|access/i.test(l)) return '🪴'; if(/ديكور|decor/i.test(l)) return '🖼️'; return '🏷️'; } /* ── Read Raed theme's existing rendered menu ────────────── */ function readRaedMenu(){ /* Raed renders: #mobile-menu li.lg:hidden > a (one per category) */ var nav = document.querySelector('#mobile-menu, nav.mobile-menu'); if(!nav) return null; var links = nav.querySelectorAll('li.lg\\:hidden > a'); if(!links || !links.length) return null; var seen = {}, result = []; links.forEach(function(a){ var href = a.getAttribute('href') || ''; if(!href || seen[href]) return; seen[href] = true; var spanEl = a.querySelector('span'); var name = (spanEl ? spanEl.textContent : a.textContent).trim(); if(!name) return; result.push({ icon: getCategoryIcon(name), name: name, url: href }); }); return result.length ? result : null; } function parseSallaItems(arr){ var seen = {}, result = []; arr.slice(0,15).forEach(function(m){ var name = m.name || m.title || m.label || ''; var url = m.url || m.link || (m.id ? '/categories/'+m.id : '#'); if(!name || seen[url]) return; seen[url] = true; result.push({ icon: getCategoryIcon(name), name: name, url: url }); }); return result; } function loadSallaNavigation(cb){ if(_menuItems){ cb(_menuItems); return; } /* ── Strategy 0: Read Raed theme's already-rendered #mobile-menu ── */ /* This is the most reliable: the HTML is already in the DOM */ var fromDom = readRaedMenu(); if(fromDom && fromDom.length){ _menuItems = fromDom; cb(_menuItems); return; } /* ── Strategy 1-2: salla.store object ── */ try { var sm = window.salla && window.salla.store && window.salla.store.menus; if(sm && sm.length){ _menuItems = parseSallaItems(sm); return cb(_menuItems); } } catch(e){} try { var sc = window.salla && window.salla.store && window.salla.store.categories; if(sc && sc.length){ _menuItems = parseSallaItems(sc); return cb(_menuItems); } } catch(e){} /* ── Strategy 3: salla.config ── */ try { var cfg = window.salla && window.salla.config; var cfgCats = cfg && (cfg.categories || (cfg.store && cfg.store.categories)); if(cfgCats && cfgCats.length){ _menuItems = parseSallaItems(cfgCats); return cb(_menuItems); } } catch(e){} /* ── Strategy 4: Wait for #mobile-menu to appear in DOM ── */ /* (Raed may render it slightly after our script runs) */ var domWait = 0; var domTimer = setInterval(function(){ domWait += 200; var items = readRaedMenu(); if(items && items.length){ clearInterval(domTimer); _menuItems = items; cb(_menuItems); return; } if(domWait >= 3000){ clearInterval(domTimer); fetchCategories(); } }, 200); function fetchCategories(){ fetch('/api/store/v1/categories', { credentials:'same-origin' }) .then(function(r){ return r.ok ? r.json() : Promise.reject(); }) .then(function(data){ var arr = data && data.data; if(arr && arr.length){ _menuItems = parseSallaItems(arr); cb(_menuItems); } else useFallback(); }) .catch(useFallback); } function useFallback(){ _menuItems = DEFAULT_MENU; cb(DEFAULT_MENU); } } function injectMenuOverlay(){ if(document.getElementById('cmo-overlay')) return; /* Backdrop */ var backdrop = document.createElement('div'); backdrop.id = 'cmo-backdrop'; backdrop.addEventListener('click', closeMenuOverlay); document.body.appendChild(backdrop); /* Overlay wrap */ var ov = document.createElement('div'); ov.id = 'cmo-overlay'; ov.setAttribute('aria-modal','true'); ov.setAttribute('role','dialog'); ov.setAttribute('aria-label','القائمة الرئيسية'); ov.innerHTML = '
'+ /* Header */ '
'+ ''+ ''+ '
'+ /* Category list placeholder */ '
'+ '
Loading…
'+ '
'+ /* Footer */ ''+ '
'; document.body.appendChild(ov); /* Close button */ document.getElementById('cmo-close-btn').addEventListener('click', closeMenuOverlay); /* ESC key */ document.addEventListener('keydown', function(e){ if(e.key === 'Escape'){ closeMenuOverlay(); closeContactModal(); } }); /* Contact link → open modal, no page navigation */ var contactBtn = document.getElementById('cmo-contact-link'); if(contactBtn) contactBtn.addEventListener('click', function(){ closeMenuOverlay(); openContactModal(); }); /* About link → open about modal */ var aboutBtn = document.getElementById('cmo-about-link'); if(aboutBtn) aboutBtn.addEventListener('click', function(){ closeMenuOverlay(); openAboutModal(); }); /* Policy / الشروط والأحكام */ var policyBtn = document.getElementById('cmo-policy-link'); if(policyBtn) policyBtn.addEventListener('click', function(){ closeMenuOverlay(); openPolicyModal(); }); /* Load navigation items — re-reads Raed DOM on each open */ function refreshMenuItems(){ /* Always try Raed DOM first (freshest source) */ var live = readRaedMenu(); if(live && live.length) _menuItems = live; loadSallaNavigation(function(items){ var list = document.getElementById('cmo-cat-list'); if(list) list.innerHTML = buildMenuItems(items); }); } refreshMenuItems(); } function openMenuOverlay(){ if(!document.getElementById('cmo-overlay')) injectMenuOverlay(); var ov = document.getElementById('cmo-overlay'); var bd = document.getElementById('cmo-backdrop'); if(!ov) return; /* Re-read Raed DOM every open so menu is always fresh */ var live = readRaedMenu(); if(live && live.length){ _menuItems = live; var list = document.getElementById('cmo-cat-list'); if(list) list.innerHTML = buildMenuItems(live); } document.body.style.overflow = 'hidden'; if(bd){ bd.style.display = 'block'; requestAnimationFrame(function(){ bd.style.opacity = '1'; }); } ov.classList.add('cmo-open'); } function closeMenuOverlay(){ var ov = document.getElementById('cmo-overlay'); var bd = document.getElementById('cmo-backdrop'); if(ov) ov.classList.remove('cmo-open'); if(bd){ bd.style.opacity = '0'; setTimeout(function(){ bd.style.display = 'none'; }, 300); } document.body.style.overflow = ''; } /* ══ 9. CONTACT MODAL ══════════════════════════════════════ */ function injectContactModal(){ if(document.getElementById('cozy-contact-modal')) return; var m = document.createElement('div'); m.id = 'cozy-contact-modal'; m.innerHTML = '
'+ '
'+ '
'+ ''+ /* Social */ '
'+ ''+ ''+ '
'+ /* Phone CTA */ ''+ '+966 503 676 809'+ '
'+ ''+ ''+ ''+ '
'+ '
'+ /* Info panel */ '
'+ '
'+ ''+ '
'+ 'وزارة التجارة'+ '
'+ '
'+ '
'+ '
STC Bank
'+ '
mada
'+ '
Apple Pay
'+ '
VISA
'+ '
'+ '
'+ '
'; document.body.appendChild(m); document.getElementById('ccm-backdrop').addEventListener('click', closeContactModal); document.getElementById('ccm-close').addEventListener('click', closeContactModal); } function openContactModal(){ if(!document.getElementById('cozy-contact-modal')) injectContactModal(); var m = document.getElementById('cozy-contact-modal'); if(m){ m.classList.add('ccm-open'); document.body.style.overflow = 'hidden'; } } function closeContactModal(){ var m = document.getElementById('cozy-contact-modal'); if(m){ m.classList.remove('ccm-open'); document.body.style.overflow = ''; } } /* ══ ABOUT MODAL ════════════════════════════════════════════ */ function openAboutModal(){ if(!document.getElementById('cozy-about-modal')){ var m = document.createElement('div'); m.id = 'cozy-about-modal'; m.innerHTML = '
'+ '
'+ '
'+ ''+ '
'+ '
'+ '
'+ 'Cozy Style'+ '
'+ '

من نحن

'+ '
'+ '
'+ '
'+ '

'+ 'مرحبًا بكم في Cozy Style — متجرنا الإلكتروني المتخصص في توفير منتجات منزلية عملية وأنيقة تجعل حياتك اليومية أسهل وأكثر راحة. '+ 'نؤمن أن التفاصيل الصغيرة في المنزل تصنع فرقًا كبيرًا، لذا نحرص على اختيار كل منتج بعناية ليجمع بين الجودة والتصميم العملي والسعر المناسب.'+ '

'+ '
'+ '
'+ '

🎯 رؤيتنا

'+ '

أن نكون وجهتك المفضلة للحصول على منتجات منزلية عملية وعصرية تلبّي احتياجات المنازل الحديثة.

'+ '
'+ '
'+ '

💡 رسالتنا

'+ '

توفير منتجات مبتكرة تساعد على تحسين جودة الحياة اليومية داخل المنزل — من المطبخ والحمام إلى الديكور والتنظيم.

'+ '
'+ '
'+ '

✅ لماذا Cozy Style؟

'+ '

'+ '✔ منتجات مختارة بعناية
'+ '✔ جودة عالية وأسعار مناسبة
'+ '✔ تجربة تسوق سهلة وآمنة
'+ '✔ دعم عملاء سريع وموثوق
'+ '✔ شحن سريع من 3 إلى 10 أيام عمل'+ '

'+ '
'+ '
'+ '

🛍️ ما يميّزنا

'+ '
'+ '🏠 مستلزمات المنزل'+ '🍳 مستلزمات المطبخ'+ '🪴 إكسسوارات'+ '🖼️ ديكور المنزل'+ '✨ منتجات جديدة'+ '🔥 عروض وتخفيضات'+ '🚗 مستلزمات السيارة'+ '📱 إلكترونيات ذكية'+ '
'+ '
'+ '
'+ '
'+ '
'; document.body.appendChild(m); document.getElementById('cam-backdrop').addEventListener('click', function(){ m.classList.remove('ccm-open'); document.body.style.overflow = ''; }); document.getElementById('cam-close').addEventListener('click', function(){ m.classList.remove('ccm-open'); document.body.style.overflow = ''; }); } var m2 = document.getElementById('cozy-about-modal'); if(m2){ m2.classList.add('ccm-open'); document.body.style.overflow = 'hidden'; } } /* ══ POLICY MODAL ════════════════════════════════════════════ */ function openPolicyModal(){ var id = 'cozy-policy-modal'; if(!document.getElementById(id)){ var m = document.createElement('div'); m.id = id; m.innerHTML = '
'+ '
'+ '
'+ ''+ '
'+ '
'+ '
'+ ''+ '
'+ '

الشروط والأحكام

'+ '
'+ '
'+ '
'+ '

١. قبول الشروط

'+ '

باستخدامك لمتجر Cozy Style فإنك توافق على الالتزام بهذه الشروط والأحكام. إذا كنت لا توافق على أي جزء من هذه الشروط، يرجى عدم استخدام المتجر.

'+ '
'+ '
'+ '

٢. المنتجات والأسعار

'+ '

نحتفظ بحق تعديل الأسعار في أي وقت دون إشعار مسبق. جميع الأسعار مشمولة ضريبة القيمة المضافة. الصور المعروضة للتوضيح فقط وقد تختلف قليلاً عن المنتج الفعلي.

'+ '
'+ '
'+ '

٣. الشحن والتوصيل

'+ '

يتم الشحن خلال ٢-٥ أيام عمل. شحن مجاني للطلبات التي تتجاوز ٢٠٠ ريال. نحن غير مسؤولين عن التأخير الناتج عن شركات الشحن أو الظروف الخارجة عن إرادتنا.

'+ '
'+ '
'+ '

٤. الإرجاع والاستبدال

'+ '

يمكن إرجاع المنتجات خلال ٧ أيام من الاستلام بشرط أن تكون في حالتها الأصلية وغير مستخدمة. تحمّل رسوم الشحن العكسي على العميل ما لم يكن المنتج معيباً.

'+ '
'+ '
'+ '

٥. الخصوصية

'+ '

نحن نحترم خصوصيتك ولن نشارك بياناتك الشخصية مع أي طرف ثالث إلا عند الضرورة القانونية أو لأغراض التوصيل.

'+ '
'+ '
'+ '

٦. تواصل معنا

'+ '

لأي استفسار حول هذه الشروط يمكنك التواصل معنا عبر واتساب على الرقم 966503676809+ أو عبر منصات التواصل الاجتماعي.

'+ '
'+ '
'+ '
'+ '
'; document.body.appendChild(m); document.getElementById('cpol-backdrop').addEventListener('click', function(){ m.classList.remove('ccm-open'); document.body.style.overflow = ''; }); document.getElementById('cpol-close').addEventListener('click', function(){ m.classList.remove('ccm-open'); document.body.style.overflow = ''; }); } var m2 = document.getElementById(id); if(m2){ m2.classList.add('ccm-open'); document.body.style.overflow = 'hidden'; } } /* ══ 10. PRODUCT CARDS — Shadow DOM injection ════════════════ */ /* Matches designer p-card exactly: LEFT = wishlist (red circle) RIGHT = quick-add (dark gradient square) IMAGE = white square (aspect-ratio 1:1) PILL = "اضافة للسلة" gradient full-width NAME = clean text (no box bg) PRICE = clean brown text (no box bg) */ var SHADOW_CSS = /* ── Card base ── */ ':host{'+ 'background:rgba(252,248,244,.95)!important;'+ 'border-radius:clamp(14px,3.5vw,22px)!important;'+ 'padding:clamp(10px,2.5vw,16px)!important;'+ 'display:flex!important;flex-direction:column!important;align-items:center!important;'+ 'box-shadow:0 2px 14px rgba(0,0,0,.09)!important;'+ 'overflow:hidden!important;border:1px solid rgba(196,168,130,.18)!important;'+ '}'+ /* ── NUKE duplicate inner-card backgrounds (the ugly layered boxes) ── */ '[class*="content"],[class*="info"],[class*="footer"],[class*="details"],'+ '[class*="body"],[class*="text"],[class*="meta"],[class*="bottom"],'+ '[class*="data"],[class*="wrap"],[class*="block"],[class*="section"]{'+ 'background:transparent!important;box-shadow:none!important;'+ 'border-radius:0!important;border:none!important;padding:0!important;'+ '}'+ /* ── Image – transparent container, image fills card cleanly ── */ '[part="image"],[class*="image"],[class*="img"],[class*="media"],'+ '[class*="thumb"],[class*="photo"],[class*="picture"]{'+ 'background:transparent!important;'+ 'border-radius:clamp(10px,2.5vw,16px)!important;'+ 'aspect-ratio:1/1!important;width:100%!important;'+ 'display:flex!important;align-items:center!important;justify-content:center!important;'+ 'padding:clamp(4px,1vw,8px)!important;'+ 'margin-bottom:clamp(8px,2vw,14px)!important;'+ 'overflow:hidden!important;'+ '}'+ 'img{max-width:100%!important;max-height:100%!important;object-fit:contain!important;}'+ /* ── Wishlist – RED circle (left) ── */ '[part="wishlist"],salla-wishlist-btn,'+ 'button[class*="wish"],button[class*="fav"],'+ '[class*="wishlist-btn"],[class*="favourite-btn"]{'+ 'background:rgba(255,71,87,.12)!important;'+ 'border-radius:50%!important;'+ 'width:clamp(32px,8vw,40px)!important;height:clamp(32px,8vw,40px)!important;'+ 'border:none!important;cursor:pointer!important;'+ 'display:flex!important;align-items:center!important;justify-content:center!important;'+ 'flex-shrink:0!important;transition:background .2s!important;'+ '}'+ '[part="wishlist"] svg,button[class*="wish"] svg,salla-wishlist-btn svg,'+ '[class*="wishlist-btn"] svg{stroke:#ff4757!important;fill:none!important;'+ 'width:clamp(16px,4vw,20px)!important;height:clamp(16px,4vw,20px)!important;}'+ /* ── Quick-add top-right – dark gradient SQUARE ── */ '[part="add"],[class*="quick-add"],button[class*="fast"],[class*="add-quick"]{'+ 'background:linear-gradient(135deg,#1A1411 0%,#755C4C 100%)!important;'+ 'border-radius:clamp(10px,2.5vw,15px)!important;'+ 'width:clamp(32px,8vw,40px)!important;height:clamp(32px,8vw,40px)!important;'+ 'border:none!important;cursor:pointer!important;'+ 'display:flex!important;align-items:center!important;justify-content:center!important;'+ 'box-shadow:0 4px 12px rgba(26,20,17,.30)!important;flex-shrink:0!important;'+ '}'+ '[part="add"] svg,[class*="quick-add"] svg{stroke:#fff!important;fill:none!important;}'+ /* ── Add-to-cart pill (bottom, full-width) ── */ '[part="add-to-cart"],salla-add-product-button button,'+ 'button[class*="add-to-cart"],button[class*="add-cart"],'+ '[class*="add-product"] button,[class*="cart-btn"]{'+ 'background:linear-gradient(135deg,#1A1411 0%,#755C4C 100%)!important;'+ 'border-radius:999px!important;width:100%!important;'+ 'color:#fff!important;font-weight:800!important;'+ 'padding:clamp(10px,2.5vw,14px) 6px!important;'+ 'border:none!important;cursor:pointer!important;'+ 'font-size:clamp(11px,2.8vw,15px)!important;'+ 'margin:clamp(6px,1.5vw,10px) 0 clamp(3px,.8vw,5px)!important;'+ 'display:block!important;text-align:center!important;'+ 'box-shadow:0 4px 14px rgba(26,20,17,.24)!important;'+ '}'+ /* ── Product name – clean text, NO box ── */ '[part="name"],[class*="name"],[class*="title"]{'+ 'font-weight:700!important;font-size:clamp(11px,2.8vw,15px)!important;'+ 'color:#1A1411!important;text-align:center!important;'+ 'margin-bottom:clamp(2px,.6vw,4px)!important;'+ 'background:transparent!important;box-shadow:none!important;'+ 'border-radius:0!important;border:none!important;padding:2px 0!important;'+ '}'+ /* ── Price – clean brown text, NO box ── */ '[part="price"],[class*="price"],salla-price{'+ 'font-weight:800!important;font-size:clamp(11px,2.8vw,15px)!important;'+ 'color:#755C4C!important;text-align:center!important;'+ 'background:transparent!important;box-shadow:none!important;'+ 'border-radius:0!important;border:none!important;padding:0!important;'+ '}'; function styleProductCards(){ var cards = document.querySelectorAll('salla-product-card'); cards.forEach(function(card){ if(card._cozyStyled) return; card._cozyStyled = true; function injectShadow(){ if(!card.shadowRoot) return; var existing = card.shadowRoot.querySelector('#cozy-shadow-style'); if(existing) return; var st = document.createElement('style'); st.id = 'cozy-shadow-style'; st.textContent = SHADOW_CSS; card.shadowRoot.appendChild(st); } /* If shadow root already open, inject now */ if(card.shadowRoot){ injectShadow(); return; } /* Wait for shadow root via MutationObserver on the card */ var ob = new MutationObserver(function(){ if(card.shadowRoot){ injectShadow(); ob.disconnect(); } }); ob.observe(card, {childList:true, subtree:true, attributes:true}); /* Also watch for custom element upgrade */ customElements.whenDefined(card.localName).then(function(){ setTimeout(function(){ if(card.shadowRoot) injectShadow(); }, 100); }).catch(function(){}); }); } /* ══ 10. MUTATION OBSERVER — re-run on dynamic load ════════ */ function observe(){ var _navChecked = false; var ob = new MutationObserver(function(){ injectHeader(); injectAccPill(); injectContactSection(); injectBottomNav(); fixBackgrounds(); styleProductCards(); if(!_navChecked && isProductPage()){ handleProductPageNav(); _navChecked = true; } if(isHomepage()){ injectHero(); injectSlider(); } if(isContactPage()) injectContactCard(); }); ob.observe(document.body, {childList:true, subtree:true}); } /* ══ PAGE HELPERS ═══════════════════════════════════════════ */ function isHomepage(){ var p = window.location.pathname; return p === '/' || p === '/index.html' || p === ''; } function isContactPage(){ var p = window.location.pathname; return /contact|تواصل/i.test(p) || p === '/contactus' || p === '/contact-us' || /\/pages\/contact/i.test(p); } function isWishlistPage(){ var p = window.location.pathname; return /wish|favour|favorite/i.test(p); } function isProductPage(){ var p = window.location.pathname; /* URL-based: /products/slug or /p/slug */ if(/^\/products\/[^\/\?]+/.test(p)) return true; if(/^\/p\/[^\/\?]+/.test(p)) return true; /* DOM-based: quantity stepper or buy buttons (only exist on product detail pages) */ if(document.querySelector('salla-quantity-input, salla-add-to-cart, salla-buy-now, salla-product-form')) return true; return false; } function handleProductPageNav(){ if(isProductPage()){ document.body.classList.add('cozy-product-page'); } } /* ══ 11. CONTACT PAGE CARD ══════════════════════════════════ */ function injectContactCard(){ if(document.getElementById('cozy-contact-card')) return; var form = document.querySelector( 'salla-contact-form, [class*="contact-form"], [id*="contact-form"], form' ); var main = document.querySelector( 'main, #main, .s-layout, [class*="layout"], [class*="page-content"], [class*="content-wrap"], body' ); var target = form || main; if(!target){ setTimeout(injectContactCard, 1000); return; } var card = document.createElement('div'); card.id = 'cozy-contact-card'; card.innerHTML = /* Social */ '
'+ '

تابعونا على:

'+ '
'+ ''+ ''+ ''+ ''+ '
'+ '
'+ /* Phone CTA */ ''+ '+966 503 676 809'+ '
'+ ''+ ''+ ''+ '
'+ '
'+ /* Info panel */ '
'+ '
'+ ''+ '
'+ 'وزارة التجارة'+ '
'+ '
'+ '
'+ '
STC Bank
'+ '
mada
'+ '
Apple Pay
'+ '
VISA
'+ '
'+ '
'; if(form){ form.parentNode.insertBefore(card, form); } else { target.insertBefore(card, target.firstChild); } } ready(function(){ fixBackgrounds(); injectHeader(); injectBottomNav(); handleProductPageNav(); styleProductCards(); if(isHomepage()){ injectHero(); injectSlider(); injectAccPill(); injectContactSection(); } else { injectContactSection(); } if(isContactPage()) injectContactCard(); observe(); /* re-run after lazy content */ setTimeout(function(){ injectHeader(); injectBottomNav(); handleProductPageNav(); fixBackgrounds(); styleProductCards(); if(isHomepage()){ injectHero(); injectSlider(); injectAccPill(); injectContactSection(); } if(isContactPage()) injectContactCard(); }, 2000); }); })();