// Toast notification system
window.showToast = function(message, duration = 5000, type = 'info') {
const toast = document.createElement('div');
toast.className = `toast toast-${type}`;
const icons = { error: '❌', warning: '⚠️', success: '✅', info: 'ℹ️' };
const icon = document.createElement('span');
icon.className = 'toast-icon';
icon.textContent = icons[type] || icons.info;
const content = document.createElement('div');
content.className = 'toast-content';
content.innerHTML = message.replace(/
/g, '
');
toast.appendChild(icon);
toast.appendChild(content);
const existingToasts = document.querySelectorAll('.toast');
if (existingToasts.length >= 3) existingToasts[0].remove();
let topOffset = 100;
existingToasts.forEach(t => { topOffset += t.offsetHeight + 10; });
toast.style.top = `${topOffset}px`;
document.body.appendChild(toast);
setTimeout(() => {
toast.style.animation = 'slideOutRight 0.3s ease-out';
setTimeout(() => toast.remove(), 300);
}, duration);
toast.addEventListener('click', () => {
toast.style.animation = 'slideOutRight 0.3s ease-out';
setTimeout(() => toast.remove(), 300);
});
}