@extends('layouts.admin')

@section('title', 'Message de '.$contact->name)
@section('page-title', 'Détail du message')

@section('content')

<div class="max-w-2xl mx-auto">
    <div class="mb-6">
        <a href="{{ route('admin.contacts.index') }}" class="inline-flex items-center gap-2 text-sm text-gray-500 hover:text-primary transition-colors">
            <i class="fas fa-arrow-left"></i> Retour aux messages
        </a>
    </div>

    <div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
        <div class="bg-gray-50 px-6 py-5 border-b border-gray-100">
            <div class="flex items-start justify-between">
                <div class="flex items-center gap-3">
                    <div class="w-12 h-12 bg-pink-500 rounded-full flex items-center justify-center">
                        <span class="text-white font-bold text-lg">{{ strtoupper(substr($contact->name, 0, 1)) }}</span>
                    </div>
                    <div>
                        <h2 class="font-semibold text-gray-800">{{ $contact->name }}</h2>
                        <p class="text-sm text-gray-500">{{ $contact->email }}</p>
                        @if($contact->phone)
                        <p class="text-xs text-gray-400">{{ $contact->phone }}</p>
                        @endif
                    </div>
                </div>
                <div class="text-right">
                    <p class="text-xs text-gray-400">{{ $contact->created_at->format('d/m/Y à H:i') }}</p>
                    <span class="inline-block mt-1 bg-green-100 text-green-700 px-2.5 py-0.5 rounded-full text-xs font-medium">Lu</span>
                </div>
            </div>
        </div>

        <div class="px-6 py-5">
            <div class="mb-4">
                <span class="text-xs text-gray-400 uppercase tracking-wider">Sujet</span>
                <p class="font-semibold text-gray-800 mt-1">{{ $contact->subject }}</p>
            </div>
            <div>
                <span class="text-xs text-gray-400 uppercase tracking-wider">Message</span>
                <div class="mt-2 bg-gray-50 rounded-xl p-4 text-gray-700 text-sm leading-relaxed whitespace-pre-wrap">{{ $contact->message }}</div>
            </div>
        </div>

        <div class="px-6 py-4 border-t border-gray-100 flex gap-3">
            <a href="mailto:{{ $contact->email }}?subject=Re: {{ urlencode($contact->subject) }}"
               class="flex-1 sm:flex-none flex items-center justify-center gap-2 bg-primary text-white px-6 py-2.5 rounded-xl text-sm font-medium hover:bg-primary-dark transition-all">
                <i class="fas fa-reply"></i> Répondre par email
            </a>
            <form action="{{ route('admin.contacts.destroy', $contact) }}" method="POST"
                  onsubmit="return confirm('Supprimer ce message ?')">
                @csrf @method('DELETE')
                <button type="submit" class="flex items-center gap-2 border border-red-200 text-red-500 px-4 py-2.5 rounded-xl text-sm font-medium hover:bg-red-50 transition-colors">
                    <i class="fas fa-trash"></i> Supprimer
                </button>
            </form>
        </div>
    </div>
</div>

@endsection
