@extends('layouts.app')

@section('content')
<div class="container mx-auto px-4 py-8">
    <div class="max-w-4xl mx-auto">
        <div class="flex justify-between items-center mb-6">
            <h1 class="text-3xl font-bold text-gray-900">Ticket Center Details</h1>
            <div class="space-x-2">
                <a href="{{ route('admin.ticket-centers.edit', $ticketCenter) }}" 
                   class="bg-yellow-500 hover:bg-yellow-700 text-white font-bold py-2 px-4 rounded">
                    Edit Center
                </a>
                <a href="{{ route('admin.ticket-centers.index') }}" 
                   class="bg-gray-500 hover:bg-gray-700 text-white font-bold py-2 px-4 rounded">
                    Back to Centers
                </a>
            </div>
        </div>

        <div class="bg-white shadow-md rounded-lg overflow-hidden">
            <div class="px-6 py-4 bg-gray-50 border-b border-gray-200">
                <h2 class="text-xl font-semibold text-gray-900">{{ $ticketCenter->name }}</h2>
            </div>
            
            <div class="px-6 py-4">
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <div>
                        <h3 class="text-lg font-medium text-gray-900 mb-4">Center Information</h3>
                        <dl class="space-y-3">
                            <div>
                                <dt class="text-sm font-medium text-gray-500">Center Name</dt>
                                <dd class="text-sm text-gray-900">{{ $ticketCenter->name }}</dd>
                            </div>
                            <div>
                                <dt class="text-sm font-medium text-gray-500">Location</dt>
                                <dd class="text-sm text-gray-900">{{ $ticketCenter->location }}</dd>
                            </div>
                            <div>
                                <dt class="text-sm font-medium text-gray-500">Center ID</dt>
                                <dd class="text-sm text-gray-900">#{{ $ticketCenter->center_id }}</dd>
                            </div>
                        </dl>
                    </div>
                    
                    <div>
                        <h3 class="text-lg font-medium text-gray-900 mb-4">Staff Assignment</h3>
                        @if($ticketCenter->staff)
                            <div class="flex items-center p-4 bg-blue-50 rounded-lg">
                                <div class="w-12 h-12 bg-blue-500 rounded-full flex items-center justify-center mr-4">
                                    <span class="text-white text-lg font-medium">
                                        {{ substr($ticketCenter->staff->name, 0, 1) }}
                                    </span>
                                </div>
                                <div>
                                    <div class="text-sm font-medium text-gray-900">{{ $ticketCenter->staff->name }}</div>
                                    <div class="text-sm text-gray-500">{{ $ticketCenter->staff->email }}</div>
                                    <div class="text-xs text-gray-400">Role: {{ ucfirst($ticketCenter->staff->role) }}</div>
                                </div>
                            </div>
                        @else
                            <div class="p-4 bg-yellow-50 rounded-lg">
                                <div class="text-sm text-yellow-800">
                                    <svg class="w-5 h-5 inline mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"></path>
                                    </svg>
                                    No staff member assigned to this ticket center.
                                </div>
                            </div>
                        @endif
                    </div>
                </div>
            </div>
        </div>

        <div class="mt-6 flex justify-between">
            <form action="{{ route('admin.ticket-centers.destroy', $ticketCenter) }}" method="POST" class="inline">
                @csrf
                @method('DELETE')
                <button type="submit" 
                        class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded"
                        onclick="return confirm('Are you sure you want to delete this ticket center? This action cannot be undone.')">
                    Delete Ticket Center
                </button>
            </form>
        </div>
    </div>
</div>
@endsection
