  }).catch(error => {
                console.error('Error:', error);
                alert('Failed to create team. Please try again.');
            });
            }
        }

        // Search users and display in dropdown
        function searchUsers(query) {
            if (query.length < 2) {
                document.getElementById('userDropdown').innerHTML = "";
                return;
            }

            fetch(`/teams/search-users/?query=${query}`)
                .then(response => response.j