/**
 * Donation Form Frontend Interactions
 * Handles amount button clicks and updates the donation amount input
 */
(function() {
    'use strict';

    function initDonationForms() {
        const forms = document.querySelectorAll('.dc-donation-form');
        
        forms.forEach(function(form) {
            const input = form.querySelector('.dc-amount-field');
            const buttons = form.querySelectorAll('.dc-amount-btn');
            
            if (!input || !buttons.length) return;
            
            buttons.forEach(function(button) {
                button.addEventListener('click', function(e) {
                    e.preventDefault();
                    const amount = this.getAttribute('data-amount');
                    
                    if (input) {
                        input.value = amount;
                        
                        // Visual feedback - highlight selected button
                        buttons.forEach(function(btn) {
                            btn.classList.remove('active');
                        });
                        this.classList.add('active');
                    }
                });
            });
        });
    }

    // Initialize on DOM ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initDonationForms);
    } else {
        initDonationForms();
    }
})();
