`;
} else {
currentPlan.forEach(item => {
timelineDiv.innerHTML += `
`;
runningTime += item.time;
runningTime += 10; // Break/Transition buffer
});
}
// End
timelineDiv.innerHTML += `
`;
container.appendChild(timelineDiv);
}
function renderMenu() {
const container = document.getElementById('menu-grid-container');
container.innerHTML = '';
spaMenu.forEach(item => {
const div = document.createElement('div');
div.className = 'menu-item';
div.innerHTML = `
${runningTime} min
${item.name} ($${item.cost})
${item.desc} (${item.time} mins)
${runningTime} min
Relaxation Lounge
Post-treatment hydration and leisure time.
${item.name}
${item.desc}
Duration: ${item.time} mins
`;
container.appendChild(div);
});
}
// --- Utilities ---
window.spaSwitchTab = function(tabId) {
// Nav state
document.querySelectorAll('.spa-tab-btn').forEach(b => b.classList.remove('active'));
const activeBtn = [...document.querySelectorAll('.spa-tab-btn')].find(b => b.getAttribute('onclick').includes(tabId));
if(activeBtn) activeBtn.classList.add('active');
// Pane state
document.querySelectorAll('.spa-pane').forEach(p => {
p.classList.remove('active');
p.style.display = 'none';
});
const pane = document.getElementById(tabId);
pane.style.display = 'block';
setTimeout(() => pane.classList.add('active'), 10);
};
window.spaDownloadPDF = function() {
const element = document.getElementById('spa-planner-wrapper');
const clone = element.cloneNode(true);
// Clean up clone for PDF print
clone.querySelector('#tab-menu').remove();
clone.querySelector('#tab-consult').remove();
clone.querySelectorAll('button').forEach(b => b.remove());
// Ensure dashboard is visible
const dash = clone.querySelector('#tab-dashboard');
dash.style.display = 'block';
dash.style.opacity = '1';
dash.className = 'spa-pane active'; // remove animation
// Add Date/Name Header to PDF content
const headerInfo = document.createElement('div');
headerInfo.style.textAlign = 'center';
headerInfo.style.marginBottom = '20px';
headerInfo.style.fontFamily = 'sans-serif';
headerInfo.innerHTML = `Prepared for: ${userPreferences.name} on ${new Date().toLocaleDateString()}
`; // Insert after main header clone.querySelector('.spa-header').appendChild(headerInfo); const opt = { margin: 10, filename: `Spa_Itinerary_${userPreferences.name.replace(/\s/g,'_')}.pdf`, image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2 }, jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } }; html2pdf().set(opt).from(clone).save(); }; })();