@model IEnumerable<Watcher.Models.Server>

<div class="container py-4">
    <div class="row g-4">
        @foreach (var s in Model)
        {
            <div class="col-12 col-sm-6">
                <div class="card h-100 border-secondary shadow-sm">
                    <div class="card-body d-flex flex-column gap-3">
                        <div class="d-flex justify-content-between align-items-center mb-3">
                            <h5 class="card-title text-dark mb-0">
                                <i class="bi bi-pc-display me-2 text-muted"></i>(#@s.Id) @s.Name
                            </h5>
                            <span class="badge
                                @(s.IsOnline ? "bg-success text-light" : "bg-danger text-light")">
                                <i class="bi @(s.IsOnline ? "bi-check-circle" : "bi-x-circle") me-1"></i>
                                @(s.IsOnline ? "Online" : "Offline")
                            </span>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-5 text-muted small">
                                <div><i class="bi bi-globe me-1"></i><strong>IP:</strong> @s.IPAddress</div>
                                <div><i class="bi bi-pc-display me-1"></i><strong>Typ:</strong> @s.Type</div>
                                <div><i class="bi bi-calendar-check me-1"></i><strong>Erstellt:</strong> @s.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
                                <div><i class="bi bi-clock me-1"></i><strong>Last-Seen:</strong> @s.LastSeen.ToLocalTime().ToString("dd.MM.yyyy HH:mm")</div>
                                <div><i class="bi bi-cpu me-1"></i><strong>CPU:</strong> @(s.CpuType ?? "not found") </div>
                                <div><i class="bi bi-cpu me-1"></i><strong>CPU-Kerne: </strong> @s.CpuCores </div>
                                <div><i class="bi bi-gpu-card me-1"></i><strong>GPU:</strong> @(s.GpuType ?? "not found") </div>
                                <div><i class="bi bi-memory me-1"></i><strong>RAM:</strong> @(s.RamSize) </div>
                                <div><i class="bi bi-hdd me-1"></i><strong>Disk Space:</strong> ... </div>
                            </div>
                        </div>

                        <div class="d-flex flex-wrap gap-2">

                            <a asp-action="EditServer" asp-route-id="@s.Id" class="btn btn-outline-primary">
                                <i class="bi bi-pencil-square me-1"></i> Bearbeiten
                            </a>

                            <a asp-asp-controller="Server" asp-action="Details" asp-route-id="@s.Id" class="btn btn-outline-primary">
                                <i class="bi bi-bar-chart-fill me-1"></i> Metrics
                            </a>

                            <a asp-asp-controller="Container" asp-action="Overview" asp-route-id="@s.Id" class="btn btn-outline-primary">
                                <i class="bi bi-box-fill me-1"></i> Container
                            </a>

                            <form asp-action="Delete" asp-route-id="@s.Id" method="post" onsubmit="return confirm('Diesen Server wirklich löschen?');" class="m-0">
                                <button type="submit" class="btn btn-outline-danger">
                                    <i class="bi bi-trash me-1"></i> Löschen
                                </button>
                            </form>
                            
                        </div>
                    </div>
                </div>
            </div>
        }
    </div>
</div>
