@extends('backend.layouts.app')

@section('title')
    Room Type Details - Hotel Management System
@endsection

@section('content')
    <!-- Breadcrumb -->
    <div class="bg-white shadow-sm border-b border-gray-200 px-6 py-4">
        <div class="flex items-center justify-between">
            <div class="flex items-center text-sm text-gray-600">
                <i class="fas fa-home mr-2"></i>
                <span>/ Manage Rooms / <a href="{{ route('room-types.index') }}" class="text-blue-600 hover:text-blue-800">Room Types</a> / Details</span>
            </div>
            <div class="flex space-x-2">
                @can('edit-rooms')
                <a href="{{ route('room-types.edit', $roomType) }}" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg transition-colors">
                    <i class="fas fa-edit mr-2"></i>Edit
                </a>
                @endcan
                <a href="{{ route('room-types.index') }}" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg transition-colors">
                    <i class="fas fa-arrow-left mr-2"></i>Back to List
                </a>
            </div>
        </div>
    </div>

    <!-- Content -->
    <div class="p-6">
        <div class="max-w-4xl mx-auto space-y-6">
            <!-- Room Type Details -->
            <div class="bg-white rounded-lg shadow-md">
                <div class="px-6 py-4 border-b border-gray-200">
                    <h2 class="text-xl font-semibold text-gray-800">Room Type Details</h2>
                </div>
                
                <div class="p-6">
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label class="block text-sm font-medium text-gray-500 mb-1">Room Type Name</label>
                            <p class="text-lg font-semibold text-gray-900">{{ $roomType->room_type }}</p>
                        </div>
                        
                        <div>
                            <label class="block text-sm font-medium text-gray-500 mb-1">Price per Night</label>
                            <p class="text-lg font-semibold text-green-600">KES {{ number_format($roomType->price, 2) }}</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Associated Rooms -->
            <div class="bg-white rounded-lg shadow-md">
                <div class="px-6 py-4 border-b border-gray-200">
                    <h3 class="text-lg font-semibold text-gray-800">Associated Rooms</h3>
                    <p class="text-sm text-gray-600 mt-1">Rooms that use this room type</p>
                </div>
                
                <div class="p-6">
                    @if($roomType->rooms && $roomType->rooms->count() > 0)
                        <div class="overflow-x-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-gray-50">
                                    <tr>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Room Number
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Status
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Floor
                                        </th>
                                        <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                            Actions
                                        </th>
                                    </tr>
                                </thead>
                                <tbody class="bg-white divide-y divide-gray-200">
                                    @foreach($roomType->rooms as $room)
                                        <tr class="hover:bg-gray-50">
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <div class="text-sm font-medium text-gray-900">{{ $room->room_number }}</div>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                @php
                                                    $statusColors = [
                                                        'Available' => 'bg-green-100 text-green-800',
                                                        'Occupied' => 'bg-red-100 text-red-800',
                                                        'Maintenance' => 'bg-yellow-100 text-yellow-800',
                                                        'Booked' => 'bg-blue-100 text-blue-800'
                                                    ];
                                                    $statusColor = $statusColors[$room->status] ?? 'bg-gray-100 text-gray-800';
                                                @endphp
                                                <span class="px-2 py-1 text-xs font-medium rounded-full {{ $statusColor }}">
                                                    {{ $room->status }}
                                                </span>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap">
                                                <div class="text-sm text-gray-900">{{ $room->floor }}</div>
                                            </td>
                                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                                <a href="{{ route('rooms.edit', $room) }}" class="text-indigo-600 hover:text-indigo-900">
                                                    <i class="fas fa-edit"></i> Edit
                                                </a>
                                            </td>
                                        </tr>
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    @else
                        <div class="text-center py-8">
                            <i class="fas fa-bed text-4xl text-gray-300 mb-4"></i>
                            <p class="text-gray-500">No rooms are currently using this room type.</p>
                            <p class="text-sm text-gray-400 mt-1">Create rooms with this room type to see them listed here.</p>
                        </div>
                    @endif
                </div>
            </div>

            <!-- Statistics -->
            <div class="bg-white rounded-lg shadow-md">
                <div class="px-6 py-4 border-b border-gray-200">
                    <h3 class="text-lg font-semibold text-gray-800">Statistics</h3>
                </div>
                
                <div class="p-6">
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                        <div class="text-center">
                            <div class="text-2xl font-bold text-blue-600">{{ $roomType->rooms ? $roomType->rooms->count() : 0 }}</div>
                            <div class="text-sm text-gray-500">Total Rooms</div>
                        </div>
                        
                        <div class="text-center">
                            <div class="text-2xl font-bold text-green-600">
                                {{ $roomType->rooms ? $roomType->rooms->where('status', 'Available')->count() : 0 }}
                            </div>
                            <div class="text-sm text-gray-500">Available Rooms</div>
                        </div>
                        
                        <div class="text-center">
                            <div class="text-2xl font-bold text-red-600">
                                {{ $roomType->rooms ? $roomType->rooms->whereIn('status', ['Occupied', 'Booked'])->count() : 0 }}
                            </div>
                            <div class="text-sm text-gray-500">Occupied/Booked</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection 