@extends('layouts.app')

@section('title', 'Manage Photo Gallery - Admin Portal')

@section('content')
<div class="bg-black text-white py-8 border-b border-neutral-800">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 flex justify-between items-center">
        <h1 class="font-serif-heading font-extrabold text-2xl">Media Album Manager</h1>
        <a href="{{ route('admin.gallery.create') }}" class="px-4 py-2.5 bg-brand-blue text-white font-bold text-xs uppercase tracking-widest">
            + Upload Photo Album
        </a>
    </div>
</div>

<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-10">
    <div class="bg-white border border-gray-200 overflow-hidden">
        <div class="overflow-x-auto">
            <table class="w-full text-left text-sm text-gray-700">
                <thead class="bg-gray-50 text-[10px] font-bold text-gray-500 uppercase border-b border-gray-100">
                    <tr>
                        <th class="px-6 py-4">Title</th>
                        <th class="px-6 py-4">Category</th>
                        <th class="px-6 py-4">Date Uploaded</th>
                        <th class="px-6 py-4">Actions</th>
                    </tr>
                </thead>
                <tbody class="divide-y divide-gray-100">
                    @foreach($galleries as $item)
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 font-bold text-black flex items-center space-x-3">
                                <img src="{{ asset($item->image) }}" class="w-12 h-12 object-cover border border-gray-200">
                                <span>{{ $item->title }}</span>
                            </td>
                            <td class="px-6 py-4 text-xs font-semibold">{{ $item->category }}</td>
                            <td class="px-6 py-4 text-xs text-gray-400">{{ $item->created_at->format('M d, Y') }}</td>
                            <td class="px-6 py-4">
                                <form action="{{ route('admin.gallery.delete', $item->id) }}" method="POST" onsubmit="return confirm('Delete gallery item?');">
                                    @csrf
                                    @method('DELETE')
                                    <button type="submit" class="text-xs text-red-600 font-bold hover:underline">Delete</button>
                                </form>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
        <div class="p-4 border-t border-gray-100">
            {{ $galleries->links() }}
        </div>
    </div>
</div>
@endsection
