// Contact Form Handler
document.getElementById('contactForm').addEventListener('submit', function(e) {
    e.preventDefault();
    
    // Simulate form submission
    const submitBtn = document.querySelector('.submit-btn');
    const originalText = submitBtn.innerHTML;
    
    submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Mengirim...';
    submitBtn.disabled = true;
    
    // Simulate API call
    setTimeout(() => {
        // Show success message
        alert('✅ Terima kasih! Pesan Anda telah terkirim. Kami akan merespon dalam 24 jam.');
        document.getElementById('contactForm').reset();
        submitBtn.innerHTML = originalText;
        submitBtn.disabled = false;
    }, 2000);
    
    // Real implementation: kirim ke EmailJS / Formspree / backend PHP
});

// WhatsApp Auto Message
document.querySelectorAll('.whatsapp-link').forEach(link => {
    link.addEventListener('click', function(e) {
        e.preventDefault();
        const message = 'Halo, saya ingin bertanya/informasi/mengadu terkait:';
        const waNumber = '6281234567890';
        const waUrl = `https://wa.me/${waNumber}?text=${encodeURIComponent(message)}`;
        window.open(waUrl, '_blank');
    });
});

// Auto fill phone number format
document.getElementById('phone').addEventListener('input', function(e) {
    let value = e.target.value.replace(/\D/g, '');
    if (value.startsWith('0')) {
        value = '62' + value.substr(1);
    } else if (value.startsWith('62')) {
        value = value;
    } else {
        value = '62' + value;
    }
    e.target.value = value;
});