$(document).ready(function() {
    $('#enquiryForm').on('submit', function(event) {
        event.preventDefault();

        let formData = {
            name: $('#name').val(),
            email: $('#email').val(),
            phone: $('#phone').val()
        };

        $.ajax({
            type: 'POST',   
            url: './submit_email.php',
            data: formData,
            dataType: 'json',
            encode: true,
            success: function(response) {
                Swal.fire({
                    title: 'Success!',
                    text: response.message,
                    icon: 'success',
                    confirmButtonText: 'OK'
                }).then(() => {
                    $('#enquiryModal').modal('hide');
                    $('#enquiryForm')[0].reset();
                });
            },
            error: function(xhr, status, error) {
                Swal.fire({
                    title: 'Error!',
                    text: 'Something went wrong. Please try again later.',
                    icon: 'error',
                    confirmButtonText: 'OK'
                });
            }
        });
    });

    // Create bubble effect
    // for (let i = 0; i < 10; i++) {
    //     createBubble();
    // }

    // function createBubble() {
    //     let bubble = $('<div class="bubble"></div>');
    //     $('body').append(bubble);

    //     let size = Math.random() * 60 + 20;
    //     bubble.css({
    //         left: Math.random() * 100 + 'vw',
    //         animationDuration: Math.random() * 2 + 3 + 's',
    //         width: size + 'px',
    //         height: size + 'px'
    //     });

    //     setTimeout(() => {
    //         bubble.remove();
    //     }, 5000);
    // }
});


