Error(message) {
        const errorMsg = document.getElementById('errorMessage');
        errorMsg.textContent = message;
        errorMsg.style.display = 'block';
        setTimeout(() => {
            errorMsg.style.display = 'none';
        }, 5000);
    }

    async function optimizeDatabase() {
        const adminKey = '{{ admin_key }}';
        if (!adminKey) {
            showError('Admin key is missing. Please refresh the page.');
            return;
        }
        
        showLoading('Optimizi