<form action="{{ $certification ? route('admin.certifications.update', $certification) : route('admin.certifications.store') }}" method="POST" enctype="multipart/form-data">
    @csrf
    @if($certification) @method('PUT') @endif
    <div class="row g-3">
        <div class="col-12">
            <label class="form-label">Certificate Name <span class="text-danger">*</span></label>
            <input type="text" name="name" class="form-control" value="{{ old('name', $certification->name ?? '') }}" required>
        </div>
        <div class="col-md-6">
            <label class="form-label">Issuing Organization</label>
            <input type="text" name="issuing_organization" class="form-control" value="{{ old('issuing_organization', $certification->issuing_organization ?? '') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label">Certificate Number</label>
            <input type="text" name="certificate_number" class="form-control" value="{{ old('certificate_number', $certification->certificate_number ?? '') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label">Issue Date</label>
            <input type="date" name="issue_date" class="form-control" value="{{ old('issue_date', $certification->issue_date?->format('Y-m-d') ?? '') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label">Expiry Date</label>
            <input type="date" name="expiry_date" class="form-control" value="{{ old('expiry_date', $certification->expiry_date?->format('Y-m-d') ?? '') }}">
        </div>
        <div class="col-md-6">
            <label class="form-label">Certificate Image</label>
            <input type="file" name="image" class="form-control">
            @if($certification && $certification->image)
                <img src="{{ \App\Services\FileUploadService::url($certification->image) }}" class="img-fluid mt-2" style="max-height:100px">
            @endif
        </div>
        <div class="col-md-6">
            <label class="form-label">Certificate File (PDF/DOC)</label>
            <input type="file" name="file" class="form-control">
        </div>
        <div class="col-12">
            <label class="form-label">Description</label>
            <textarea name="description" class="form-control" rows="3">{{ old('description', $certification->description ?? '') }}</textarea>
        </div>
        <div class="col-md-6">
            <label class="form-label">Sort Order</label>
            <input type="number" name="sort_order" class="form-control" value="{{ old('sort_order', $certification->sort_order ?? 0) }}" min="0">
        </div>
        <div class="col-md-6 d-flex align-items-end">
            <div class="form-check mb-2">
                <input type="checkbox" class="form-check-input" id="status" name="status" value="1" {{ old('status', $certification->status ?? true) ? 'checked' : '' }}>
                <label class="form-check-label" for="status">Active</label>
            </div>
        </div>
    </div>
    <div class="mt-4">
        <button type="submit" class="btn btn-primary">{{ $certification ? 'Update' : 'Create' }} Certification</button>
        <a href="{{ route('admin.certifications.index') }}" class="btn btn-outline-secondary">Cancel</a>
    </div>
</form>
