@extends('layouts.app')

@section('content')

<div class="row mb-4 align-items-center">
    <div class="col-md-6">
        <h2 class="fw-bold text-dark mb-1">View Message</h2>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb mb-0">
                <li class="breadcrumb-item"><a href="{{ route('dashboard') }}" class="text-decoration-none text-muted">Dashboard</a></li>
                <li class="breadcrumb-item"><a href="{{ route('visitors-messages.index') }}" class="text-decoration-none text-muted">Messages</a></li>
                <li class="breadcrumb-item active fw-medium text-primary" aria-current="page">View</li>
            </ol>
        </nav>
    </div>
    <div class="col-md-6 text-md-end">
        <a href="{{ route('visitors-messages.index') }}" class="btn btn-light border rounded-3 px-4 shadow-sm">
            <i class="bi bi-arrow-left me-2"></i> Back to Messages
        </a>
    </div>
</div>

<div class="card border-0 shadow-sm rounded-4 overflow-hidden max-w-3xl mx-auto">
    <div class="card-header bg-white border-bottom py-4 px-4 px-md-5">
        <div class="d-flex justify-content-between align-items-center">
            <h5 class="m-0 fw-bold text-dark">{{ $message->subject }}</h5>
            <span class="badge bg-primary-subtle text-primary rounded-pill px-3 py-2">
                {{ $message->created_at->format('d M, Y h:i A') }}
            </span>
        </div>
    </div>
    <div class="card-body p-4 p-md-5">
        <div class="d-flex align-items-center mb-4 bg-light p-3 rounded-4">
            <div class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center me-3" style="width: 48px; height: 48px; font-size: 1.2rem;">
                {{ strtoupper(substr($message->name, 0, 1)) }}
            </div>
            <div>
                <h6 class="fw-bold mb-1">{{ $message->name }}</h6>
                <a href="mailto:{{ $message->email }}" class="text-decoration-none text-secondary small">
                    <i class="bi bi-envelope me-1"></i> {{ $message->email }}
                </a>
            </div>
        </div>

        <div class="message-content">
            <p class="text-secondary lh-lg mb-0" style="white-space: pre-line;">
                {{ $message->message }}
            </p>
        </div>
    </div>
    <div class="card-footer bg-white border-top py-4 px-4 px-md-5 text-end">
        <a href="mailto:{{ $message->email }}" class="btn btn-primary rounded-3 px-4 shadow-sm me-2">
            <i class="bi bi-reply me-1"></i> Reply via Email
        </a>
        <form action="{{ route('visitors-messages.destroy', $message->id) }}" method="POST" class="d-inline">
            @csrf
            @method('DELETE')
            <button type="submit" class="btn btn-danger rounded-3 px-4 shadow-sm" onclick="return confirm('Are you sure you want to delete this message?');">
                <i class="bi bi-trash3 me-1"></i> Delete
            </button>
        </form>
    </div>
</div>

@endsection

@section('styles')
<style>
    .bg-primary-subtle { background-color: #eff6ff !important; }
    .breadcrumb-item + .breadcrumb-item::before { content: "\2022"; color: #cbd5e1; }
</style>
@endsection
