// 修改登录表单为手机号输入
document.addEventListener('DOMContentLoaded', function() {
    // 等待 Livewire 初始化完成
    setTimeout(function() {
        const emailInput = document.querySelector('#form\\.email');
        const emailLabel = document.querySelector('label[for="form.email"]');

        if (emailInput && emailLabel) {
            // 修改输入框类型为 tel
            emailInput.type = 'tel';
            emailInput.inputMode = 'numeric';
            emailInput.maxLength = 11;
            emailInput.placeholder = '请输入11位手机号';

            // 修改标签文字
            emailLabel.textContent = '手机号';

            // 添加提示文字
            const hint = document.createElement('p');
            hint.className = 'mt-1 text-xs text-slate-500';
            hint.textContent = '请输入11位手机号码（以1开头）';
            emailLabel.parentNode.insertBefore(hint, emailInput.parentNode.nextSibling);

            // 监听输入事件，只允许数字
            emailInput.addEventListener('input', function(e) {
                let value = e.target.value.replace(/\D/g, '');
                if (value.length > 11) {
                    value = value.substring(0, 11);
                }
                e.target.value = value;
            });

            console.log('Login form modified to phone number input');
        } else {
            console.error('Login form elements not found');
        }
    }, 1000);
});
