jQuery(document).ready(function($) {
    var allMembers = teamMxtData.allMembers;
    
    // Set CSS variables for responsive design
    document.documentElement.style.setProperty('--cards-in-row-pc', teamMxtData.cardsInRowPc);
    document.documentElement.style.setProperty('--cards-in-row-tablet', teamMxtData.cardsInRowTablet);
    
    function ensureHttp(url) {
        if (!/^(?:f|ht)tps?\:\/\//.test(url)) {
            url = 'http://' + url;
        }
        return url;
    }
    
    function showMemberPopup(memberIndex) {
        var memberData = allMembers[memberIndex];
        var photoUrl = memberData.photo_url;
        var popupContent = '<div class="popup-inner" style="overflow: scroll;">' +
            '<div class="popup-photo-container">' +
            '<img src="' + photoUrl + '" alt="' + memberData.name + '" class="popup-photo">' +
            '</div>' +
            '<div class="popup-info-container">' +
            '<p class="popup-designation">' + memberData.designation + '</p>' +
            '<h3 class="popup-name">' + memberData.name + '</h3>';
        
        // ... (rest of the popup content generation)
        
        $('#team-mxt-popup-content').html(popupContent);
        $('#team-mxt-popup').show();
    }
    
    $(document).on('click', '.carousel-item', function() {
        var memberIndex = $(this).data('member-index');
        showMemberPopup(memberIndex);
    });
    
    $('#team-mxt-popup-close').click(function() {
        $('#team-mxt-popup').hide();
    });
});