`;
}
};
// --- PDF Download Logic ---
if (pdfDownloadButton) {
pdfDownloadButton.addEventListener('click', () => {
const { jsPDF } = window.jspdf;
const pdfContent = document.getElementById('pdf-output');
if (!pdfContent) {
console.error("PDF content area not found.");
return;
}
html2canvas(pdfContent, { scale: 2, useCORS: true }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({
orientation: 'portrait',
unit: 'pt',
format: 'a4'
});
const pdfWidth = pdf.internal.pageSize.getWidth();
const imgWidth = pdfWidth - 80;
const imgHeight = canvas.height * imgWidth / canvas.width;
let position = 40;
pdf.setFont('Inter', 'bold');
pdf.setFontSize(18);
pdf.text('Kidney Disease Risk Report', pdfWidth / 2, position, { align: 'center' });
position += 40;
pdf.addImage(imgData, 'PNG', 40, position, imgWidth, imgHeight);
position += imgHeight + 20;
pdf.setFont('Inter', 'normal');
pdf.setFontSize(8);
pdf.setTextColor(150);
const disclaimer = 'This calculator provides an estimate for informational purposes only and is not a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding a medical condition.';
const splitDisclaimer = pdf.splitTextToSize(disclaimer, pdfWidth - 80);
pdf.text(splitDisclaimer, 40, position);
pdf.save('Kidney-Disease-Risk-Report.pdf');
});
});
}
// --- Initial Load ---
updateTabState();
});
