@page
@model TaxBaik.Web.Pages.Admin.Clients.IndexModel
@{
    ViewData["Title"] = "고객 관리";
}

<section class="admin-page-shell">
    @await Html.PartialAsync("_AdminPageHeader", new TaxBaik.Web.Models.AdminPageHeaderModel("고객 관리", "고객 목록", "검색, 상태 필터, 페이지네이션 기준의 고객 목록입니다.", "/admin/clients/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="Search">검색</label>
                        <input class="form-control form-control-sm" id="Search" name="search" value="@Model.Search" placeholder="이름, 전화, 회사" />
                    </div>
                    <div class="col-md-2">
                        <label class="form-label form-label-sm" for="Status">상태</label>
                        <select class="form-select form-select-sm" id="Status" name="status">
                            <option value="" selected="@(string.IsNullOrWhiteSpace(Model.Status))">전체</option>
                            <option value="active" selected="@(Model.Status == "active")">active</option>
                            <option value="inactive" selected="@(Model.Status == "inactive")">inactive</option>
                        </select>
                    </div>
                    <div class="col-auto">
                        <label class="form-label form-label-sm" for="PageSize">건수</label>
                        <select class="form-select form-select-sm" id="PageSize" name="pageSize">
                            <option value="10" selected="@(Model.PageSize == 10)">10</option>
                            <option value="20" selected="@(Model.PageSize == 20)">20</option>
                            <option value="50" selected="@(Model.PageSize == 50)">50</option>
                        </select>
                    </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/clients">초기화</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>등록일</th>
                            <th class="text-end">작업</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Items)
                        {
                            <tr>
                                <td class="fw-semibold">@item.Name</td>
                                <td>@item.CompanyName</td>
                                <td>@item.Phone</td>
                                <td>@await Html.PartialAsync("_StatusBadge", item.Status)</td>
                                <td>@item.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-outline-secondary" href="/admin/clients/@item.Id">상세</a>
                                        <a class="btn btn-sm btn-primary" href="/admin/clients/@item.Id/edit">수정</a>
                                    </div>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        }
        else
        {
            <div class="card-body">
                @await Html.PartialAsync("_EmptyState", "검색 결과가 없습니다.")
            </div>
        }
    </div>

    @await Html.PartialAsync("_Pagination", new TaxBaik.Web.Pages.Shared.PaginationModel(Model.CurrentPage, Model.TotalPages, Model.BuildPageUrl))
</section>









