<div class="modal-overlay"
    x-data
    x-cloak
    x-show="$wire.open"
    x-transition.opacity
    @click.self="$wire.close()"
    @keydown.escape.window="$wire.close()"
    @modal:opened.window="refreshIcons($el)"
>
    <div class="modal-window" x-transition x-show="$wire.open">
        <div class="modal-header">
            <span class="modal-title">Download files</span>
            <button type="button" class="modal-close" @click="$wire.close()">
                <i data-lucide="x" size="20"></i>
            </button>
        </div>
        <div class="modal-body">
            <div class="file-list">
                @forelse( $files as $file )
                    @if( $file->state === 'private' )
                        @continue
                    @endif
                    <div class="file-item">
                        <div class="file-info">
                            <span class="file-name">@if($file->state === 'archived')<i data-lucide="archive"></i> @endif{{ $file->filename }}</span>
                            <span class="file-meta">{{ $file->prettyFileSize() }} - {{ $file->download_count }} downloads</span>
                        </div>
                        <div style="display:flex;flex-direction:column;gap:15px;">
                            <a href="{{ route('fs.download', ['entry_id' => $entryId, 'file' => $file->file_uuid] ) }}" class="btn primary"><i data-lucide="download"></i> Download</a>
                            @if( $file->online_patcher )
                                <a href="{{ route('tools.direct-patch', ['entry_id' => $entryId, 'file' => $file->file_uuid] ) }}" class="btn"><i data-lucide="stamp"></i> Patch</a>
                            @endif
                            @if( $file->playOnlineSetting )
                                @auth
                                    <a href="{{ route('tools.play', ['entry_id' => $entryId, 'file' => $file->file_uuid] ) }}" class="btn"><i data-lucide="gamepad-2"></i> Try it online</a>
                                @endauth
                            @endif
                        </div>
                    </div>
                @empty
                    No files found
                @endforelse
            </div>
        </div>
    </div>
</div>
