@extends('admin.layout')

@section('title', 'Message de ' . $contactMessage->name)
@section('header', 'Message reçu')

@section('content')
<div class="max-w-2xl">
    <div class="bg-white rounded-2xl border border-slate-200 p-6 space-y-6">
        <div class="flex items-start justify-between gap-4">
            <div>
                <h2 class="text-lg font-semibold text-slate-900">{{ $contactMessage->name }}</h2>
                <a href="mailto:{{ $contactMessage->email }}" class="text-primary-600 hover:underline">{{ $contactMessage->email }}</a>
                @if($contactMessage->phone)
                    <p class="text-slate-600 mt-1">Tél. {{ $contactMessage->phone }}</p>
                @endif
            </div>
            <span class="text-slate-500 text-sm">{{ $contactMessage->created_at->format('d/m/Y à H:i') }}</span>
        </div>
        @if($contactMessage->subject)
            <div>
                <span class="text-sm font-medium text-slate-500">Sujet :</span>
                <p class="text-slate-900">{{ $contactMessage->subject }}</p>
            </div>
        @endif
        <div>
            <span class="text-sm font-medium text-slate-500">Message :</span>
            <p class="text-slate-700 mt-2 whitespace-pre-wrap">{{ $contactMessage->message }}</p>
        </div>
        <div class="flex gap-3 pt-4 border-t border-slate-200">
            <a href="mailto:{{ $contactMessage->email }}?subject=Re: {{ $contactMessage->subject }}" class="px-4 py-2 bg-primary-500 text-white rounded-lg hover:bg-primary-600 text-sm font-medium">
                Répondre par email
            </a>
            <form method="POST" action="{{ route('admin.contact-messages.destroy', $contactMessage) }}" onsubmit="return confirm('Supprimer ce message ?')">
                @csrf
                @method('DELETE')
                <button type="submit" class="px-4 py-2 border border-slate-200 rounded-lg hover:bg-red-50 hover:border-red-200 hover:text-red-600 text-sm font-medium">
                    Supprimer
                </button>
            </form>
            <a href="{{ route('admin.contact-messages.index') }}" class="px-4 py-2 border border-slate-200 rounded-lg hover:bg-slate-50 text-sm font-medium text-slate-700">
                Retour
            </a>
        </div>
    </div>
</div>
@endsection
