@extends('admin.layout')

@section('title', 'Réservations')
@section('header', 'Réservations')

@section('content')
<nav class="mb-6">
    <a href="{{ route('admin.reservation.index') }}" class="text-slate-500 hover:text-slate-900 text-sm">← Réservation</a>
</nav>

<div class="bg-white rounded-2xl border border-slate-200 overflow-hidden">
    <div class="overflow-x-auto">
    <table class="w-full min-w-[600px]">
        <thead class="bg-slate-50 text-left text-sm text-slate-500">
            <tr>
                <th class="px-6 py-3 font-medium">Client</th>
                <th class="px-6 py-3 font-medium">Service</th>
                <th class="px-6 py-3 font-medium">Date</th>
                <th class="px-6 py-3 font-medium">Créneau</th>
                <th class="px-6 py-3 font-medium">Statut</th>
                <th class="px-6 py-3 font-medium"></th>
            </tr>
        </thead>
        <tbody class="divide-y divide-slate-100">
            @forelse($reservations as $r)
            <tr class="hover:bg-slate-50/50">
                <td class="px-6 py-4 font-medium">{{ $r->customer_name }}<br><span class="text-sm text-slate-500">{{ $r->customer_email }}</span></td>
                <td class="px-6 py-4">{{ $r->slot->service->name ?? '—' }}</td>
                <td class="px-6 py-4">{{ $r->slot->date->format('d/m/Y') }}</td>
                <td class="px-6 py-4">{{ \Carbon\Carbon::parse($r->slot->start_time)->format('H:i') }} - {{ \Carbon\Carbon::parse($r->slot->end_time)->format('H:i') }}</td>
                <td class="px-6 py-4"><span class="px-2 py-1 rounded-lg text-xs font-medium {{ $r->status === 'confirmed' ? 'bg-emerald-100 text-emerald-700' : ($r->status === 'cancelled' ? 'bg-red-100 text-red-700' : 'bg-slate-100 text-slate-600') }}">{{ $r->status === 'confirmed' ? 'Confirmée' : ($r->status === 'cancelled' ? 'Annulée' : 'Terminée') }}</span></td>
                <td class="px-6 py-4"><a href="{{ route('admin.reservation.reservations.show', $r) }}" class="text-primary-500 hover:underline text-sm">Voir</a></td>
            </tr>
            @empty
            <tr><td colspan="6" class="px-6 py-12 text-center text-slate-500">Aucune réservation.</td></tr>
            @endforelse
        </tbody>
    </table>
    </div>
</div>

<div class="mt-4">{{ $reservations->links() }}</div>
@endsection
