@extends('layout.admin')

@section('content')
<div class="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 py-6">

    {{-- হেডার --}}
    <div class="mb-6">
        <h2 class="text-2xl font-bold text-gray-800 flex items-center gap-2">
            <i class="fa fa-edit text-blue-600"></i>
            জব এডিট করুন
        </h2>
    </div>

    {{-- এরর --}}
    @if ($errors->any())
        <div class="bg-red-100 border border-red-300 text-red-700 px-4 py-3 rounded mb-4">
            <ul class="list-disc pl-5 text-sm">
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    {{-- ফর্ম --}}
    <form action="{{ route('admin.jobs.update', $job->id) }}" method="POST" enctype="multipart/form-data"
          class="space-y-5 bg-white p-6 rounded-xl shadow border">
        @csrf
        @method('PUT')

        {{-- Title --}}
        <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">
                <i class="fa fa-heading mr-1 text-gray-500"></i> জব টাইটেল
            </label>
            <input type="text" name="title" value="{{ old('title', $job->title) }}" required
                   class="w-full border border-gray-300 rounded-md px-4 py-2 focus:ring-2 focus:ring-blue-500">
        </div>

        {{-- Description --}}
        <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">
                <i class="fa fa-align-left mr-1 text-gray-500"></i> জব ডেসক্রিপশন
            </label>
            <textarea name="description" rows="4" required
                      class="w-full border border-gray-300 rounded-md px-4 py-2 focus:ring-2 focus:ring-blue-500">{{ old('description', $job->description) }}</textarea>
        </div>

        {{-- Link --}}
        <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">
                <i class="fa fa-link mr-1 text-gray-500"></i> জব লিংক
            </label>
            <input type="url" name="link" value="{{ old('link', $job->link) }}" required
                   class="w-full border border-gray-300 rounded-md px-4 py-2 focus:ring-2 focus:ring-blue-500">
        </div>

        {{-- Amount --}}
        <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">
                <i class="fa fa-money-bill-wave mr-1 text-gray-500"></i> এমাউন্ট (৳)
            </label>
            <input type="number" name="amount" step="0.01" value="{{ old('amount', $job->amount) }}" required
                   class="w-full border border-gray-300 rounded-md px-4 py-2 focus:ring-2 focus:ring-blue-500">
        </div>

        {{-- Limit --}}
        <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">
                <i class="fa fa-users mr-1 text-gray-500"></i> লিমিট (কতজন করতে পারবে)
            </label>
            <input type="number" name="limit" value="{{ old('limit', $job->limit) }}" required
                   class="w-full border border-gray-300 rounded-md px-4 py-2 focus:ring-2 focus:ring-blue-500">
        </div>

        {{-- Photo --}}
        <div>
            <label class="block text-sm font-medium text-gray-700 mb-1">
                <i class="fa fa-image mr-1 text-gray-500"></i> জব ফটো
            </label>
            @if($job->photo)
                <div class="mb-2">
                    <img src="{{ asset($job->photo) }}" class="h-20 rounded-md border">
                </div>
            @endif
            <input type="file" name="photo" accept="image/*"
                   class="w-full text-sm border border-gray-300 rounded-md px-4 py-2 file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100">
        </div>

        {{-- Submit --}}
        <div>
            <button type="submit"
                    class="w-full bg-green-600 hover:bg-green-700 text-white font-semibold py-3 rounded-md shadow-md transition">
                জব আপডেট করুন
            </button>
        </div>
    </form>
</div>
@endsection