@extends('layouts.app')

@section('title', \App\Helpers\TranslationHelper::transFromDatabase('General.EditCountry', __('تعديل دولة')))

@section('content')
<div class="container m-auto p-4 py-6">
    <div class="flex items-center justify-between mb-6">
        <h2 class="text-2l font-bold text-gray-800">{{ \App\Helpers\TranslationHelper::transFromDatabase('General.EditCountry', __('تعديل دولة')) }}</h2>
        <a href="{{ route('countries.index') }}" class="bg-gray-200 hover:bg-gray-300 text-gray-700 font-bold py-2 p-4 rounded-md flex items-center">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 ml-1" viewBox="0 0 20 20" fill="currentColor">
                <path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd" />
            </svg>
            {{ \App\Helpers\TranslationHelper::transFromDatabase('General.BackToList', __('العودة للقائمة')) }}
        </a>
    </div>

    <div class="bg-white rounded-lg shadow-md p-6">
        <form action="{{ route('countries.update', $country) }}" method="POST">
            @csrf
            @method('PUT')
            
            <div class="mb-4">
                <label for="name" class="block text-gray-700 text-sm font-bold mb-2">{{ \App\Helpers\TranslationHelper::transFromDatabase('General.CountryName', __('اسم الدولة')) }} <span class="text-red-600">*</span></label>
                <input type="text" name="name" id="name" value="{{ old('name', $country->name) }}" class="shadow appearance-none border rounded w-full py-2 p-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('name') border-red-500 @enderror" required>
                @error('name')
                <p class="text-red-500 text-s mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div class="mb-4">
                <label for="code" class="block text-gray-700 text-sm font-bold mb-2">{{ \App\Helpers\TranslationHelper::transFromDatabase('General.CountryCode', __('كود الدولة')) }}</label>
                <input type="text" name="code" id="code" value="{{ old('code', $country->code) }}" class="shadow appearance-none border rounded w-full py-2 p-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('code') border-red-500 @enderror">
                @error('code')
                <p class="text-red-500 text-s mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div class="flex items-center justify-between">
                <button type="submit" class="bg-primary-600 hover:bg-primary-700 text-white font-bold py-2 p-4 rounded focus:outline-none focus:shadow-outline">
                    {{ \App\Helpers\TranslationHelper::transFromDatabase('General.Update', __('تحديث')) }}
                </button>
            </div>
        </form>
    </div>
</div>
@endsection
