<!-- Alert Toast (hidden by default) -->
<div id="alertToast" style="display:none; position: fixed; top: 50%; left: 50%; 
     transform: translate(-50%, -50%);
     background: rgba(0,0,0,0.85); padding: 12px 20px; border-radius: 10px;
     text-align: center; min-width: 160px; z-index: 99999; flex-direction: column; align-items: center;">
  <div class="toast-icon" style="font-size: 18px; margin-bottom: 6px; 
       width: 28px; height: 28px; border-radius: 50%; display: flex; justify-content: center; align-items: center; background:#fff; color:#FFE790;">
  </div>
  <div class="toast-message" style="font-size: 14px; color: #fff;"></div>
</div>

<script>
function showAlert(message, icon = '⚠', color = '#FFE790') {
    const toast = document.getElementById('alertToast');
    const iconEl = toast.querySelector('.toast-icon');
    const messageEl = toast.querySelector('.toast-message');

    iconEl.textContent = icon;      // ⚠ icon
    iconEl.style.color = color;      // icon color
    messageEl.textContent = message; // message text

    toast.style.display = 'flex';

    // Hide after 2.5 seconds
    setTimeout(() => {
        toast.style.display = 'none';
    }, 2500);
}

// Only show Laravel messages if they exist
<?php
    $messages = [];
    if(session()->has('success')) $messages[] = ['text' => session('success'), 'icon' => '⚠', 'color' => '#4CAF50'];
    if(session()->has('error')) $messages[] = ['text' => session('error'), 'icon' => '⚠', 'color' => '#FF4D4F'];
    if($errors->any()) {
        foreach($errors->all() as $error) {
            $messages[] = ['text' => $error, 'icon' => '⚠', 'color' => '#FF4D4F'];
        }
    }
?>

<?php if(!empty($messages)): ?>
    let laravelMessages = <?php echo json_encode($messages, 15, 512) ?>;

    function showLaravelMessages(messages) {
        if(messages.length === 0) return;
        let current = messages.shift();
        showAlert(current.text, current.icon, current.color);
        setTimeout(() => showLaravelMessages(messages), 2800);
    }

    showLaravelMessages(laravelMessages);
<?php endif; ?>
</script>
<?php /**PATH /home/goldenyi/public_html/resources/views/alert-message.blade.php ENDPATH**/ ?>