<div id="messages-container" class="fixed top-16 right-4 z-50 space-y-2 max-w-md">
    {% for message in messages %}
    <div data-message 
         class="rounded-lg shadow-lg p-4 flex items-start space-x-3 transition-opacity duration-300
                {% if message.tags == 'error' or message.tags == 'danger' %}
                bg-red-50 border border-red-200
                {% elif message.tags == 'warning' %}
                bg-yellow-50 border border-yellow-200
                {% elif message.tags == 'success' %}
                bg-green-50 border border-green-200
                {% elif message.tags == 'info' %}
                bg-blue-50 border border-blue-200
                {% else %}
                bg-gray-50 border border-gray-200
                {% endif %}"
         role="alert">
        
        <!-- Icon -->
        <div class="flex-shrink-0">
            {% if message.tags == 'error' or message.tags == 'danger' %}
            <svg class="h-5 w-5 text-red-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
            </svg>
            {% elif message.tags == 'warning' %}
            <svg class="h-5 w-5 text-yellow-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
            </svg>
            {% elif message.tags == 'success' %}
            <svg class="h-5 w-5 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
            </svg>
            {% elif message.tags == 'info' %}
            <svg class="h-5 w-5 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
            </svg>
            {% else %}
            <svg class="h-5 w-5 text-gray-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
            </svg>
            {% endif %}
        </div>
        
        <!-- Message Text -->
        <div class="flex-1">
            <p class="text-sm font-medium
                      {% if message.tags == 'error' or message.tags == 'danger' %}
                      text-red-800
                      {% elif message.tags == 'warning' %}
                      text-yellow-800
                      {% elif message.tags == 'success' %}
                      text-green-800
                      {% elif message.tags == 'info' %}
                      text-blue-800
                      {% else %}
                      text-gray-800
                      {% endif %}">
                {{ message }}
            </p>
        </div>
        
        <!-- Close Button -->
        <button type="button" 
                onclick="this.parentElement.remove()"
                class="flex-shrink-0 text-gray-400 hover:text-gray-600 transition-colors">
            <span class="sr-only">Close</span>
            <svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
            </svg>
        </button>
    </div>
    {% endfor %}
</div>