@model JobsMedical.Web.Models.TalentListing
@{
    string comp;
    if (Model.PayType == JobsMedical.Web.Models.PayType.Percentage && Model.SharePercent is int sp)
        comp = $"{JalaliDate.ToPersianDigits(sp.ToString())}٪ سهم درآمد";
    else if (Model.PayAmount is long pa && pa > 0)
        comp = JalaliDate.Toman(pa) + " مدنظر";
    else
        comp = "توافقی";

    var heading = string.IsNullOrWhiteSpace(Model.PersonName)
        ? (Model.Role?.Name ?? "آماده به کار")
        : Model.PersonName!;
    var area = Model.District?.Name ?? Model.AreaNote;
    var q = ViewData["q"] as string;
    var tags = (Model.Tags ?? "").Split(' ', StringSplitOptions.RemoveEmptyEntries)
        .Where(t => t != Model.Role?.Name && t != Model.City?.Name).Distinct().Take(6).ToList();
}
<a class="card card-pad shift-card" asp-page="/Talent/Details" asp-route-id="@Model.Id">
    <div class="row" style="justify-content: space-between;">
        <span class="facility">@JobsMedical.Web.Services.SearchHighlight.Mark(heading, q)</span>
        <span class="badge badge-talent">آماده به کار</span>
    </div>
    <div class="row">
        @if (Model.Role is not null)
        {
            <span class="badge badge-type">@Model.Role.Name</span>
        }
        @if (Model.YearsExperience is int yrs && yrs > 0)
        {
            <span class="badge badge-day">@JalaliDate.ToPersianDigits(yrs.ToString()) سال سابقه</span>
        }
        @if (Model.IsLicensed)
        {
            <span class="badge badge-verified">پروانه‌دار</span>
        }
        @if (Model.Gender != JobsMedical.Web.Models.Gender.Any)
        {
            <span class="badge badge-gender">@JalaliDate.GenderLabel(Model.Gender)</span>
        }
    </div>
    <div class="row">📍 @Model.City?.Name@(area is not null ? "، " + area : "")</div>
    @{ var snip = JobsMedical.Web.Services.SearchHighlight.Snippet(Model.Description ?? Model.Tags, q); }
    @if (snip.Value.Length > 0)
    {
        <div class="search-snippet">@snip</div>
    }
    @if (tags.Count > 0)
    {
        <div class="tag-chips">
            @foreach (var tg in tags)
            {
                <span class="tag-chip">@JobsMedical.Web.Services.SearchHighlight.Mark(tg, q)</span>
            }
        </div>
    }
    <div class="foot">
        <span class="pay">@comp</span>
        <span class="btn btn-accent contact-trigger" style="padding: 6px 14px;" data-contact-type="talent" data-contact-id="@Model.Id">📞 مشاهده و تماس</span>
    </div>
</a>
