﻿@extends('layouts.app')

@section('title', TranslationHelper::transFromDatabase('Branches.CreateTitle', __('إضافة فرع جديد')))

@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">{{ TranslationHelper::transFromDatabase('Branches.CreateTitle', __('إضافة فرع جديد')) }}</h2>
        <a href="{{ route('branches.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>
            {{ TranslationHelper::transFromDatabase('General.BackToList', __('العودة للقائمة')) }}
        </a>
    </div>

    <div class="bg-white rounded-lg shadow-md p-6">
        <form action="{{ route('branches.store') }}" method="POST">
            @csrf
            
            <div class="mb-4">
                <label for="name" class="block text-gray-700 text-sm font-bold mb-2">{{ TranslationHelper::transFromDatabase('Branches.Name', __('اسم الفرع')) }} <span class="text-red-600">*</span></label>
                <input type="text" name="name" id="name" value="{{ old('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="address" class="block text-gray-700 text-sm font-bold mb-2">{{ TranslationHelper::transFromDatabase('Branches.Address', __('عنوان الفرع')) }}</label>
                <input type="text" name="address" id="address" value="{{ old('address') }}" class="shadow appearance-none border rounded w-full py-2 p-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('address') border-red-500 @enderror">
                @error('address')
                <p class="text-red-500 text-s mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div class="mb-4">
                <label for="phone" class="block text-gray-700 text-sm font-bold mb-2">{{ TranslationHelper::transFromDatabase('Branches.Phone', __('رقم الهاتف')) }}</label>
                <input type="text" name="phone" id="phone" value="{{ old('phone') }}" class="shadow appearance-none border rounded w-full py-2 p-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('phone') border-red-500 @enderror">
                @error('phone')
                <p class="text-red-500 text-s mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div class="mb-4">
                <label for="email" class="block text-gray-700 text-sm font-bold mb-2">{{ TranslationHelper::transFromDatabase('Branches.Email', __('البريد الإلكتروني')) }}</label>
                <input type="email" name="email" id="email" value="{{ old('email') }}" class="shadow appearance-none border rounded w-full py-2 p-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('email') border-red-500 @enderror">
                @error('email')
                <p class="text-red-500 text-s mt-1">{{ $message }}</p>
                @enderror
            </div>

            <div class="mb-4">
                <div class="flex items-center">
                    <input type="checkbox" name="is_main" id="is_main" value="1" {{ old('is_main') ? 'checked' : '' }} class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded ml-2">
                    <label for="is_main" class="text-gray-700 text-sm font-bold">{{ TranslationHelper::transFromDatabase('Branches.MainBranch', __('فرع رئيسي')) }}</label>
                </div>
                <p class="text-gray-500 text-s mt-1">{{ TranslationHelper::transFromDatabase('Branches.MainBranchNote', __('ملاحظة: إذا تم تحديد هذا الفرع كفرع رئيسي، سيتم إلغاء تعيين الفرع الرئيسي السابق.')) }}</p>
            </div>

            <div class="mb-6">
                <div class="flex items-center">
                    <input type="checkbox" name="is_active" id="is_active" value="1" {{ old('is_active', '1') ? 'checked' : '' }} class="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded ml-2">
                    <label for="is_active" class="text-gray-700 text-sm font-bold">{{ TranslationHelper::transFromDatabase('Branches.ActiveBranch', __('فرع نشط')) }}</label>
                </div>
            </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">
                    {{ TranslationHelper::transFromDatabase('General.Save', __('حفظ الفرع')) }}
                </button>
            </div>
        </form>
    </div>
</div>
@endsection
