{% extends 'admin/base.html' %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1><i class="fas fa-envelope-open-text me-2"></i> Détails du message</h1>
        <div>
            <a href="{{ url_for('admin.contacts') }}" class="btn btn-secondary">
                <i class="fas fa-arrow-left me-2"></i> Retour à la liste
            </a>
            <button type="button" class="btn btn-danger ms-2" data-bs-toggle="modal" data-bs-target="#deleteModal" data-id="{{ contact.id }}" data-name="{{ contact.name }}" data-type="le message" data-action="{{ url_for('admin.delete_contact', id=contact.id) }}">
                <i class="fas fa-trash-alt me-2"></i> Supprimer
            </button>
        </div>
    </div>
    
    <div class="row">
        <div class="col-lg-8">
            <div class="card border-0 shadow-sm mb-4">
                <div class="card-header bg-white d-flex justify-content-between align-items-center">
                    <h5 class="mb-0">Message</h5>
                    <span class="badge {{ 'bg-success' if contact.is_read else 'bg-warning text-dark' }}">
                        {{ 'Lu' if contact.is_read else 'Non lu' }}
                    </span>
                </div>
                <div class="card-body">
                    <div class="mb-4">
                        <h6 class="text-muted mb-2">Message:</h6>
                        <p style="white-space: pre-line;">{{ contact.message }}</p>
                    </div>
                </div>
            </div>
            
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-white">
                    <h5 class="mb-0">Répondre</h5>
                </div>
                <div class="card-body">
                    <form>
                        <div class="form-group mb-3">
                            <label for="replySubject" class="form-label">Sujet:</label>
                            <input type="text" class="form-control" id="replySubject" value="RE: Message de contact GMPL">
                        </div>
                        <div class="form-group mb-3">
                            <label for="replyMessage" class="form-label">Message:</label>
                            <textarea class="form-control" id="replyMessage" rows="6">Bonjour {{ contact.name }},

Merci pour votre message.

Cordialement,
L'équipe GMPL</textarea>
                        </div>
                        <div class="d-grid">
                            <a href="mailto:{{ contact.email }}" class="btn btn-primary">
                                <i class="fas fa-paper-plane me-2"></i> Envoyer
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        
        <div class="col-lg-4">
            <div class="card border-0 shadow-sm mb-4">
                <div class="card-header bg-white">
                    <h5 class="mb-0">Informations de contact</h5>
                </div>
                <div class="card-body">
                    <div class="mb-3">
                        <h6 class="text-muted mb-2">Nom:</h6>
                        <p class="mb-0">{{ contact.name }}</p>
                    </div>
                    <div class="mb-3">
                        <h6 class="text-muted mb-2">Email:</h6>
                        <p class="mb-0">
                            <a href="mailto:{{ contact.email }}">{{ contact.email }}</a>
                        </p>
                    </div>
                    <div class="mb-3">
                        <h6 class="text-muted mb-2">Téléphone:</h6>
                        <p class="mb-0">
                            {% if contact.phone %}
                                <a href="tel:{{ contact.phone }}">{{ contact.phone }}</a>
                            {% else %}
                                <span class="text-muted">Non fourni</span>
                            {% endif %}
                        </p>
                    </div>
                    <div>
                        <h6 class="text-muted mb-2">Date:</h6>
                        <p class="mb-0">{{ contact.created_at.strftime('%d/%m/%Y à %H:%M') }}</p>
                    </div>
                </div>
            </div>
            
            <div class="card border-0 shadow-sm">
                <div class="card-header bg-white">
                    <h5 class="mb-0">Actions</h5>
                </div>
                <div class="card-body">
                    <div class="d-grid gap-2">
                        <a href="mailto:{{ contact.email }}" class="btn btn-outline-primary">
                            <i class="fas fa-envelope me-2"></i> Envoyer un email
                        </a>
                        {% if contact.phone %}
                            <a href="tel:{{ contact.phone }}" class="btn btn-outline-primary">
                                <i class="fas fa-phone me-2"></i> Appeler
                            </a>
                        {% endif %}
                        <button type="button" class="btn btn-outline-primary" disabled>
                            <i class="fas fa-history me-2"></i> Voir l'historique
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
