@model IEnumerable<iyixiGames.Domain.DTOs.Sites.SiteResponse>

@{
    ViewData["Title"] = "网站管理";
}

<div class="container mt-4">
    <div class="d-flex justify-content-between align-items-center mb-3">
        <h1>网站列表</h1>
        <a asp-action="Create" class="btn btn-primary">创建新网站</a>
    </div>

    <table class="table table-striped table-hover">
        <thead class="table-dark">
            <tr>
                <th>@Html.DisplayNameFor(model => model.Name)</th>
                <th>@Html.DisplayNameFor(model => model.Domain)</th>
                <th>@Html.DisplayNameFor(model => model.OwnerUserId)</th>
                <th>@Html.DisplayNameFor(model => model.Status)</th>
                <th>@Html.DisplayNameFor(model => model.CreatedAt)</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            @if (Model != null && Model.Any())
            {
                @foreach (var item in Model)
                {
                    <tr>
                        <td>@Html.DisplayFor(modelItem => item.Name)</td>
                        <td><a href="@item.Domain" target="_blank">@Html.DisplayFor(modelItem => item.Domain)</a></td>
                        <td>@Html.DisplayFor(modelItem => item.OwnerUserId)</td>
                        <td>
                            <span class="badge @(item.Status == "active" ? "bg-success" : (item.Status == "inactive" ? "bg-secondary" : "bg-warning"))">
                                @Html.DisplayFor(modelItem => item.Status)
                            </span>
                        </td>
                        <td>@Html.DisplayFor(modelItem => item.CreatedAt)</td>
                        <td>
                            <a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-sm btn-info me-1">编辑</a>
                            <a asp-action="Details" asp-route-id="@item.Id" class="btn btn-sm btn-secondary me-1">详情</a>
                            <a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-sm btn-danger">删除</a>
                        </td>
                    </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="6" class="text-center text-muted">暂无网站数据。</td>
                </tr>
            }
        </tbody>
    </table>
</div>