@model JobsMedical.Web.Services.Recommendation
@{
    var isJob = Model.IsJob;
    var role = isJob ? Model.Job!.Role?.Name : Model.Shift!.Role?.Name;
    var fac = isJob ? Model.Job!.Facility : Model.Shift!.Facility;
    var gender = isJob ? Model.Job!.GenderRequirement : Model.Shift!.GenderRequirement;
    var url = isJob ? $"/Jobs/Details/{Model.Job!.Id}" : $"/Shifts/Details/{Model.Shift!.Id}";
    string empLabel(JobsMedical.Web.Models.EmploymentType t) => t switch
    {
        JobsMedical.Web.Models.EmploymentType.PartTime => "پاره‌وقت",
        JobsMedical.Web.Models.EmploymentType.Contract => "قراردادی",
        JobsMedical.Web.Models.EmploymentType.Plan => "طرح",
        _ => "تمام‌وقت",
    };
}
<a class="card card-pad shift-card" href="@url">
    <div class="row" style="justify-content: space-between;">
        <span class="facility">@(role ?? (isJob ? "استخدام" : "شیفت"))</span>
        @if (isJob)
        {
            <span class="badge badge-job">استخدام</span>
        }
        else
        {
            var s = Model.Shift!;
            var (badgeClass, typeLabel) = s.ShiftType switch
            {
                ShiftType.Day => ("badge-day", "صبح"),
                ShiftType.Evening => ("badge-evening", "عصر"),
                ShiftType.Night => ("badge-night", "شب"),
                _ => ("badge-oncall", "آنکال"),
            };
            <span class="badge @badgeClass">@typeLabel</span>
        }
    </div>
    <div class="row">
        @if (gender != Gender.Any)
        {
            <span class="badge badge-gender">@JalaliDate.GenderLabel(gender)</span>
        }
        @if (JobsMedical.Web.Services.SeoJsonLd.HasRealEmployer(fac))
        {
            <span>🏥 @fac?.Name</span>
        }
        <span>📍 @fac?.City?.Name</span>
    </div>

    @if (isJob)
    {
        <div class="row">💼 @empLabel(Model.Job!.EmploymentType)</div>
    }
    else
    {
        var s = Model.Shift!;
        <div class="row">📅 @JalaliDate.WeekDayName(s.Date)، @JalaliDate.ToLongDate(s.Date) — 🕐 @JalaliDate.Time(s.StartTime)</div>
        <partial name="_HourBar" model="s" />
    }

    @* The "why" — what makes a pattern engine trustworthy: every pick is explained. *@
    <div class="rec-reasons">
        @foreach (var reason in Model.Reasons)
        {
            <span class="rec-reason">✓ @reason</span>
        }
    </div>

    <div class="foot">
        <span class="pay">
            @if (isJob)
            {
                @(Model.Job!.SalaryMin is long m ? JalaliDate.ToPersianDigits(m.ToString("#,0")) + " تومان" : "توافقی")
            }
            else
            {
                var s = Model.Shift!;
                @JalaliDate.PayLabel(s.PayType, s.PayAmount, s.SharePercent)
            }
        </span>
        <span class="btn btn-outline" style="padding: 6px 14px;">جزئیات</span>
    </div>
</a>
