@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">

        {{-- Header --}}
        <div class="mb-6 flex items-start sm:items-center justify-between gap-4 flex-col sm:flex-row">
            <div>
                <h1 class="text-2xl font-bold text-gray-900">জেলা এডিট করুন</h1>
                <p class="text-sm text-gray-600">জেলার তথ্য আপডেট করুন</p>
            </div>

            <a href="{{ route('districts.index') }}"
               class="px-4 py-2 border rounded-lg text-gray-700 hover:bg-gray-100">
                জেলা তালিকা
            </a>
        </div>

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

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

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

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

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

    </div>
</div>
@endsection
