<form action="{{ $download ? route('admin.downloads.update', $download) : route('admin.downloads.store') }}" method="POST" enctype="multipart/form-data">
    @csrf
    @if($download) @method('PUT') @endif
    <div class="mb-3">
        <label class="form-label">Title <span class="text-danger">*</span></label>
        <input type="text" name="title" class="form-control" value="{{ old('title', $download->title ?? '') }}" required>
    </div>
    <div class="mb-3">
        <label class="form-label">Description</label>
        <textarea name="description" class="form-control" rows="3">{{ old('description', $download->description ?? '') }}</textarea>
    </div>
    <div class="mb-3">
        <label class="form-label">Category</label>
        <input type="text" name="category" class="form-control" value="{{ old('category', $download->category ?? 'Other') }}">
        <div class="form-text">e.g. Company Profile, Certificate, Brochure</div>
    </div>
    <div class="mb-3">
        <label class="form-label">File (PDF/DOC) <span class="text-danger">*</span></label>
        <input type="file" name="file" class="form-control" {{ $download ? '' : 'required' }}>
        @if($download && $download->file)
            <div class="mt-2"><a href="{{ \App\Services\FileUploadService::url($download->file) }}" target="_blank" class="btn btn-sm btn-outline-secondary">View current file</a></div>
        @endif
    </div>
    <div class="mb-3">
        <label class="form-label">Sort Order</label>
        <input type="number" name="sort_order" class="form-control" value="{{ old('sort_order', $download->sort_order ?? 0) }}" min="0">
    </div>
    <div class="form-check mb-3">
        <input type="checkbox" class="form-check-input" id="status" name="status" value="1" {{ old('status', $download->status ?? true) ? 'checked' : '' }}>
        <label class="form-check-label" for="status">Active</label>
    </div>
    <button type="submit" class="btn btn-primary">{{ $download ? 'Update' : 'Create' }} Download</button>
    <a href="{{ route('admin.downloads.index') }}" class="btn btn-outline-secondary">Cancel</a>
</form>
