@model List<Slide>
@{
    ViewData["Title"] = "Meows (Slides)";
}

@section HeaderActions {
    <a href="/admin/slides/create" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i>New Meow</a>
}

@if (Model.Any())
{
    <div class="table-responsive">
        <table class="table table-hover align-middle">
            <thead>
                <tr><th>Name</th><th>Type</th><th>Assigned To</th><th>Updated</th><th class="text-end">Actions</th></tr>
            </thead>
            <tbody>
                @foreach (var slide in Model)
                {
                    <tr>
                        <td><strong>@slide.Name</strong></td>
                        <td>
                            @switch (slide.SlideType)
                            {
                                case SlideType.Content: <span class="badge bg-info"><i class="bi bi-file-richtext me-1"></i>Content</span> break;
                                case SlideType.Embed: <span class="badge bg-warning text-dark"><i class="bi bi-globe me-1"></i>Embed</span> break;
                                case SlideType.IcsCalendar: <span class="badge bg-success"><i class="bi bi-calendar-event me-1"></i>Calendar</span> break;
                            }
                        </td>
                        <td>
                            @if (slide.DeviceSlides.Any()) { @foreach (var ds in slide.DeviceSlides) { <span class="badge bg-secondary me-1">@ds.Device.Name</span> } }
                            else { <span class="text-muted">Unassigned</span> }
                        </td>
                        <td><small class="text-muted">@slide.UpdatedAt.ToString("dd MMM yyyy HH:mm")</small></td>
                        <td class="text-end">
                            <div class="btn-group btn-group-sm">
                                <a href="/admin/slides/preview/@slide.Id" target="_blank" class="btn btn-outline-secondary" title="Preview"><i class="bi bi-eye"></i></a>
                                <a href="/admin/slides/edit/@slide.Id" class="btn btn-outline-primary" title="Edit"><i class="bi bi-pencil"></i></a>
                                <a href="/admin/slides/delete/@slide.Id" class="btn btn-outline-danger" title="Delete"><i class="bi bi-trash"></i></a>
                            </div>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}
else
{
    <div class="empty-state">
        <i class="bi bi-layers" style="font-size:3em;"></i>
        <h4 class="mt-3">No meows yet</h4>
        <p class="text-muted">Create your first slide to get started.</p>
        <a href="/admin/slides/create" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i>Create Meow</a>
    </div>
}
