{{-- resources/views/components/allegati/file-display.blade.php --}}
@props(['files' => []])

@foreach($files as $file)
    @php
        $filePath = storage_path('app/public/' . $file);
        $extension = pathinfo($filePath, PATHINFO_EXTENSION);
        $allowedExtensions = ['jpg', 'jpeg', 'png', 'gif'];
    @endphp

    @if(file_exists($filePath) && in_array(strtolower($extension), $allowedExtensions))
        <div class="image-container" style="margin-bottom: 5px;">
            <img
                src="{{ $filePath }}"
                alt="{{ basename($file) }}"
                style="max-width: 100%; height: auto; display: block;"
            >
        </div>
    @endif
@endforeach
