 
                    updateCaseDeviceCount(caseID);
                }, 200);
            })
            .catch(error => {
                alert('Error adding device to case: ' + error.message);
            });
        }
    }

    function refreshCaseDevicesContent(caseID) {
        // Check if the case devices modal is currently open
        const modal = document.getElementById('caseDevicesModal');
        if (modal && modal.style.display === 'flex') {
            // Modal is open, just refresh the conte