@extends('layouts.app')

@section('title', 'Platform Support Desk')

@section('content')
<div class="space-y-6">
    <div class="flex items-center justify-between">
        <div>
            <h1 class="text-xl font-bold text-slate-900 dark:text-white">Tenant Support Helpdesk</h1>
            <p class="text-xs text-slate-500">Manage support tickets submitted by typing center tenants.</p>
        </div>
    </div>

    <!-- Support Desk Tickets Table (Requirement 43-46) -->
    <div class="bg-white dark:bg-slate-800 rounded-3xl border border-slate-200 dark:border-slate-700/60 shadow-sm overflow-hidden text-xs">
        <div class="overflow-x-auto">
            <table class="w-full text-left rtl:text-right">
                <thead class="bg-slate-50 dark:bg-slate-900/60 border-b border-slate-200 dark:border-slate-700 text-slate-500 uppercase tracking-wider font-bold">
                    <tr>
                        <th class="px-6 py-4">Ticket #</th>
                        <th class="px-6 py-4">Tenant Company</th>
                        <th class="px-6 py-4">Category</th>
                        <th class="px-6 py-4">Subject</th>
                        <th class="px-6 py-4">Priority</th>
                        <th class="px-6 py-4">Status</th>
                        <th class="px-6 py-4 text-right rtl:text-left">Action</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-slate-200 dark:divide-slate-700/60 font-medium">
                    @foreach($tickets as $ticket)
                        <tr class="hover:bg-slate-50 dark:hover:bg-slate-700/30">
                            <td class="px-6 py-4 font-mono font-bold text-sky-600">{{ $ticket->ticket_code }}</td>
                            <td class="px-6 py-4 font-bold text-slate-900 dark:text-white">{{ $ticket->tenant->company_name }}</td>
                            <td class="px-6 py-4 text-slate-500 uppercase text-[10px] font-bold">{{ $ticket->category }}</td>
                            <td class="px-6 py-4 text-slate-800 dark:text-slate-200 font-semibold">{{ $ticket->subject }}</td>
                            <td class="px-6 py-4">
                                <span class="px-2.5 py-0.5 rounded-full text-[10px] font-bold {{ $ticket->priority === 'urgent' ? 'bg-rose-100 text-rose-700' : 'bg-slate-100 text-slate-700' }}">
                                    {{ ucfirst($ticket->priority) }}
                                </span>
                            </td>
                            <td class="px-6 py-4">
                                <span class="px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-sky-100 dark:bg-sky-950 text-sky-700 dark:text-sky-300">
                                    {{ ucfirst($ticket->status) }}
                                </span>
                            </td>
                            <td class="px-6 py-4 text-right rtl:text-left">
                                <a href="{{ route('platform.support.show', $ticket->id) }}" class="text-sky-600 font-bold hover:underline">View Ticket ➔</a>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
        <div class="p-4 border-t border-slate-200 dark:border-slate-700">
            {{ $tickets->links() }}
        </div>
    </div>
</div>
@endsection
