@model JobsMedical.Web.Models.JobOpening
@{
    string empLabel = Model.EmploymentType switch
    {
        EmploymentType.FullTime => "تمام‌وقت",
        EmploymentType.PartTime => "پاره‌وقت",
        EmploymentType.Contract => "قراردادی",
        _ => "طرح",
    };
    string salary;
    if (Model.SalaryMin is null && Model.SalaryMax is null) salary = "توافقی";
    else if (Model.SalaryMin == Model.SalaryMax) salary = JalaliDate.Toman(Model.SalaryMin) + " ماهانه";
    else salary = $"از {JalaliDate.ToPersianDigits((Model.SalaryMin ?? 0).ToString("#,0"))} تا {JalaliDate.Toman(Model.SalaryMax)} ماهانه";
    var q = ViewData["q"] as string;
}
<a class="card card-pad shift-card" asp-page="/Jobs/Details" asp-route-id="@Model.Id">
    <div class="row" style="justify-content: space-between;">
        <span class="facility">@JobsMedical.Web.Services.SearchHighlight.Mark(Model.Title, q)</span>
        <span class="badge badge-job">@empLabel</span>
    </div>
    <div class="row">
        @if (Model.Role is not null)
        {
            <span class="badge badge-type">@JobsMedical.Web.Services.SearchHighlight.Mark(Model.Role.Name, q)</span>
        }
        @if (Model.GenderRequirement != Gender.Any)
        {
            <span class="badge badge-gender">@JalaliDate.GenderLabel(Model.GenderRequirement)</span>
        }
        <span>🏥 @JobsMedical.Web.Services.SearchHighlight.Mark(Model.Facility?.Name, q)</span>
    </div>
    <div class="row">📍 @Model.Facility?.City?.Name@(Model.Facility?.District is not null ? "، " + Model.Facility.District.Name : "")</div>
    @if (Model.DistanceKm is double km)
    {
        <div class="row"><span class="badge badge-distance">📍 @JalaliDate.ToPersianDigits(km.ToString("0.#")) کیلومتر از شما</span></div>
    }
    @{ var snip = JobsMedical.Web.Services.SearchHighlight.Snippet(Model.Description, q); }
    @if (snip.Value.Length > 0)
    {
        <div class="search-snippet">@snip</div>
    }
    <div class="foot">
        <span class="pay">@salary</span>
        <span class="btn btn-outline" style="padding: 6px 14px;">جزئیات</span>
    </div>
</a>
