@extends('layouts.app')

@section('title', 'تعديل النظام')

@section('content')
<div class="py-12">
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
            <div class="p-6 bg-white border-b border-gray-200">
                <div class="flex items-center justify-between mb-6">
                    <h2 class="text-2xl font-semibold text-gray-800">تعديل النظام: {{ $businessActivity->name }}</h2>
                    <a href="{{ route('system-admin.business-activities.index') }}" class="text-gray-600 hover:text-gray-900">
                        العودة للقائمة
                    </a>
                </div>

                <form action="{{ route('system-admin.business-activities.update', $businessActivity) }}" method="POST">
                    @csrf
                    @method('PUT')
                    
                    <div class="grid grid-cols-1 gap-6 max-w-2xl">
                        <!-- اسم النظام -->
                        <div class="mb-4">
                            <label for="name" class="block text-sm font-medium text-gray-700 mb-2">اسم النظام</label>
                            <input type="text" name="name" id="name" value="{{ old('name', $businessActivity->name) }}" 
                                class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" required>
                            @error('name') <span class="text-red-500 text-xs">{{ $message }}</span> @enderror
                        </div>

                        <!-- رابط تسجيل الدخول -->
                        <div class="mb-4">
                            <label for="login_url" class="block text-sm font-medium text-gray-700 mb-2">رابط تسجيل الدخول</label>
                            <input type="url" name="login_url" id="login_url" value="{{ old('login_url', $businessActivity->login_url) }}" 
                                class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" placeholder="https://..." required>
                            @error('login_url') <span class="text-red-500 text-xs">{{ $message }}</span> @enderror
                        </div>

                        <!-- حالة النظام -->
                        <div class="mb-4">
                            <div class="flex items-center">
                                <input type="checkbox" name="is_active" id="is_active" value="1" {{ old('is_active', $businessActivity->is_active) ? 'checked' : '' }}
                                    class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
                                <label for="is_active" class="mr-2 block text-sm text-gray-900">
                                    مفعل
                                </label>
                            </div>
                            @error('is_active') <span class="text-red-500 text-xs">{{ $message }}</span> @enderror
                        </div>
                    </div>

                    <div class="mt-8 flex justify-end">
                        <button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-6 rounded-md shadow-sm transition duration-150 ease-in-out">
                            تحديث النظام
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
@endsection
