@extends('admin.layouts.app')

@section('title', 'Contact Message #' . $message->id)

@section('content')
<div class="mb-6">
    <a href="{{ route('admin.contacts') }}" class="text-primary-600 hover:text-primary-700 font-medium mb-4 inline-block">
        ← Back to Messages
    </a>
    <h1 class="text-3xl font-display font-bold text-gray-900">Contact Message #{{ $message->id }}</h1>
</div>

<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
    <div class="lg:col-span-2">
        <!-- Message Content -->
        <div class="bg-white rounded-xl shadow-sm p-6 mb-6">
            <h2 class="text-xl font-bold text-gray-900 mb-4">{{ $message->subject ?: 'No Subject' }}</h2>
            <div class="prose max-w-none">
                <p class="text-gray-700 whitespace-pre-line">{{ $message->message }}</p>
            </div>
        </div>

        <!-- Sender Information -->
        <div class="bg-white rounded-xl shadow-sm p-6">
            <h2 class="text-xl font-bold text-gray-900 mb-4">Sender Information</h2>
            <div class="grid grid-cols-2 gap-4">
                <div>
                    <p class="text-sm text-gray-600 mb-1">Name</p>
                    <p class="text-gray-900 font-medium">{{ $message->name }}</p>
                </div>
                <div>
                    <p class="text-sm text-gray-600 mb-1">Email</p>
                    <p class="text-gray-900">{{ $message->email }}</p>
                </div>
                @if($message->phone)
                <div>
                    <p class="text-sm text-gray-600 mb-1">Phone</p>
                    <p class="text-gray-900">{{ $message->phone }}</p>
                </div>
                @endif
                <div>
                    <p class="text-sm text-gray-600 mb-1">Received</p>
                    <p class="text-gray-900">{{ $message->created_at->format('F j, Y H:i') }}</p>
                </div>
            </div>
        </div>
    </div>

    <div class="lg:col-span-1">
        <!-- Actions -->
        <div class="bg-white rounded-xl shadow-sm p-6">
            <h3 class="text-lg font-bold text-gray-900 mb-4">Actions</h3>
            <div class="space-y-3">
                <a href="mailto:{{ $message->email }}?subject=Re: {{ $message->subject }}" class="btn btn-primary w-full flex items-center justify-center gap-2">
                    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
                    </svg>
                    Reply via Email
                </a>

                @if($message->phone)
                <a href="tel:{{ $message->phone }}" class="btn btn-outline w-full flex items-center justify-center gap-2">
                    <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
                    </svg>
                    Call
                </a>
                @endif

                <form method="POST" action="{{ route('admin.contacts.delete', $message->id) }}" onsubmit="return confirm('Are you sure you want to delete this message?');">
                    @csrf
                    @method('DELETE')
                    <button type="submit" class="btn bg-red-50 text-red-600 hover:bg-red-100 w-full flex items-center justify-center gap-2">
                        <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
                        </svg>
                        Delete Message
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection

