/**
 * Gathers details from all checked subject checkboxes.
 * @returns {Array} An array of objects, where each object has an 'id' and 'name'.
 */
// function getSelectedSubjects() {
//     const selectedCheckboxes = document.querySelectorAll('.subject-checkbox:checked');
//     const subjectsData = [];
//     selectedCheckboxes.forEach(checkbox => {
//         subjectsData.push({
//             id: checkbox.dataset.subjectId,
//             name: checkbox.dataset.subjectName
//         });
//     });
//     return subjectsData;
// }

// // This event listener ensures all HTML is loaded before the script runs.
// document.addEventListener('DOMContentLoaded', function() {
//     const readyToPayBox = document.querySelector('.ready-to-pay-box');
//     const subjectCheckboxes = document.querySelectorAll('.subject-checkbox');
//     const subjectsSelectedCount = document.querySelector('.subjects-selected');
//     const totalAmountValue = document.querySelector('.total-amount-value');
//     const pricePerSubject = 300; // Set your price per subject

//     function addSubjectToPayList(id, name) {
//         const newItemHTML = `
//             <div class="ready-course-item" data-item-id="${id}">
//                 <div class="ready-course-left">
//                     <span class="ready-dot"></span>
//                     <span>${name}</span>
//                 </div>
//             </div>`;
//         readyToPayBox.querySelector('.ready-title-row').insertAdjacentHTML('afterend', newItemHTML);
//     }

//     function removeSubjectFromPayList(id) {
//         const itemToRemove = readyToPayBox.querySelector(`.ready-course-item[data-item-id="${id}"]`);
//         if (itemToRemove) {
//             itemToRemove.remove();
//         }
//     }
    
//     function updateSummary() {
//         const selectedCheckboxes = document.querySelectorAll('.subject-checkbox:checked');
//         const count = selectedCheckboxes.length;
//         const total = count * pricePerSubject;
//         subjectsSelectedCount.textContent = `${count} Subject${count !== 1 ? 's' : ''} Selected`;
//         totalAmountValue.textContent = `LKR : ${total.toFixed(2)}`;
//     }

//     subjectCheckboxes.forEach(checkbox => {
//         checkbox.addEventListener('change', function() {
//             const subjectId = this.dataset.subjectId;
//             const subjectName = this.dataset.subjectName;
//             this.checked ? addSubjectToPayList(subjectId, subjectName) : removeSubjectFromPayList(subjectId);
//             updateSummary();
//         });
//     });

//     // Clean up placeholder items and initialize summary
//     const staticItems = readyToPayBox.querySelectorAll('.ready-course-item');
//     staticItems.forEach(item => item.remove());
//     updateSummary();

//     // --- Request button logic ---
//     const requestBtn = document.getElementById('requestBtn');
//     if (requestBtn) {
//         requestBtn.addEventListener('click', function() {
//             const allSelectedSubjects = getSelectedSubjects();
//             if (allSelectedSubjects.length === 0) {
//                 alert("Please select at least one subject before requesting.");
//                 return;
//             }

//             console.log("Details of all selected subjects:", allSelectedSubjects);
//             // Here you would send 'allSelectedSubjects' to your server.
            
//             // Start the countdown timer
//             this.disabled = true;
//             this.textContent = 'Requested';
//             // ... (rest of the timer logic) ...
//         });
//     }
// });