@model List<Device>
@{ ViewData["Title"] = "Posts (Devices)"; }

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

@if (Model.Any())
{
    <div class="row g-4">
        @foreach (var device in Model)
        {
            <div class="col-md-6 col-lg-4">
                <div class="card device-card h-100">
                    <div class="card-body">
                        <h5 class="card-title"><i class="bi bi-display me-2"></i>@device.Name</h5>
                        <div class="device-meta mb-3">
                            <span class="badge bg-dark"><i class="bi bi-aspect-ratio me-1"></i>@(device.ResolutionWidth)x@(device.ResolutionHeight)</span>
                            <span class="badge bg-secondary"><i class="bi bi-layers me-1"></i>@device.DeviceSlides.Count meow(s)</span>
                            <span class="badge bg-info"><i class="bi bi-shuffle me-1"></i>@device.Transition</span>
                        </div>
                        <div class="mb-3">
                            <label class="form-label text-muted small">Display URL</label>
                            <div class="input-group input-group-sm">
                                <span class="input-group-text"><i class="bi bi-link-45deg"></i></span>
                                <input type="text" class="form-control font-monospace" value="/@device.Slug" readonly />
                                <a href="/@device.Slug" target="_blank" class="btn btn-outline-success"><i class="bi bi-box-arrow-up-right"></i></a>
                            </div>
                        </div>
                    </div>
                    <div class="card-footer d-flex gap-2">
                        <a href="/admin/devices/playlist/@device.Id" class="btn btn-primary btn-sm flex-fill"><i class="bi bi-music-note-list me-1"></i>Playlist</a>
                        <a href="/admin/devices/edit/@device.Id" class="btn btn-outline-secondary btn-sm"><i class="bi bi-pencil"></i></a>
                        <a href="/admin/devices/delete/@device.Id" class="btn btn-outline-danger btn-sm"><i class="bi bi-trash"></i></a>
                    </div>
                </div>
            </div>
        }
    </div>
}
else
{
    <div class="empty-state">
        <i class="bi bi-display" style="font-size:3em;"></i>
        <h4 class="mt-3">No posts yet</h4>
        <p class="text-muted">Create your first display device.</p>
        <a href="/admin/devices/create" class="btn btn-primary"><i class="bi bi-plus-lg me-1"></i>Create Post</a>
    </div>
}
