let currentDiv = 0;
const divs = document.querySelectorAll('.content');

function showDiv(index) {
    divs.forEach(div => div.classList.remove('active'));
    divs[index].classList.add('active');
}

function nextDiv() {
    if (currentDiv < divs.length - 1) {
        currentDiv++;
        showDiv(currentDiv);
    }
}

function previousDiv() {
    if (currentDiv > 0) {
        currentDiv--;
        showDiv(currentDiv);
    }
}

const thumbnails = document.querySelectorAll('.thumbnail img');
const mainImage = document.querySelector('.main-image img');

thumbnails.forEach(thumbnail => {
    thumbnail.addEventListener('click', function() {
        mainImage.src = this.src;
    });
});



const thumbnailDiv = document.querySelector('.thumbnail');
const scrollUpBtn = document.getElementById('scroll-up');
const scrollDownBtn = document.getElementById('scroll-down');

scrollUpBtn.addEventListener('click', () => {
    thumbnailDiv.scrollBy({
        top: -140, // Scroll up by 140px (height of one image + margin)
        behavior: 'smooth'
    });
});

scrollDownBtn.addEventListener('click', () => {
    thumbnailDiv.scrollBy({
        top: 140, // Scroll down by 140px (height of one image + margin)
        behavior: 'smooth'
    });
});

var h1Elements = document.querySelectorAll("#inc-dec");

function minus(button) {
    // Har button ke liye h1 element dhoondna
    var h1 = button.parentElement.querySelector("p");
    if (h1.innerHTML > 1) {
        h1.innerHTML--;
    }
}

function plus(button) {
    // Har button ke liye h1 element dhoondna
    var h1 = button.parentElement.querySelector("p");
    h1.innerHTML++;
}

document.getElementById('customizeCheck').addEventListener('change', function() {
    var contentDiv = document.getElementById('customizeContent');
    if (this.checked) {
        contentDiv.style.display = 'block';
    } else {
        contentDiv.style.display = 'none';
    }
});


function openTab(tabName) {
    // Sab tab content elements ko hide kar do
    var i, tabContent, tabButtons;
    tabContent = document.getElementsByClassName("tab-content");
    for (i = 0; i < tabContent.length; i++) {
        tabContent[i].classList.remove("active");
    }

    // Sab tab buttons se active class hatao
    tabButtons = document.getElementsByClassName("tab-btn");
    for (i = 0; i < tabButtons.length; i++) {
        tabButtons[i].classList.remove("active");
    }

    // Clicked tab ko dikhayein aur active class lagayein
    document.getElementById(tabName).classList.add("active");
    event.currentTarget.classList.add("active");
}

function previewLogo(event) {
    const file = event.target.files[0];
    if (file) {
        const reader = new FileReader();
        reader.onload = function(e) {
            const logoPreview = document.getElementById('logoPreview');
            logoPreview.src = e.target.result;
            logoPreview.style.display = 'block';
            logoPreview.style.width = '100px'; // optional: adjust size
        };
        reader.readAsDataURL(file);
    }
}