
        uploadButton.disabled = true;
      }
    });

    // Reset file input when clicked to allow selecting the same file again
    fileInput.addEventListener('click', () => {
      fileInput.value = '';
    });

    uploadButton.onclick = async () => {
      const file = fileInput.files[0];
      if (!file) {
        alert('Please choose a file first.');
        return;
      }

      // Reset UI
      progressSection.classList.remove('hidden');
      successMessage.classList.add('hidden');
      uploa