@model IList<SharedLibraryCore.Dtos.PlayerInfo>
@{
    var loc = Utilities.CurrentLocalization.LocalizationIndex;
}

<!-- desktop -->
<div class="content mt-0">
    <h2 class="content-title mt-20 mb-0">@loc["WEBFRONT_SEARCH_RESULTS_TITLE"]</h2>
    <div class="text-muted mb-15">
        @foreach (var match in Utilities.SplitTranslationTokens("WEBFRONT_SEARCH_RESULTS_SUBTITLE_FORMAT"))
        {
            if (match.IsInterpolation)
            {
                if (match.MatchValue == "searchTerm")
                {
                    <span class="badge">
                        @ViewBag.SearchTerm
                    </span>
                }
                
                else if (match.MatchValue == "searchCount")
                {
                    <span class="text-primary">@ViewBag.ResultCount</span>
                }
            }
            else
            {
                <span>@match.MatchValue</span>
            }
        }
    </div>

    <table class="table d-none d-md-table">
        <thead>
        <tr class="bg-primary text-light">
            <td>@loc["WEBFRONT_PENALTY_TEMPLATE_NAME"]</td>
            <td>@loc["WEBFRONT_PROFILE_LEVEL"]</td>
            <td class="text-right">@loc["WEBFRONT_SEARCH_LAST_CONNECTED"]</td>
        </tr>
        </thead>
        <tbody>
        @foreach (var client in Model)
        {
            <tr class="bg-dark-dm bg-light-lm">
                <td class="col-5">
                    <a asp-controller="Client" asp-action="Profile" asp-route-id="@client.ClientId">
                        <color-code value="@client.Name"></color-code>
                    </a>
                </td>
                @if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
                {
                    <td class="col-3 level-color-0">@loc["GLOBAL_PERMISSION_USER"]</td>
                }
                else
                {
                    <td class="col-3 level-color-@client.LevelInt">@client.Level</td>
                }
                <td class="col-4 text-right">@client.LastConnection.HumanizeForCurrentCulture()</td>
            </tr>
        }
        </tbody>
    </table>


    <!--- mobile -->
    <table class="table bg-dark-dm bg-light-lm d-md-none">
        <tbody>
        @foreach (var client in Model)
        {
            <tr class="d-flex">
                <td class="bg-primary text-light">
                    <div>@loc["WEBFRONT_PENALTY_TEMPLATE_NAME"]</div>
                    <div>@loc["WEBFRONT_PROFILE_LEVEL"]</div>
                    <div>@loc["WEBFRONT_SEARCH_LAST_CONNECTED"]</div>
                </td>
                <td class="flex-grow">
                    <a asp-controller="Client" asp-action="Profile" asp-route-id="@client.ClientId" class="link-inverse">
                        <color-code value="@client.Name"></color-code>
                    </a>
                    @if (!ViewBag.Authorized && ViewBag.EnablePrivilegedUserPrivacy)
                    {
                        <div class="p-2 level-color-0">@loc["GLOBAL_PERMISSION_USER"]</div>
                    }
                    else
                    {
                        <div class="p-2 level-color-@client.LevelInt">@client.Level</div>
                    }
                    <div>@client.LastConnection.HumanizeForCurrentCulture()</div>
                </td>
            </tr>
        }
        </tbody>
    </table>


</div>
