@extends('layout.main')

@section('title', 'উপজেলা এডিট')

@section('content')
<div class="min-h-screen bg-gray-50 p-4 sm:p-6">
    <div class="max-w-3xl mx-auto">

        <div class="mb-6 flex items-center justify-between">
            <div>
                <h1 class="text-2xl font-bold text-gray-900">উপজেলা এডিট</h1>
                <p class="text-sm text-gray-600">উপজেলার তথ্য আপডেট করুন</p>
            </div>
            <a href="{{ route('upazilas.index') }}" class="px-4 py-2 border rounded-lg hover:bg-gray-50">তালিকা</a>
        </div>

        <div class="bg-white border rounded-xl p-6">
            <form method="POST" action="{{ route('upazilas.update', $upazila) }}" class="space-y-5">
                @csrf
                @method('PUT')

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">জেলা <span class="text-red-500">*</span></label>
                    <select name="district_id" required
                            class="w-full border rounded-lg px-4 py-2 bg-white @error('district_id') border-red-500 @enderror">
                        <option value="">জেলা নির্বাচন করুন</option>
                        @foreach($districts as $d)
                            <option value="{{ $d->id }}"
                                {{ (old('district_id', $upazila->district_id) == $d->id) ? 'selected' : '' }}>
                                {{ $d->name_bn }} ({{ $d->name_en }})
                            </option>
                        @endforeach
                    </select>
                    @error('district_id') <p class="text-sm text-red-600 mt-1">{{ $message }}</p> @enderror
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">উপজেলা নাম (বাংলা) <span class="text-red-500">*</span></label>
                    <input type="text" name="name_bn" value="{{ old('name_bn', $upazila->name_bn) }}" required
                           class="w-full border rounded-lg px-4 py-2 @error('name_bn') border-red-500 @enderror">
                    @error('name_bn') <p class="text-sm text-red-600 mt-1">{{ $message }}</p> @enderror
                </div>

                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-1">Upazila name (English) <span class="text-red-500">*</span></label>
                    <input type="text" name="name_en" value="{{ old('name_en', $upazila->name_en) }}" required
                           class="w-full border rounded-lg px-4 py-2 @error('name_en') border-red-500 @enderror">
                    @error('name_en') <p class="text-sm text-red-600 mt-1">{{ $message }}</p> @enderror
                </div>

                <div class="flex justify-end gap-2 pt-4 border-t">
                    <a href="{{ route('upazilas.index') }}" class="px-5 py-2 border rounded-lg hover:bg-gray-50">বাতিল</a>
                    <button class="px-5 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700">আপডেট</button>
                </div>
            </form>
        </div>

    </div>
</div>
@endsection
