@php $compact = $compact ?? false; @endphp

@if($attachments->count() > 0)
    {{-- Image gallery --}}
    @php $images = $attachments->where('type', 'image'); @endphp
    @if($images->count() > 0)
        <div class="flex flex-wrap gap-2 mb-3">
            @foreach($images as $img)
                <a href="{{ $img->url }}"
                   target="_blank"
                   class="block rounded-lg overflow-hidden border border-gray-200 hover:border-indigo-400 transition shadow-sm"
                   title="{{ $img->original_name }}">
                    <img src="{{ $img->url }}"
                         alt="{{ $img->original_name }}"
                         class="{{ $compact ? 'w-16 h-16' : 'w-24 h-24' }} object-cover">
                </a>
            @endforeach
        </div>
    @endif

    {{-- Non-image files --}}
    @php $files = $attachments->where('type', '!=', 'image'); @endphp
    @if($files->count() > 0)
        <div class="flex flex-wrap gap-2">
            @foreach($files as $att)
                <a href="{{ route('partners.forum.attachments.download', $att) }}"
                   class="inline-flex items-center gap-2 px-3 py-1.5 bg-gray-100 hover:bg-indigo-50 border border-gray-200 hover:border-indigo-300 rounded-lg text-xs text-gray-700 hover:text-indigo-700 transition"
                   title="{{ $att->original_name }}">
                    <i class="{{ $att->icon_class }}"></i>
                    <span class="truncate max-w-[140px]">{{ $att->original_name }}</span>
                    <span class="text-gray-400 flex-shrink-0">{{ $att->human_size }}</span>
                    <i class="fas fa-download text-gray-400 flex-shrink-0"></i>
                </a>
            @endforeach
        </div>
    @endif
@endif
