<?php document.getElementById('loginForm').addEventListener('submit',function(e){e.preventDefault();const btn=this.querySelector('.login-btn');btn.classList.add('loading');const formData=new FormData(this);fetch('auth.php',{method:'POST',body:formData}).then(response=>response.json()).then(data=>{if(data.status==='success'){Swal.fire({icon:'success',title:'Success!',text:data.message,showConfirmButton:false,timer:1500,customClass:{popup:'swal-dark'}}).then(()=>{window.location.href=data.redirect;});}else{Swal.fire({icon:'error',title:'Error!',text:data.message,customClass:{popup:'swal-dark'}});}}).catch(error=>{Swal.fire({icon:'error',title:'Error!',text:'Connection error. Please try again.',customClass:{popup:'swal-dark'}});}).finally(()=>{btn.classList.remove('loading');});});?>