// Admin-specific JavaScript functionality

document.addEventListener('DOMContentLoaded', function() {
    // Confirm deletion of products
    const deleteButtons = document.querySelectorAll('a.btn-danger');
    deleteButtons.forEach(button => {
        button.addEventListener('click', function(e) {
            if (!confirm('Are you sure you want to delete this product?')) {
                e.preventDefault();
            }
        });
    });
    
    // Form validation for product forms
    const productForms = document.querySelectorAll('form[action*="product"]');
    productForms.forEach(form => {
        form.addEventListener('submit', function(e) {
            const name = form.querySelector('input[name="name"]');
            const description = form.querySelector('textarea[name="description"]');
            const price = form.querySelector('input[name="price"]');
            const category = form.querySelector('select[name="category"]');
            
            if (!name.value.trim() || !description.value.trim() || !price.value || !category.value) {
                alert('Please fill in all required fields.');
                e.preventDefault();
            }
        });
    });
});