(function(){
var luxTabs=document.querySelector('.lux-tabs');
if(luxTabs){
luxTabs.addEventListener('click',function(e){
var btn=e.target.closest('[data-action="auth-tab"]');
if(!btn)return;
var tabs=document.querySelectorAll('.lux-tabs .lux-tab');
for(var i=0;i<tabs.length;i++)tabs[i].classList.remove('active');
btn.classList.add('active');
var formId=btn.getAttribute('data-target');
document.getElementById('login-form').style.display=formId==='login-form'?'block':'none';
document.getElementById('register-form').style.display=formId==='register-form'?'block':'none';
});
}
var luxNav=document.querySelector('.lux-nav');
if(luxNav){
luxNav.addEventListener('click',function(e){
var btn=e.target.closest('[data-action="dash-tab"]');
if(btn){
var tabs=document.querySelectorAll('.lux-nav-btn');
for(var i=0;i<tabs.length;i++)tabs[i].classList.remove('active');
btn.classList.add('active');
var panelId=btn.getAttribute('data-target');
var panels=document.querySelectorAll('.lux-panel');
for(var j=0;j<panels.length;j++)panels[j].classList.remove('active');
document.getElementById(panelId).classList.add('active');
return;
}
var logoutBtn=e.target.closest('[data-action="logout"]');
if(logoutBtn){
doLogout();
}
});
}
var loginForm=document.getElementById('login-form');
if(loginForm){
var form=loginForm.querySelector('form');
if(form)form.addEventListener('submit',function(e){doLogin(e);});
}
var registerForm=document.getElementById('register-form');
if(registerForm){
var form=registerForm.querySelector('form');
if(form)form.addEventListener('submit',function(e){doRegister(e);});
}
var settingsForm=document.getElementById('settings-form');
if(settingsForm)settingsForm.addEventListener('submit',function(e){updateProfile(e);});
var ticketForm=document.getElementById('ticket-form');
if(ticketForm)ticketForm.addEventListener('submit',function(e){createTicket(e);});
})();
