@extends('admin.layouts.app')
@section('title', 'Contacts')
@section('content')
<div class="action-bar"><span>{{ $contacts->total() }} messages</span></div>
<div class="card">
    <table>
        <tr><th>Name</th><th>Email</th><th>Subject</th><th>Date</th><th>Status</th><th>Actions</th></tr>
        @foreach($contacts as $contact)
        <tr>
            <td><strong>{{ $contact->name }}</strong></td>
            <td>{{ $contact->email }}</td>
            <td class="text-muted">{{ $contact->subject ?? '—' }}</td>
            <td class="text-muted">{{ $contact->created_at->diffForHumans() }}</td>
            <td>{!! $contact->is_read ? '<span style="color:#6fcf97">Read</span>' : '<span style="color:#f0c040">New</span>' !!}</td>
            <td class="inline-flex">
                <a href="{{ route('admin.contacts.show', $contact) }}" class="btn btn-primary btn-sm">View</a>
                <form action="{{ route('admin.contacts.destroy', $contact) }}" method="POST" onsubmit="return confirm('Delete?')">
                    @csrf @method('DELETE')
                    <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                </form>
            </td>
        </tr>
        @endforeach
    </table>
    <div class="pagination">{{ $contacts->links() }}</div>
</div>
@endsection
