@page
@model TaxBaik.Web.Pages.Admin.Blog.IndexModel
@{
    ViewData["Title"] = "블로그";
}

<section class="admin-page-shell">
    @await Html.PartialAsync("_AdminPageHeader", new TaxBaik.Web.Models.AdminPageHeaderModel("콘텐츠", "블로그 관리", "검색, 발행 상태, 작성일 기준의 블로그 목록입니다.", "/admin/blog/create", "새 글 작성"))

    <div class="card">
        <div class="card-body p-2">
            <form method="get">
                <div class="row g-2 align-items-end">
                    <div class="col-md-4">
                        <label class="form-label form-label-sm" for="SearchQuery">검색</label>
                        <input class="form-control form-control-sm" id="SearchQuery" name="searchQuery" value="@Model.SearchQuery" placeholder="제목 또는 본문" />
                    </div>
                    <div class="col-auto">
                        <button class="btn btn-primary btn-sm" type="submit">검색</button>
                    </div>
                    <div class="col-auto">
                        <a class="btn btn-outline-secondary btn-sm" href="/admin/blog">초기화</a>
                    </div>
                    <div class="col-auto">
                        <a class="btn btn-outline-secondary btn-sm" href="/admin/blog?showArchived=true">내린 글</a>
                    </div>
                </div>
            </form>
        </div>
        @if (Model.Items.Count > 0)
        {
            <div class="table-responsive table-responsive--separator">
                <table class="table table-vcenter card-table table-hover">
                    <thead>
                        <tr>
                            <th>제목</th>
                            <th>발행</th>
                            <th>조회수</th>
                            <th>작성일</th>
                            <th class="text-end">작업</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var post in Model.Items)
                        {
                            <tr>
                                <td>
                                    <div class="fw-semibold">@post.Title</div>
                                    <div class="text-muted small">@post.Slug</div>
                                </td>
                                <td>@await Html.PartialAsync("_StatusBadge", post.IsPublished ? "active" : "inactive")</td>
                                <td>@post.ViewCount</td>
                                <td>@post.CreatedAt.ToString("yyyy-MM-dd")</td>
                                <td class="text-end">
                                    <div class="btn-list flex-nowrap justify-content-end">
                                        <a class="btn btn-sm btn-primary" href="/admin/blog/@post.Id/edit">수정</a>
                                        <a class="btn btn-sm btn-outline-secondary" href="/blog/@post.Slug" target="_blank">보기</a>
                                    </div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        }
        else
        {
            <div class="card-body py-4">
                @await Html.PartialAsync("_EmptyState", "블로그 글이 없습니다.")
            </div>
        }
    </div>
</section>









