{% extends '__layout__.html' %}
{% block title %}Home{% endblock %}
{% block head %}
<link href="/static/css/home.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
{% endblock %}
{% block content %}
<div id="main">
    <div class="container">
        {% if not isEmailVerified: %}
        <div class="alert alert-warning d-flex align-items-center p-2">
            <i class="bi bi-envelope-plus ms-2" style="font-size:30px;"></i>
            <div class="m-2">Verify your email to secure your account and get a free item!</div>
            <a href="/settings/update-email" class="ms-auto text-decoration-none me-2"><button
                    class="btn btn-sm btn-primary">Verify Email</button></a>
        </div>
        {%endif%}
        {% if not isDiscordLinked: %}
        <div class="alert alert-info d-flex align-items-center p-2">
            <i class="bi bi-discord ms-2" style="font-size:30px;"></i>
            <div class="m-2">Link your Discord Account and get a lifetime builders club membership for free!</div>
            <a href="/settings/discord_link" class="ms-auto text-decoration-none me-2"><button
                    class="btn btn-sm btn-primary">Link Discord</button></a>
        </div>
        {%endif%}
        <div class="d-flex align-items-center">
            <img class="rounded overflow-hidden me-4" src="/Thumbs/Head.ashx?x=150&y=150&userId={{currentuser.id}}"
                style="width:auto;max-height:130px;border-radius:4px;" />
            <div class="mt-2">
                <h1>Hello, {{currentuser.username}}!</h1>
                {% if membershipValue == 1: %}<span class="rbx-icon-bc"></span>{%endif%}
                {% if membershipValue == 2: %}<span class="rbx-icon-tbc"></span>{%endif%}
                {% if membershipValue == 3: %}<span class="rbx-icon-negative-obc"></span>{%endif%}
            </div>
        </div>
        <h4>Friends ( {{friendcount}} )</h4>
        <div class="w-100 p-2 d-flex card-container" style="overflow-x:auto;min-height:100px;">
            {% for friend in friends %}
            <a href="/users/{{friend.id}}/profile" style="text-decoration:none;">
                <div style="height:fit-content;width:90px;" class="me-3">
                    <div class="image-container">
                        <img class="rounded w-100 d-table" src="/Thumbs/Head.ashx?x=100&y=100&userId={{friend.id}}"
                            style="margin:0 auto;max-width:100px;" alt="{{friend.username}}" />
                        {% if friend.isonline: %}<div
                            class="status-icon {% if friend.ingame: %}status-icon-green{% endif %}"></div>{% endif %}
                    </div>
                    <p class="text-white w-100 text-center d-inline-block m-0 text-truncate" style="font-size:12px;">
                        {{friend.username}}</p>
                </div>
            </a>
            {% endfor %}
            {% if friendcount == 0: %}
            <p style="margin:auto;" class="d-flex align-items-center">You have no friends <img width="21" height="21"
                    src="https://media.tenor.com/jeYb8iK3YfsAAAAi/skull-skullgif.gif" style="margin-left:6px;"></p>
            {% endif %}
        </div>
        <h4 class="mt-3">Recently Played</h4>
        <div class="w-100 p-2 d-flex" style="overflow-x:auto;min-height:100px;">
            {% for place in recentlyplayed %}
            <a class="text-decoration-none" href="/games/{{place.id}}/">
                <div class="me-3 overflow-hidden rounded place-card">
                    <div class="position-relative">
                        <img width="100%" style="aspect-ratio:1/1;"
                            src="/Thumbs/PlaceIcon.ashx?assetId={{place.id}}&x=150&y=150" alt="{{place.name}}">
                        <div class="position-absolute" style="bottom:0;left:0;">
                            <div class="fw-bold text-white"
                                style="font-size:12px;padding:3px;border-top-right-radius:4px;background:rgba(0,0,0,0.55);">
                                {{place.placeyear.value}}</div>
                        </div>
                    </div>
                    <div class="p-1">
                        <h5 class="mb-0" style="font-size:17px;text-overflow:ellipsis;">{{place.name}}</h5>
                        <div class="d-flex align-items-center">
                            <p style="margin:0;font-size:14px;" class="text-secondary"><i class="bi bi-people"></i>
                                {{place.playercount}} <span style="font-size:13px;">Playing</span></p>
                        </div>
                        <div class="w-100 votePercentageBackground">
                            <div class="votePercentageFill" style="width:{{place.likePercentage}}%;"></div>
                            <div>
                                <div class="segment" style="left:18%;"></div>
                                <div class="segment" style="left:38%;"></div>
                                <div class="segment" style="left:58%;"></div>
                                <div class="segment" style="left:78%;"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </a>
            {% endfor %}
            {% if recentlyplayedcount == 0: %}
            <p style="margin:auto;">Looks like you haven't played any games yet.. maybe go <a
                    class="text-decoration-none" href="/games">play</a> one!</p>
            {% endif %}
        </div>
    </div>
</div>
{% endblock %}