`;
const tempDiv = document.createElement('div');
tempDiv.innerHTML = pdfContentHtml;
document.body.appendChild(tempDiv); // Temporarily add to DOM to ensure styles apply
const options = {
margin: 10,
filename: `ESG_Comparison_Report_${data.companyName.replace(/\s/g, '_')}.pdf`,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, logging: true, dpi: 192, letterRendering: true },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
html2pdf().set(options).from(tempDiv).save().finally(() => {
document.body.removeChild(tempDiv);
});
}
// Event Listeners on DOMContentLoaded
document.addEventListener('DOMContentLoaded', function() {
populateProviderInputs(); // Initial population of provider input sections
const compareRatingsBtn = document.getElementById('compareRatingsBtn');
const resetBtn = document.getElementById('resetBtn');
const downloadPdfBtn = document.getElementById('downloadPdfBtn');
const companyNameInput = document.getElementById('companyName');
if (compareRatingsBtn) compareRatingsBtn.addEventListener('click', compareRatings);
if (resetBtn) resetBtn.addEventListener('click', resetCalculator);
if (downloadPdfBtn) downloadPdfBtn.addEventListener('click', downloadPdf);
if (companyNameInput) companyNameInput.addEventListener('input', hideResults); // Hide results on company name change
});