`;
resultsContainer.innerHTML = resultsHTML;
resultsContainer.classList.remove('hidden');
document.getElementById('download-pdf-btn').addEventListener('click', downloadPdf);
resultsContainer.scrollIntoView({ behavior: 'smooth' });
}
function downloadPdf() {
if (!userAnswers.exposure) return;
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
const guideKey = userAnswers.exposure.toLowerCase().replace('/','_');
const guide = firstResponseData[guideKey];
// Header
doc.setFontSize(22);
doc.setFont('helvetica', 'bold');
doc.setTextColor(220, 38, 38); // Red
doc.text('EMERGENCY First Response Guide', 105, 20, { align: 'center' });
doc.setTextColor(0, 0, 0); // Black
doc.setFontSize(16);
doc.text(`For Suspected ${guide.title}`, 105, 28, { align: 'center' });
// Steps
doc.setFontSize(14);
doc.setFont('helvetica', 'bold');
doc.text('Immediate Actions:', 14, 45);
doc.setFontSize(11);
doc.setFont('helvetica', 'normal');
let yPos = 52;
guide.steps.forEach(step => {
const cleanStep = step.replace(//g, '').replace(/<\/strong>/g, '');
const textLines = doc.splitTextToSize('• ' + cleanStep, 180);
doc.text(textLines, 14, yPos);
yPos += (textLines.length * 5) + 3;
});
// User Info
if (yPos > 240) { doc.addPage(); yPos = 20; }
doc.setFontSize(14);
doc.setFont('helvetica', 'bold');
doc.text('User-Reported Symptoms:', 14, yPos + 10);
doc.setFontSize(11);
doc.setFont('helvetica', 'normal');
doc.text(userAnswers.symptoms.join(', ') || 'None reported', 14, yPos + 17);
doc.save(`Poisoning-First-Response-${guide.title.replace(' ', '-')}.pdf`);
}
// --- EVENT LISTENERS ---
nextBtn1.addEventListener('click', () => {
populateSymptoms();
switchStep('2');
});
prevBtn2.addEventListener('click', () => switchStep('1'));
finishBtn.addEventListener('click', generateGuide);
// --- INITIALIZATION ---
// No init needed
});
