
(function($) {




var swiper = new Swiper(".mySwiper", {
  speed: 1200,
  autoplay: {
    delay: 5000, // Wait 5 seconds before sliding to the next
    disableOnInteraction: false,
  },
  loop: true, // Optional: enables infinite looping
  navigation: {
    nextEl: ".swiper-button-next",
    prevEl: ".swiper-button-prev",
  },
  pagination: {
    el: ".swiper-pagination",
    clickable: true,
  },
  mousewheel: false,
  keyboard: true,
});



	// slick_slider_active

	var witrbslick = $('.categorie_active');				
		if(witrbslick.length > 0){
		witrbslick.slick({
			infinite: true,
			autoplay: true,
			autoplaySpeed: 500,
			speed: 1000,					
			slidesToShow: 9,
			slidesToScroll: 1,
			arrows: true,
			dots: false,
			responsive: [
				{
					breakpoint: 1200,
					settings: {
						slidesToShow: 6,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 992,
					settings: {
						slidesToShow: 5,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 767,
					settings: {
						slidesToShow: 3,
						slidesToScroll: 1,
					}
				}
				]
			});
		}


// collection_active
	var witrbslick = $('.collection_active');				
		if(witrbslick.length > 0){
		witrbslick.slick({
			infinite: true,
			autoplay: true,
			autoplaySpeed: 3000,
			speed: 1000,					
			slidesToShow: 6,
			slidesToScroll: 2,
			arrows: true,
			dots: true,
			responsive: [
				{
					breakpoint: 1200,
					settings: {
						slidesToShow: 4,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 992,
					settings: {
						slidesToShow: 4,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 767,
					settings: {
						slidesToShow: 2,
						slidesToScroll: 1,
					}
				}
				]
			});
		}





// collection_punjabi_active
	var witrbslick = $('.collection_punjabi_active');				
		if(witrbslick.length > 0){
		witrbslick.slick({
			infinite: true,
			autoplay: true,
			autoplaySpeed: 3000,
			speed: 1000,					
			slidesToShow: 6,
			slidesToScroll: 2,
			arrows: true,
			dots: true,
			responsive: [
				{
					breakpoint: 1200,
					settings: {
						slidesToShow: 4,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 992,
					settings: {
						slidesToShow: 4,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 767,
					settings: {
						slidesToShow: 2,
						slidesToScroll: 1,
					}
				}
				]
			});
		}






// collection_wllet_active
	var witrbslick = $('.collection_wllet_active');				
		if(witrbslick.length > 0){
		witrbslick.slick({
			infinite: true,
			autoplay: true,
			autoplaySpeed: 3000,
			speed: 1000,					
			slidesToShow: 6,
			slidesToScroll: 2,
			arrows: true,
			dots: true,
			responsive: [
				{
					breakpoint: 1200,
					settings: {
						slidesToShow: 4,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 992,
					settings: {
						slidesToShow: 4,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 767,
					settings: {
						slidesToShow: 2,
						slidesToScroll: 1,
					}
				}
				]
			});
		}







// tab_collection_active
	var witrbslick = $('.tab_collection_active');				
		if(witrbslick.length > 0){
		witrbslick.slick({
			infinite: true,
			autoplay: true,
			autoplaySpeed: 3000,
			speed: 1000,					
			slidesToShow: 6,
			slidesToScroll: 2,
			arrows: true,
			dots: true,
			responsive: [
				{
					breakpoint: 1200,
					settings: {
						slidesToShow: 3,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 992,
					settings: {
						slidesToShow: 2,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 767,
					settings: {
						slidesToShow: 2,
						slidesToScroll: 1,
					}
				}
				]
			});
		}




// slick_slider_actives

	var witrbslick = $('.testi_active');				
		if(witrbslick.length > 0){
		witrbslick.slick({
			infinite: true,
			autoplay: true,
			autoplaySpeed: 5000,
			speed: 1000,					
			slidesToShow: 1,
			slidesToScroll: 1,
			arrows: false,
			dots: true,
			responsive: [
				{
					breakpoint: 1200,
					settings: {
						slidesToShow: 1,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 992,
					settings: {
						slidesToShow: 1,
						slidesToScroll: 1,
					}
				},
				{
					breakpoint: 767,
					settings: {
						slidesToShow: 1,
						slidesToScroll: 1,
					}
				}
				]
			});
		}




const tabButtons = document.querySelectorAll(".tab-button");
const tabContents = document.querySelectorAll(".collection_item");

tabButtons.forEach(button => {
  button.addEventListener("click", () => {
    const tabId = button.getAttribute("data-tab");

    // Update active class on buttons
    tabButtons.forEach(btn => btn.classList.remove("active"));
    button.classList.add("active");

    // Update active class on tab contents
    tabContents.forEach(content => {
      content.classList.remove("active");
      if (content.id === tabId) {
        content.classList.add("active");
      }
    });
  });
});

setTimeout(function () {
  // show tab content
}, 3000);




const tabButtons1 = document.querySelectorAll(".tab-button-style");
const tabContents1 = document.querySelectorAll(".collection_wllet_active");

tabButtons1.forEach(button => {
  button.addEventListener("click", () => {
    const tabId = button.getAttribute("data-tab");

    // Update active class on buttons
    tabButtons1.forEach(btn => btn.classList.remove("active"));
    button.classList.add("active");

    // Update active class on tab contents
    tabContents1.forEach(content => {
      content.classList.remove("active");
      if (content.id === tabId) {
        content.classList.add("active");
      }
    });
  });
});

setTimeout(function () {
  // show tab content
}, 3000);






// Deitail imgaes zoomOverlay

  document.addEventListener("DOMContentLoaded", function () {
    const thumbnails = document.querySelectorAll('.product-bottom-img img');
    const detailImg = document.querySelector('.detail-img img');
    const detailContainer = document.querySelector('.detail-img');
    const zoomOverlay = document.querySelector('.zoom-overlay');

    // Only proceed if all required elements exist
    if (thumbnails.length && detailImg && detailContainer && zoomOverlay) {
        // Thumbnail click = change image and active class
        thumbnails.forEach(function (thumb) {
            thumb.addEventListener('click', function () {
                detailImg.src = this.src;
                thumbnails.forEach(img => img.classList.remove('active'));
                this.classList.add('active');
            });
        });

        thumbnails[0].classList.add('active');

        // Zoom overlay movement with mouse
        detailContainer.addEventListener('mousemove', function (e) {
            const rect = detailContainer.getBoundingClientRect();
            const x = e.clientX - rect.left - 100;
            const y = e.clientY - rect.top - 100;

            zoomOverlay.style.display = 'block';
            zoomOverlay.style.left = `${Math.max(0, Math.min(x, rect.width - 200))}px`;
            zoomOverlay.style.top = `${Math.max(0, Math.min(y, rect.height - 200))}px`;
        });

        detailContainer.addEventListener('mouseleave', function () {
            zoomOverlay.style.display = 'none';
        });
    }
});

document.addEventListener("DOMContentLoaded", function () {
    const container = document.querySelector('.detail-img');
    if (container) {
        const image = container.querySelector('img');
        if (image) {
            container.addEventListener('mousemove', function (e) {
                const rect = container.getBoundingClientRect();
                const x = ((e.clientX - rect.left) / rect.width) * 100;
                const y = ((e.clientY - rect.top) / rect.height) * 100;

                image.style.transformOrigin = `${x}% ${y}%`;
                image.style.transform = 'scale(2)';
            });

            container.addEventListener('mouseleave', function () {
                image.style.transform = 'scale(1)';
                image.style.transformOrigin = 'center center';
            });
        }
    }
});





    const buttons = document.querySelectorAll(".tab-button");
    const contents = document.querySelectorAll(".tab-content");

    buttons.forEach(button => {
      button.addEventListener("click", () => {
        // Remove active classes
        buttons.forEach(btn => btn.classList.remove("active"));
        contents.forEach(content => content.classList.remove("active"));

        // Add active class to clicked tab and related content
        button.classList.add("active");
        document.getElementById(button.dataset.tab).classList.add("active");
      });
    });



// Check out Form
 const districtThanaMap = {
            "Dhaka": ["Dhanmondi", "Mirpur", "Uttara", "Gulshan"],
            "Chattogram": ["Pahartali", "Kotwali", "Double Mooring", "Panchlaish"],
            "Rajshahi": ["Boalia", "Rajpara", "Motihar", "Shah Makhdum"],
            "Khulna": ["Khalishpur", "Sonadanga", "Daulatpur", "Batiaghata"]
            // Add more districts and thanas as needed
        };

        function populateThana() {
            const districtSelect = document.querySelector('select[name="district"]');
            const areaSelect = document.querySelector('select[name="area"]');
            const selectedDistrict = districtSelect.value;

            // Clear previous options
            areaSelect.innerHTML = '<option value="">Thana/Upazilla</option>';

            if (selectedDistrict && districtThanaMap[selectedDistrict]) {
                districtThanaMap[selectedDistrict].forEach(thana => {
                    const option = document.createElement("option");
                    option.value = thana;
                    option.textContent = thana;
                    areaSelect.appendChild(option);
                });
            }
        }



			document.addEventListener("DOMContentLoaded", function () {
    const districtSelect = document.querySelector('select[name="district"]');
    if (districtSelect) {
        districtSelect.addEventListener("change", populateThana);
    }
});
     



	





// categiru colapse
  $(document).ready(function () {
    $('.filter-group .card-header a').on('click', function () {
      var target = $(this).data('target');
      var iconToggle = $(this).find('.icon-toggle');

      // Wait for collapse transition to complete
      $(target).on('shown.bs.collapse', function () {
        iconToggle.find('.fa-chevron-down').hide();
        iconToggle.find('.fa-chevron-up').show();
      });

      $(target).on('hidden.bs.collapse', function () {
        iconToggle.find('.fa-chevron-down').show();
        iconToggle.find('.fa-chevron-up').hide();
      });
    });
  });



// Dashbord menu

document.addEventListener('DOMContentLoaded', function () {
    const currentPage = window.location.pathname.split('/').pop();
    const menuItems = document.querySelectorAll('.ds-menu li');

    menuItems.forEach(item => {
        const link = item.querySelector('a');
        if (link.getAttribute('href') === currentPage) {
            item.classList.add('active');
        } else {
            item.classList.remove('active');
        }
    });
});





// Login menu

  $(document).ready(function() {
    var currentURL = window.location.href;
    $('.btn-menu a').each(function() {
      if (this.href === currentURL) {
        $(this).addClass('active');
      } else {
        $(this).removeClass('active');
      }
    });
  });






 document.addEventListener('DOMContentLoaded', () => {
  const toggleBtn = document.getElementById('toggleSearch');
  const searchOverlay = document.getElementById('searchOverlay');
  const closeBtn = document.getElementById('closeSearch');

  if (toggleBtn && searchOverlay && closeBtn) {
    toggleBtn.addEventListener('click', () => {
      searchOverlay.style.display = 'flex';
    });

    closeBtn.addEventListener('click', () => {
      searchOverlay.style.display = 'none';
    });

    searchOverlay.addEventListener('click', (e) => {
      if (e.target === searchOverlay) {
        searchOverlay.style.display = 'none';
      }
    });
  }
});



})(jQuery);