document.addEventListener('DOMContentLoaded', function() {
    const table = document.getElementById('objectTable');
    if (!table) return;

    table.addEventListener('click', function(e) {
        const row = e.target.closest('.selectable-row');
        if (!row) return;

        // Remove selection from all rows
        table.querySelectorAll('.selected-row').forEach(selectedRow => {
            selectedRow.classList.remove('selected-row');
        });

        // Add selection to clicked row
        row.classList.add('selected-row');

        // Get container ID and redirect to show its details
        const containerId = row.dataset.id;
        const currentUrl = new URL(window.location.href);
        currentUrl.searchParams.set('selected', containerId);
        window.location.href = currentUrl.toString();
    });
});