<div>
    <div>
        <div class="card mb-4">
            <div class="card-body">
                <div class="row mb-3">
                    <div class="col-md-4">
                        <label for="search" class="form-label text-muted fw-bold">Search Album:</label>
                        <input wire:model.live="search" wire:keyup="updateSearch" type="text" id="search" class="form-control" placeholder="Search albums...">
                    </div>
                </div>

                <div class="table-responsive">
                    <table class="table table-striped table-auto table-sm">
                        <thead class="bg-secondary text-white">
                            <tr>
                                <th>#ID</th>
                                <th>Cover</th>
                                <th>Album Name</th>
                                <th>Description</th>
                                <th>Actions</th>
                                <th>Manage Photos</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($albums as $album)
                            <tr>
                                <td>{{ $album->id }}</td>
                                <td>
                                    @if($album->cover_photo)
                                        <img src="{{ asset('images/albums/' . $album->cover_photo) }}" class="img-thumbnail" style="max-width: 100px;" alt="{{ $album->title }}">
                                    @else
                                        <span class="badge bg-secondary text-white">No Image</span>
                                    @endif
                                </td>
                                <td>{{ $album->title }}</td>
                                <td>{{ Str::limit($album->description, 50) }}</td>
                                <td>
                                    <a href="{{ route('admin.edit_album', ['id' => $album->id]) }}" class="btn btn-sm btn-primary me-1">
                                        <i class="bi bi-pencil-square"></i>
                                    </a>
                                    <button wire:click="deleteAlbum({{ $album->id }})" class="btn btn-sm btn-danger">
                                        <i class="bi bi-trash"></i>
                                    </button>
                                </td>
                                <td>
                                    <a href="{{ route('admin.photos.list', ['album' => $album->id]) }}">
                                        <i class="bi bi-images"></i> Photos
                                    </a>
                                </td>
                            </tr>
                            @empty
                            <tr>
                                <td colspan="6" class="text-center text-muted">No albums found.</td>
                            </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>

                <div class="mt-3">
                    {{ $albums->links('livewire::simple-bootstrap') }}
                </div>
            </div>
        </div>
    </div>
</div>
