@extends('layouts.client')

@section('header_title', 'Suporte Técnico')
@section('header_subtitle', 'Acompanhe pedidos de assistência e abra novos tickets.')

@section('content')
    <div class="flex justify-end mb-8">
        <a href="{{ route('client.tickets.create') }}" class="inline-flex items-center justify-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white text-sm font-semibold rounded-xl shadow-lg shadow-blue-500/20 transition-all">
            <svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" /></svg>
            Novo Pedido
        </a>
    </div>

    @if (session('success'))
        <div class="mb-6 p-4 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-sm">{{ session('success') }}</div>
    @endif
    @if (session('error'))
        <div class="mb-6 p-4 rounded-xl bg-red-500/10 border border-red-500/20 text-red-400 text-sm">{{ session('error') }}</div>
    @endif

    <div class="bg-slate-900 border border-white/5 rounded-2xl overflow-hidden shadow-xl">
        <div class="overflow-x-auto">
            <table class="w-full text-left border-collapse">
                <thead>
                    <tr class="bg-slate-950/50 border-b border-white/5 text-xs font-semibold uppercase tracking-wider text-slate-400">
                        <th class="px-6 py-4">Assunto</th>
                        <th class="px-6 py-4">Instalação</th>
                        <th class="px-6 py-4">Prioridade</th>
                        <th class="px-6 py-4">Estado</th>
                        <th class="px-6 py-4 text-right">Ação</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-white/5 whitespace-nowrap text-sm text-slate-300">
                    @forelse($tickets as $ticket)
                        <tr class="hover:bg-slate-800/50">
                            <td class="px-6 py-4 text-white">{{ $ticket->subject }}</td>
                            <td class="px-6 py-4">{{ $ticket->installation->address ?? 'Sem instalação' }}</td>
                            <td class="px-6 py-4">{{ $ticket->priority }}</td>
                            <td class="px-6 py-4">{{ $ticket->status }}</td>
                            <td class="px-6 py-4 text-right">
                                <a href="{{ route('client.tickets.show', $ticket) }}" class="text-blue-400 hover:text-blue-300 font-medium">Ver</a>
                            </td>
                        </tr>
                    @empty
                        <tr><td colspan="5" class="px-6 py-12 text-center text-slate-500">Nenhum pedido de suporte registado.</td></tr>
                    @endforelse
                </tbody>
            </table>
        </div>
        @if($tickets->hasPages())
            <div class="px-6 py-4 border-t border-white/5 bg-slate-950/20">{{ $tickets->links() }}</div>
        @endif
    </div>
@endsection
