export function showToast(message, type = 'info') {
    const toast = document.createElement('div');
    toast.innerText = message;
    let bg = '#333';
    if (type === 'error') bg = '#dc3545';
    else if (type === 'success') bg = '#28a745';
    else if (type === 'warning') bg = '#ff9800';

    Object.assign(toast.style, {
        position: 'fixed',
        bottom: '30px',
        left: '50%',
        transform: 'translateX(-50%)',
        backgroundColor: bg,
        color: 'white',
        padding: '10px 20px',
        borderRadius: '5px',
        zIndex: '10000',
        fontFamily: 'sans-serif',
        boxShadow: '0 2px 10px rgba(0,0,0,0.5)',
        opacity: '0',
        transition: 'opacity 0.5s'
    });
    document.body.appendChild(toast);
    
    requestAnimationFrame(() => { toast.style.opacity = '1'; });
    
    const duration = type === 'success' ? 1000 : 3000;

    setTimeout(() => {
        toast.style.opacity = '0';
        setTimeout(() => { if (toast.parentNode) toast.parentNode.removeChild(toast); }, 500);
    }, duration);
}