@extends('layouts.nova')

@section('content')
    <div class="container mx-auto py-8">
        <h1 class="text-2xl font-semibold mb-4">My Gallery</h1>

        @if($artworks->isEmpty())
            <p class="text-sm text-gray-500">You have not uploaded any artworks yet.</p>
        @else
            <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
                @foreach($artworks as $art)
                    <div class="space-y-3">
                        <x-artwork-card :art="$art" />
                        <div class="rounded-xl border border-white/5 bg-white/[0.03] px-3 py-2">
                            <div class="text-xs text-soft">Published: {{ optional($art->published_at)->format('Y-m-d') }}</div>
                            <div class="mt-2 flex gap-2">
                                <a href="{{ route('dashboard.artworks.edit', ['id' => $art->id]) }}" class="text-xs px-2 py-1 bg-black/10 rounded">Edit</a>
                                <form method="POST" action="{{ route('dashboard.artworks.destroy', ['id' => $art->id]) }}" onsubmit="return confirm('Really delete this artwork?');">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="text-xs px-2 py-1 bg-red-600 text-white rounded">Delete</button>
                                </form>
                            </div>
                        </div>
                    </div>
                @endforeach
            </div>

            <div class="mt-6">{{ $artworks->links() }}</div>
        @endif
    </div>
@endsection
