@extends('layouts.sash')

@section('title', 'Edit Walk-In')

@section('content')
<div class="row mt-4">
<div class="col-lg-7">
    <h1 class="text-2xl font-semibold text-slate-800 mb-4">Edit Walk-In</h1>

    <form method="post" action="{{ route('walk-ins.update', $walkIn) }}" class="bg-white rounded-xl shadow-sm border border-slate-200 p-6 space-y-4">
        @csrf
        @method('put')

        <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
            <div>
                <p class="text-xs font-medium text-slate-500">Token</p>
                <p class="text-sm font-semibold text-slate-800">{{ $walkIn->token_no }}</p>
            </div>
            <div>
                <p class="text-xs font-medium text-slate-500">Branch</p>
                <p class="text-sm text-slate-800">{{ $walkIn->branch?->name ?? '—' }}</p>
            </div>
        </div>

        <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
            <div>
                <label class="block text-sm font-medium text-slate-700">Customer name</label>
                <input type="text" name="customer_name" value="{{ old('customer_name', $walkIn->customer_name) }}" class="mt-1 block w-full rounded-lg border-slate-300 shadow-sm text-sm">
            </div>
            <div>
                <label class="block text-sm font-medium text-slate-700">Mobile</label>
                <input type="text" name="mobile" value="{{ old('mobile', $walkIn->mobile) }}" class="mt-1 block w-full rounded-lg border-slate-300 shadow-sm text-sm">
            </div>
        </div>

        <div>
            <label class="block text-sm font-medium text-slate-700">Requested services (summary)</label>
            <input type="text" name="requested_service_summary" value="{{ old('requested_service_summary', $walkIn->requested_service_summary) }}" class="mt-1 block w-full rounded-lg border-slate-300 shadow-sm text-sm">
        </div>

        <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
            <div>
                <label class="block text-sm font-medium text-slate-700">Preferred staff</label>
                <select name="preferred_staff_id" class="mt-1 block w-full rounded-lg border-slate-300 shadow-sm text-sm">
                    <option value="">Any available</option>
                    @foreach($staff as $s)
                        <option value="{{ $s->id }}" {{ old('preferred_staff_id', $walkIn->preferred_staff_id) == $s->id ? 'selected' : '' }}>{{ $s->full_name }}</option>
                    @endforeach
                </select>
            </div>
            <div>
                <label class="block text-sm font-medium text-slate-700">Estimated wait (minutes)</label>
                <input type="number" name="estimated_wait_minutes" value="{{ old('estimated_wait_minutes', $walkIn->estimated_wait_minutes) }}" min="0" class="mt-1 block w-full rounded-lg border-slate-300 shadow-sm text-sm">
            </div>
        </div>

        <div>
            <label class="block text-sm font-medium text-slate-700">Status *</label>
            <select name="status" required class="mt-1 block w-full rounded-lg border-slate-300 shadow-sm text-sm">
                @foreach(['waiting','assigned','in_service','completed','cancelled','converted'] as $status)
                    <option value="{{ $status }}" {{ old('status', $walkIn->status) === $status ? 'selected' : '' }}>{{ ucfirst(str_replace('_', ' ', $status)) }}</option>
                @endforeach
            </select>
        </div>

        <div>
            <label class="block text-sm font-medium text-slate-700">Notes</label>
            <textarea name="notes" rows="3" class="mt-1 block w-full rounded-lg border-slate-300 shadow-sm text-sm">{{ old('notes', $walkIn->notes) }}</textarea>
        </div>

        <div class="flex gap-3 pt-2">
            <button type="submit" class="px-4 py-2 bg-slate-800 text-white text-sm font-medium rounded-lg">Update</button>
            <a href="{{ route('walk-ins.index') }}" class="px-4 py-2 bg-slate-200 rounded-lg text-sm">Cancel</a>
        </div>
    </form>
</div>
</div>
@endsection
