const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0); cartTotal.textContent = '$' + total.toFixed(2); } // Re-initialize icons for new content lucide.createIcons(); } function toggleCart(forceOpen = null) { const sidebar = document.getElementById('cart-sidebar'); const overlay = document.getElementById('overlay'); const isOpen = !sidebar.classList.contains('translate-x-full'); const shouldOpen = forceOpen !== null ? forceOpen : !isOpen; if (shouldOpen) { sidebar.classList.remove('translate-x-full'); overlay.classList.remove('hidden'); } else { sidebar.classList.add('translate-x-full'); overlay.classList.add('hidden'); } } // Quotation Modal functions function openQuotationModal() { document.getElementById('quotation-modal').classList.remove('hidden'); document.getElementById('quotation-modal').classList.add('flex'); document.getElementById('overlay').classList.remove('hidden'); lucide.createIcons(); } function closeQuotationModal() { document.getElementById('quotation-modal').classList.add('hidden'); document.getElementById('quotation-modal').classList.remove('flex'); document.getElementById('overlay').classList.add('hidden'); } function submitQuotation(e) { e.preventDefault(); const formData = new FormData(e.target); const data = Object.fromEntries(formData); // Simulate sending quote request alert(`Quote request submitted!\n\nEmail: ${data.email}\nRequirements: ${data.requirements}\nBudget: ${data.budget || 'Not specified'}\n\nWe'll get back to you within 24 hours.`); closeQuotationModal(); e.target.reset(); } // Checkout functions function openCheckout() { if (cart.length === 0) { alert('Your cart is empty!'); return; } const summary = document.getElementById('checkout-summary'); const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0); summary.innerHTML = `

Order Summary

${cart.map(item => `
${item.name} x${item.quantity} ${(item.price * item.quantity).toFixed(2)}
`).join('')}
Total Monthly ${total.toFixed(2)}
`; document.getElementById('checkout-modal').classList.remove('hidden'); document.getElementById('checkout-modal').classList.add('flex'); toggleCart(false); lucide.createIcons(); } function closeCheckout() { document.getElementById('checkout-modal').classList.add('hidden'); document.getElementById('checkout-modal').classList.remove('flex'); document.getElementById('overlay').classList.add('hidden'); } function submitCheckout(e) { e.preventDefault(); const email = e.target.email.value; // Simulate order processing alert(`Order confirmed!\n\nConfirmation sent to: ${email}\n\nYour server details will be provisioned and emailed to you within 5 minutes.\n\nThank you for choosing NexGen Cloud!`); // Clear cart cart = []; saveCart(); updateCartUI(); closeCheckout(); e.target.reset(); } function closeAllPanels() { toggleCart(false); closeQuotationModal(); closeCheckout(); } function scrollToDedicated() { document.getElementById('dedicated').scrollIntoView({ behavior: 'smooth' }); } // Initialize UI on load updateCartUI();