`;
});
summaryHtml += `
`;
summaryContent.innerHTML = summaryHtml;
};
downloadPdfBtn.addEventListener('click', () => {
if (typeof window.jspdf === 'undefined' || !window.jspdf.jsPDF.autoTable) return;
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'letter' });
const getValue = id => document.getElementById(id).value;
const page = { width: doc.internal.pageSize.getWidth(), margin: 72 };
let y = page.margin;
// Title Page
doc.setFont('times', 'bold');
doc.setFontSize(22);
doc.text('Multi-Platform Product Listing Guide', page.width / 2, y, { align: 'center' });
y += 40;
doc.setFontSize(16);
doc.setFont('times', 'normal');
doc.text(`Product: ${getValue('productName')}`, page.width / 2, y, { align: 'center' });
y += 20;
doc.text(`SKU: ${getValue('productSku')}`, page.width / 2, y, { align: 'center' });
doc.addPage();
y = page.margin;
// Core Info Section
doc.setFont('times', 'bold');
doc.setFontSize(16);
doc.text('Core Product Information', page.margin, y);
y += 20;
doc.setFont('times', 'normal');
doc.setFontSize(11);
const coreInfo = `Base Price: $${getValue('basePrice')}\n\nCore Description:\n${getValue('coreDescription')}`;
const coreLines = doc.splitTextToSize(coreInfo, page.width - page.margin * 2);
doc.text(coreLines, page.margin, y, { lineHeightFactor: 1.5 });
y += coreLines.length * 11 * 1.5 + 30;
// Platform Sections
document.querySelectorAll('.dynamic-platform').forEach(block => {
const platformName = block.querySelector('.platform-name').value || 'Unnamed Platform';
const platformTitle = block.querySelector('.platform-title').value;
const platformDesc = block.querySelector('.platform-desc').value;
const platformTags = block.querySelector('.platform-tags').value;
const sectionContent = `Title: ${platformTitle}\n\nDescription:\n${platformDesc}\n\nTags: ${platformTags}`;
const sectionLines = doc.splitTextToSize(sectionContent, page.width - page.margin * 2);
const sectionHeight = sectionLines.length * 11 * 1.5 + 40;
if (y + sectionHeight > doc.internal.pageSize.getHeight() - page.margin) {
doc.addPage();
y = page.margin;
}
doc.setFont('times', 'bold');
doc.setFontSize(16);
doc.text(platformName, page.margin, y);
y += 25;
doc.setFont('times', 'normal');
doc.setFontSize(11);
doc.text(sectionLines, page.margin, y, { lineHeightFactor: 1.5 });
y += sectionLines.length * 11 * 1.5 + 30;
});
doc.save(`Product-Listing-Guide-${getValue('productName').replace(/\s/g, '_')}.pdf`);
});
// --- Initial Setup ---
addPlatformBlock("Marketplace", "Artisan Crafted Leather Journal for Writers", "Discover the perfect companion for your thoughts and sketches. Our handcrafted leather journal features 200 pages of high-quality, acid-free paper, bound in genuine full-grain leather.", "journal, leather notebook, gift for writer, handmade");
addPlatformBlock("Social Media Shop", "Your New Favorite Journal ✨", "Handmade leather journals just dropped! Perfect for bullet journaling, sketching, or writing your next novel. Tap to shop!", "#journaling #handmade #leathercraft #giftideas #stationery");
addPlatformBlock("Brand Website", "The Heritage Journal | Full-Grain Leather", "The Heritage Journal is an heirloom-quality notebook designed for a lifetime of use. Bound in rich, American-sourced leather, its lay-flat design and premium paper offer an unparalleled writing experience. Available in Brown and Black.", "leather journal, premium notebook, archival paper, gift");
switchTab('product');
});
