@page
@model JobsMedical.Web.Pages.Admin.ReviewsModel
@{
    ViewData["Title"] = "مدیریت نظرات";
}
<div class="page-head">
    <div class="container">
        <h1>نظرات کاربران</h1>
        <p class="muted"><a asp-page="/Admin/Overview">← پنل مدیریت</a></p>
    </div>
</div>

<div class="container section" style="max-width:820px;">
    @if (Model.Msg is not null) { <div class="alert alert-success">@Model.Msg</div> }
    @if (Model.Items.Count == 0)
    {
        <div class="card empty-state">نظری ثبت نشده است.</div>
    }
    else
    {
        foreach (var r in Model.Items)
        {
            <div class="card card-pad" style="margin-bottom:8px; @(r.IsApproved ? "" : "opacity:.6;")">
                <div style="display:flex; justify-content:space-between; align-items:flex-start; gap:10px;">
                    <div>
                        <strong>@r.Facility.Name</strong>
                        <span style="color:#f59e0b;">@(new string('★', r.Stars))</span>
                        @if (!r.IsApproved) { <span class="badge badge-type">پنهان</span> }
                        <div class="muted" style="font-size:13px;">@(r.User.FullName ?? "کاربر") · <span dir="ltr">@JalaliDate.ToPersianDigits(r.User.Phone)</span></div>
                        @if (!string.IsNullOrWhiteSpace(r.Comment)) { <p style="margin:6px 0 0;">@r.Comment</p> }
                    </div>
                    <div style="display:flex; gap:6px; flex-wrap:wrap;">
                        <form method="post" asp-page-handler="Toggle" asp-route-id="@r.Id"><button class="btn btn-outline" style="padding:4px 12px;">@(r.IsApproved ? "پنهان‌کردن" : "نمایش")</button></form>
                        <form method="post" asp-page-handler="Delete" asp-route-id="@r.Id" onsubmit="return confirm('حذف شود؟');"><button class="btn btn-outline" style="padding:4px 12px; color:var(--danger); border-color:var(--danger);">حذف</button></form>
                    </div>
                </div>
            </div>
        }
    }
</div>
