@extends('layouts.admin')

@section('title', 'Query Details | Smart Dermatology')
@section('page_title', 'Query Details')
@section('page_subtitle', 'Review the full user message and manage its read status.')

@section('content')
    <div class="card panel-card p-4">
        <div class="d-flex justify-content-between align-items-start gap-3 flex-wrap mb-4">
            <div class="d-flex align-items-center">
                <img src="https://ui-avatars.com/api/?name={{ urlencode($query->name) }}&background=F690A6&color=fff" class="rounded-circle me-3" width="64" alt="{{ $query->name }}">
                <div>
                    <h4 class="fw-bold mb-1">{{ $query->name }}</h4>
                    <div class="text-muted">{{ $query->email }}</div>
                    @if ($query->phone)
                        <div class="text-muted">{{ $query->phone }}</div>
                    @endif
                    <div class="small text-muted mt-1">Received {{ $query->created_at?->format('d M Y h:i A') }}</div>
                </div>
            </div>
            <span class="badge text-white px-3 py-2" style="background: var(--brand-pink);">{{ $query->status }}</span>
        </div>

        <div class="p-4 rounded-4 mb-4" style="background:#f8f9fb;">
            <h6 class="fw-bold mb-3">Message</h6>
            <p class="mb-0 text-dark" style="white-space: pre-line;">{{ $query->message }}</p>
        </div>

        <div class="d-flex gap-2 flex-wrap">
            <a href="{{ route('admin.queries') }}" class="btn btn-outline-secondary rounded-pill">Back to Queries</a>
            <form action="{{ route('admin.queries.status', $query) }}" method="POST">
                @csrf
                @method('PATCH')
                <button type="submit" class="btn text-white rounded-pill" style="background: var(--brand-pink); border:none;">
                    {{ $query->status === 'Unread' ? 'Mark as Read' : 'Mark as Unread' }}
                </button>
            </form>
        </div>
    </div>
@endsection
