{% extends 'base.html.twig' %}

{% block title %}Conversation{% endblock %}

{% block body %}
    <div class="container mx-auto p-6">
        <h1 class="text-3xl font-bold mb-6 text-center">Conversation avec {{ receiver.nickname }}</h1>

        <div class="conversation bg-gray-100 p-6 rounded-lg shadow-lg">
            {% for msg in conversation %}
                <div class="message {% if msg.sender == app.user %}bg-teal-500 text-white self-end{% else %}bg-gray-200 text-gray-700 self-start{% endif %} p-4 my-2 rounded-lg max-w-xs">
                    <p class="font-semibold">{{ msg.sender.nickname }} :</p>
                    <p class="mt-2">{{ msg.content }}</p>
                    <p class="text-xs text-gray-500 mt-2">{{ msg.sendingDate|date('Y-m-d H:i:s') }}</p>
                </div>
            {% endfor %}
        </div>

        <!-- Bouton pour répondre -->
        <div class="mt-4 text-center">
            <a href="{{ path('app_message_new', {'receiverId': receiverId}) }}" class="bg-teal-500 text-white px-6 py-3 rounded-md hover:bg-teal-600">
                Répondre
            </a>
        </div>
        <a href="{{ path('app_message_index') }}" class="text-teal-500 hover:text-teal-700 text-lg">
            <i class="fas fa-arrow-left"></i> Retour à la liste des Messages
        </a>
    </div>
{% endblock %}
