function message(msg, type) {
    if (!msg) return;

    const body = document.body;
    const messageBox = document.createElement("div");

    // Common styles for the full-screen overlay
    messageBox.style.position = 'fixed';
    messageBox.style.top = '0';
    messageBox.style.left = '0';
    messageBox.style.width = '100%';
    messageBox.style.height = '100%';
    messageBox.style.display = 'flex';
    messageBox.style.justifyContent = 'center';
    messageBox.style.alignItems = 'center';
    messageBox.style.zIndex = '9999';

    // Inner message content box
    const messageContent = document.createElement("div");
    messageContent.style.padding = '12px 20px';
    messageContent.style.borderRadius = '8px';
    messageContent.style.fontSize = '16px';
    messageContent.style.boxShadow = '0 4px 10px rgba(0, 0, 0, 0.3)';
    messageContent.style.textAlign = 'center';
    messageContent.innerHTML = msg;

    // Apply colors based on type
    switch (type) {
        case 'success':
            messageContent.style.background = '#28a745';  // Green
            messageContent.style.color = '#fff';
            break;
        case 'error':
            messageContent.style.background = '#dc3545';  // Red
            messageContent.style.color = '#fff';
            break;
        default:
            messageContent.style.background = '#000';     // Black
            messageContent.style.color = '#fff';
            break;
    }

    // Append and show
    messageBox.appendChild(messageContent);
    body.appendChild(messageBox);

    // Remove after 2 seconds
    setTimeout(() => {
        messageBox.remove();
    }, 2000);
}
