${primaryOil.name}
${primaryOil.desc}
${secondaryOil.name}
${secondaryOil.desc}
Diffuser Recipe:
Add the following to your diffuser with water:
- 3 drops ${primaryOil.name}
- 2 drops ${secondaryOil.name}
Safety First
Always diffuse in a well-ventilated area. Keep oils away from children and pets. Do not ingest essential oils. Consult a healthcare provider if you are pregnant, nursing, or have a medical condition.
`;
elements.resultContainer.innerHTML = resultHTML;
};
const downloadPDF = () => {
if (typeof window.jspdf === 'undefined') {
alert('Could not generate PDF. The required library is missing.');
return;
}
const { jsPDF } = window.jspdf;
const doc = new jsPDF();
const { blendName, primaryOil, secondaryOil, recipe } = recommendationData;
const colors = { primary: '#047857', secondary: '#10b981', textPrimary: '#1f2937', textSecondary: '#6b7280' };
doc.setFillColor(colors.primary);
doc.rect(0, 0, 210, 28, 'F');
doc.setFont('helvetica', 'bold');
doc.setFontSize(20);
doc.setTextColor('#FFFFFF');
doc.text('Your Aromatherapy Recommendation', 105, 18, { align: 'center' });
let yPos = 40;
doc.setFontSize(16);
doc.setFont('helvetica', 'bold');
doc.setTextColor(colors.primary);
doc.text(blendName, 14, yPos);
yPos += 10;
doc.setFontSize(12);
doc.setFont('helvetica', 'bold');
doc.setTextColor(colors.textPrimary);
doc.text(primaryOil.name, 14, yPos);
yPos += 5;
doc.setFont('helvetica', 'normal');
doc.setFontSize(11);
const splitDesc1 = doc.splitTextToSize(primaryOil.desc, 180);
doc.text(splitDesc1, 14, yPos);
yPos += (splitDesc1.length * 5) + 5;
doc.setFontSize(12);
doc.setFont('helvetica', 'bold');
doc.setTextColor(colors.textPrimary);
doc.text(secondaryOil.name, 14, yPos);
yPos += 5;
doc.setFont('helvetica', 'normal');
doc.setFontSize(11);
const splitDesc2 = doc.splitTextToSize(secondaryOil.desc, 180);
doc.text(splitDesc2, 14, yPos);
yPos += (splitDesc2.length * 5) + 10;
doc.setFontSize(14);
doc.setFont('helvetica', 'bold');
doc.setTextColor(colors.primary);
doc.text('Diffuser Recipe', 14, yPos);
yPos += 7;
doc.setFontSize(11);
doc.setFont('helvetica', 'normal');
doc.text(`• 3 drops ${primaryOil.name}`, 20, yPos);
yPos += 7;
doc.text(`• 2 drops ${secondaryOil.name}`, 20, yPos);
yPos += 15;
doc.setFillColor('#fffbeb'); // yellow-50
doc.rect(14, yPos, 182, 25, 'F');
doc.setFontSize(12);
doc.setFont('helvetica', 'bold');
doc.setTextColor('#b45309'); // amber-700
doc.text('Important Safety Information', 20, yPos + 7);
doc.setFontSize(9);
doc.setFont('helvetica', 'normal');
doc.setTextColor('#92400e'); // amber-800
const safetyText = "Always diffuse in a well-ventilated area and for limited periods (e.g., 30-60 minutes). Keep essential oils out of reach of children and pets. Do not ingest. If you are pregnant, nursing, or have a medical condition, consult a healthcare professional before use.";
doc.text(doc.splitTextToSize(safetyText, 170), 20, yPos + 12);
doc.save('My_Aromatherapy_Blend.pdf');
};
// --- Event Listeners ---
elements.nextBtn.addEventListener('click', nextStep);
elements.prevBtn.addEventListener('click', prevStep);
elements.downloadPdfBtn.addEventListener('click', downloadPDF);
// --- Initialization ---
updateFormUI();
});