`;
});
const resultsHTML = `
`;
resultsContainer.innerHTML = resultsHTML;
resultsContainer.classList.remove('hidden');
document.getElementById('download-pdf-btn').addEventListener('click', downloadPdf);
resultsContainer.scrollIntoView({ behavior: 'smooth' });
}
function downloadPdf() {
if (!routineData) return;
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
// Header
doc.setFontSize(22);
doc.setFont('helvetica', 'bold');
doc.text('Personalized Office Exercise Routine', 105, 20, { align: 'center' });
doc.setFontSize(14);
doc.text(`Your ${routineData.time} routine for ${routineData.focus}`, 105, 28, { align: 'center' });
// Table of Exercises
const tableData = routineData.exercises.map(ex => [ex.name, ex.reps]);
doc.autoTable({
startY: 40,
head: [['Exercise', 'Reps / Duration']],
body: tableData,
theme: 'grid',
headStyles: { fillColor: [79, 70, 229] }, // Indigo
});
let finalY = doc.autoTable.previous.finalY;
// Disclaimer
if (finalY > 240) { doc.addPage(); finalY = 20; }
doc.setFontSize(12);
doc.setFont('helvetica', 'bold');
doc.setTextColor(239, 68, 68); // Red
doc.text('Disclaimer', 14, finalY + 15);
doc.setFontSize(10);
doc.setTextColor(0, 0, 0); // Black
const disclaimerText = doc.splitTextToSize("This guide provides general recommendations and is not a substitute for professional medical advice. Consult with a healthcare provider before starting any new exercise program, especially if you have pre-existing conditions.", 180);
doc.text(disclaimerText, 14, finalY + 22);
doc.save(`Office-Routine-${routineData.focus.replace(' & ', '-')}.pdf`);
}
// --- EVENT LISTENERS ---
generateBtn.addEventListener('click', generateRoutine);
});
Your ${routineData.time} Routine
Focusing on: ${routineData.focus}
${exercisesHTML}
Disclaimer
This guide provides general recommendations and is not a substitute for professional medical advice. Consult with a healthcare provider before starting any new exercise program, especially if you have pre-existing conditions.
