`).join('');
};
const updateEmptyState = () => {
const hasQuestions = generatedQuestions.length > 0;
document.getElementById('report-content-area').style.display = hasQuestions ? 'block' : 'none';
document.getElementById('report-empty-state').style.display = hasQuestions ? 'none' : 'block';
downloadPdfBtn.style.display = hasQuestions ? 'flex' : 'none';
};
// --- PDF Generation ---
const generatePdf = () => {
const { jsPDF } = window.jspdf;
if (!jsPDF || generatedQuestions.length === 0) return;
const doc = new jsPDF();
doc.setFont('helvetica', 'bold');
doc.setFontSize(20);
doc.text(`"People Also Ask" Questions for: ${currentTopic}`, 15, 20);
const tableData = generatedQuestions.map(q => [q]);
doc.autoTable({
startY: 30,
head: [['Generated Questions']],
body: tableData,
theme: 'grid',
headStyles: { fillColor: '#4b5563', textColor: '#ffffff' }
});
doc.save(`PAA-Questions-${currentTopic.replace(/\s+/g, '-')}.pdf`);
};
downloadPdfBtn.addEventListener('click', generatePdf);
// --- Initialization ---
updateEmptyState();
switchTab('question-generator');
});
