@extends('layouts.dashboard')

@section('title', 'Devis')

@section('content')
<h1 class="text-2xl font-bold text-slate-800 mb-8">Demandes de devis</h1>

@if($devis->isEmpty())
<div class="bg-white rounded-xl p-12 text-center border border-slate-100">
    <p class="text-slate-500">Aucune demande de devis.</p>
</div>
@else
<div class="bg-white rounded-xl shadow-sm border border-slate-100 overflow-x-auto">
    <table class="w-full min-w-[640px]">
        <thead class="bg-slate-50 border-b border-slate-200">
            <tr>
                <th class="text-left px-6 py-4 text-sm font-semibold text-slate-700">Nom</th>
                <th class="text-left px-6 py-4 text-sm font-semibold text-slate-700">Prestation</th>
                <th class="text-left px-6 py-4 text-sm font-semibold text-slate-700">Statut</th>
                <th class="text-left px-6 py-4 text-sm font-semibold text-slate-700">Date</th>
                <th class="text-right px-6 py-4 text-sm font-semibold text-slate-700">Actions</th>
            </tr>
        </thead>
        <tbody>
            @foreach($devis as $devi)
            <tr class="border-b border-slate-100 hover:bg-slate-50/50">
                <td class="px-6 py-4">
                    <a href="{{ route('dashboard.devis.show', $devi) }}" class="font-medium text-slate-800 hover:text-amber-600">{{ $devi->nom }}</a>
                </td>
                <td class="px-6 py-4 text-slate-600">{{ $devi->type_prestation ?? '-' }}</td>
                <td class="px-6 py-4">
                    @php
                        $statutClasses = [
                            'en_attente' => 'bg-amber-100 text-amber-700',
                            'en_cours' => 'bg-blue-100 text-blue-700',
                            'accepte' => 'bg-green-100 text-green-700',
                            'refuse' => 'bg-red-100 text-red-700',
                        ];
                    @endphp
                    <span class="text-xs px-2 py-1 rounded-full {{ $statutClasses[$devi->statut] ?? 'bg-slate-100 text-slate-600' }}">
                        {{ ucfirst(str_replace('_', ' ', $devi->statut)) }}
                    </span>
                </td>
                <td class="px-6 py-4 text-slate-500 text-sm">{{ $devi->created_at->format('d/m/Y') }}</td>
                <td class="px-6 py-4 text-right">
                    <a href="{{ route('dashboard.devis.show', $devi) }}" class="text-amber-600 hover:text-amber-700 text-sm font-medium">Voir</a>
                </td>
            </tr>
            @endforeach
        </tbody>
    </table>
</div>

<div class="mt-6">
    {{ $devis->links() }}
</div>
@endif
@endsection
