document.addEventListener('DOMContentLoaded', function () {
    const tabsContainer = document.querySelector('#human-in-loop-tabs');
    if (!tabsContainer) return;

    const tabs = tabsContainer.querySelectorAll('.tab-button');
    const contents = tabsContainer.querySelectorAll('.tab-content');

    tabs.forEach(tab => {
        tab.addEventListener('click', () => {
            const target = tab.getAttribute('data-tab');

            // Deactivate all tabs and hide all content
            tabs.forEach(t => {
                t.classList.remove('active-tab');
            });
            contents.forEach(c => {
                c.classList.add('hidden');
            });

            // Activate the clicked tab and show its content
            tab.classList.add('active-tab');
            
            const activeContent = tabsContainer.querySelector(`#${target}`);
            if (activeContent) {
                activeContent.classList.remove('hidden');
            }
        });
    });
});