@php
    $canDelete = $attachmentService->canDelete(auth()->user(), $attachment);
@endphp
<tr data-attachment-id="{{ $attachment->id }}">
    <td>
        <div class="d-flex align-items-center gap-2">
            <i class="bi {{ $attachment->isPdf() ? 'bi-file-earmark-pdf text-danger' : ($attachment->isImage() ? 'bi-file-earmark-image text-primary' : 'bi-file-earmark text-secondary') }}"></i>
            <div>
                <div class="fw-semibold">{{ $attachment->file_name }}</div>
                <div class="text-muted" style="font-size:11.5px">{{ $attachment->file_size_human }}</div>
            </div>
        </div>
    </td>
    <td class="d-none d-md-table-cell text-muted">{{ $attachment->description ?: '—' }}</td>
    <td class="d-none d-lg-table-cell text-muted">{{ $attachment->uploadedBy?->name ?: '—' }}</td>
    <td class="d-none d-lg-table-cell text-muted">{{ $attachment->created_at?->format('d M Y H:i') }}</td>
    <td class="text-end text-nowrap">
        <a href="{{ route('vouchers.attachments.download', [$voucherType, $voucher, $attachment]) }}"
           class="btn btn-link btn-sm p-0 me-2">
            Download
        </a>
        @if($canDelete)
            <button type="button"
                    class="btn btn-link btn-sm text-danger p-0 voucher-attachment-delete"
                    data-url="{{ route('vouchers.attachments.destroy', [$voucherType, $voucher, $attachment]) }}">
                Remove
            </button>
        @endif
    </td>
</tr>
