@extends('admin.layouts.app')
@section('title','Enquiry #'.$enquiry->id)
@section('page-title','Enquiry #'.$enquiry->id)
@section('content')
<div class="d-flex gap-2 mb-3">
    <a href="{{ route('admin.enquiries.index') }}" class="btn btn-sm" style="border:1px solid #e2e8f0;color:#374151"><i class="bi bi-arrow-left me-1"></i>Back</a>
    <form method="POST" action="{{ route('admin.enquiries.status', $enquiry->id) }}">
        @csrf
        <select name="status" class="form-select form-select-sm d-inline-block" style="width:auto" onchange="this.form.submit()">
            <option value="new" {{ $enquiry->status=='new'?'selected':'' }}>Mark New</option>
            <option value="read" {{ $enquiry->status=='read'?'selected':'' }}>Mark Read</option>
            <option value="replied" {{ $enquiry->status=='replied'?'selected':'' }}>Mark Replied</option>
        </select>
    </form>
</div>

<div class="row g-3">
    <div class="col-lg-8">
        <div class="card-admin p-4 mb-3">
            <div class="fw-700 mb-3" style="font-size:.95rem;color:#0f172a">Message</div>
            <div style="font-size:.88rem;color:#374151;line-height:1.7;white-space:pre-wrap;background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;padding:1rem">{{ $enquiry->message ?? '(No message provided)' }}</div>
        </div>
    </div>
    <div class="col-lg-4">
        <div class="card-admin p-4 mb-3">
            <div class="fw-700 mb-3" style="font-size:.88rem">Contact Details</div>
            <div class="mb-2">
                <div style="font-size:.72rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:1px">Name</div>
                <div class="fw-600" style="font-size:.88rem">{{ $enquiry->name }}</div>
            </div>
            <div class="mb-2">
                <div style="font-size:.72rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:1px">Email</div>
                <a href="mailto:{{ $enquiry->email }}" class="fw-600" style="font-size:.88rem;color:#E5943C">{{ $enquiry->email }}</a>
            </div>
            @if($enquiry->phone)
            <div class="mb-2">
                <div style="font-size:.72rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:1px">Phone</div>
                <div style="font-size:.88rem">{{ $enquiry->phone }}</div>
            </div>
            @endif
            @if($enquiry->company)
            <div class="mb-2">
                <div style="font-size:.72rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:1px">Company</div>
                <div style="font-size:.88rem">{{ $enquiry->company }}</div>
            </div>
            @endif
            <hr style="border-color:#e2e8f0">
            <div class="mb-2">
                <div style="font-size:.72rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:1px">Enquiry Type</div>
                <span class="badge" style="background:#eff6ff;color:#1e40af;font-size:.75rem">{{ ucfirst(str_replace('_',' ',$enquiry->enquiry_type)) }}</span>
            </div>
            @if($enquiry->product)
            <div class="mb-2">
                <div style="font-size:.72rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:1px">Product</div>
                <div style="font-size:.88rem">{{ $enquiry->product->name }}</div>
            </div>
            @endif
            <div class="mb-0">
                <div style="font-size:.72rem;font-weight:700;color:#94a3b8;text-transform:uppercase;letter-spacing:1px">Received</div>
                <div style="font-size:.88rem">{{ $enquiry->created_at->format('d M Y, H:i') }}</div>
            </div>
        </div>
        <a href="mailto:{{ $enquiry->email }}" class="btn btn-admin w-100"><i class="bi bi-reply me-1"></i>Reply via Email</a>
    </div>
</div>
@endsection
