@extends('backend.layouts.app')

@section('title')
    Edit Room Type - 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> / Edit</span>
            </div>
            <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>

    <!-- Content -->
    <div class="p-6">
        <div class="max-w-2xl mx-auto">
            <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">Edit Room Type</h2>
                </div>
                
                <form action="{{ route('room-types.update', $roomType) }}" method="POST" class="p-6">
                    @csrf
                    @method('PUT')
                    
                    @if($errors->any())
                        <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
                            <ul class="list-disc list-inside">
                                @foreach($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        </div>
                    @endif

                    <div class="grid grid-cols-1 gap-6">
                        <!-- Room Type Name -->
                        <div>
                            <label for="room_type" class="block text-sm font-medium text-gray-700 mb-2">
                                Room Type Name <span class="text-red-500">*</span>
                            </label>
                            <input type="text" 
                                   id="room_type" 
                                   name="room_type" 
                                   value="{{ old('room_type', $roomType->room_type) }}"
                                   class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent @error('room_type') border-red-500 @enderror"
                                   placeholder="e.g., Single, Double, Suite, Presidential"
                                   required>
                            @error('room_type')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                            <p class="mt-1 text-sm text-gray-500">
                                Enter the name of the room type (e.g., Single, Double, Triple, Suite, etc.)
                            </p>
                        </div>

                        <!-- Price -->
                        <div>
                            <label for="price" class="block text-sm font-medium text-gray-700 mb-2">
                                Price per Night <span class="text-red-500">*</span>
                            </label>
                            <div class="relative">
                                <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-gray-500">
                                    KES
                                </span>
                                <input type="number" 
                                       id="price" 
                                       name="price" 
                                       value="{{ old('price', $roomType->price) }}"
                                       step="0.01" 
                                       min="0"
                                       class="w-full pl-8 pr-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent @error('price') border-red-500 @enderror"
                                       placeholder="e.g., 2500.00"
                                       required>
                            </div>
                            @error('price')
                                <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
                            @enderror
                            <p class="mt-1 text-sm text-gray-500">
                                Enter the price per night for this room type in KES
                            </p>
                        </div>
                    </div>

                    <div class="flex items-center justify-end space-x-3 mt-8 pt-6 border-t border-gray-200">
                        <a href="{{ route('room-types.index') }}" 
                           class="bg-gray-500 hover:bg-gray-600 text-white px-6 py-2 rounded-lg transition-colors">
                            Cancel
                        </a>
                        <button type="submit" 
                                class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg transition-colors">
                            <i class="fas fa-save mr-2"></i>Update Room Type
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection 