{% extends 'layouts/base.html' %}

{% load static %}

{% block title %}{% endblock title %}

{% block stylesheets %}
<link type="text/css" rel="stylesheet" href="{% static '/css/home/index.css' %}">
<link type="text/css" rel="stylesheet" href="{% static '/css/home/select2.css' %}">
{% endblock stylesheets %}

{% block content %}
<div class="container-lg px-0 h-100">
    <div class="d-flex flex-nowrap h-100 border-start border-end">
        <div class="d-flex flex-column bg-body-tertiary py-3 border-end" style="width: 4.5rem">
            <ul id="serverList" class="nav nav-pills nav-flush flex-column mb-auto text-center">
                <li class="nav-item">
                    <button type="button" id="newServerBtn" class="btn btn-outline-primary rounded-1 mt-1" style="width: 46px; height: 46px;">
                        <i class="bi bi-plus-lg fs-5"></i>
                    </button>
                </li>
            </ul>
        </div>
        <div class="flex-grow-1 container-fluid bg-body overflow-y-auto" style="min-width: 0;">
            <div id="noSelectedServer">
                select a server
            </div>
            <div id="selectedServerContainer" class="row" style="display: none;">
                <div class="col-12 bg-body-tertiary border-bottom">
                    <div class="px-3 py-4 d-flex justify-content-start align-items-center">
                        <img src="" alt="Selected Server Icon" class="rounded-3 selected-server-icon">
                        <div class="ms-3" style="min-width: 0">
                            <h3 class="mb-0 selected-server-name text-truncate"></h3>
                            <h5 class="mb-0 selected-server-id text-truncate text-body-secondary"></h5>
                        </div>
                        <div class="ms-auto">
                            <a href="" id="invitePyrssToServerBtn" class="btn btn-outline-info rounded-1" target="_blank" data-bs-toggle="tooltip" data-bs-title="Invite @PYRSS Bot">
                                <i class="bi bi-envelope"></i>
                            </a>
                            <button type="button" id="deleteSelectedServerBtn" class="btn btn-outline-danger rounded-1 ms-3">
                                <i class="bi bi-x-lg"></i>
                            </button>
                        </div>
                    </div>
                </div>

                <div class="col-12 m-0">
                    <div id="serverJoinAlert" class="alert alert-warning alert-dismissable fade show mt-4 d-flex align-items-center" role="alert" style="display: none !important">
                        <i class="bi bi-warning"></i>
                        <span>
                            <strong>Warning:</strong>
                            The Bot isn't a member of this server, please <a href="" class="alert-link" target="_blank">invite the bot</a> to use it.
                        </span>

                        <button type="button" class="btn-close ms-auto" data-bs-dismiss="alert" aria-label="Close"></button>
                    </div>
                </div>

                <div class="col-12">
                    <div class="d-flex px-3 pt-4 pb-2">
                        <ul id="serverTabs" class="nav nav-pills me-auto" role="tablist">
                            <li class="nav-item" role="presentation">
                                <button id="subscriptionsTab" class="nav-link rounded-1" data-bs-toggle="tab" data-bs-target="#subscriptionsTabPane" type="button" aria-controls="subscriptionsTabPane" aria-selected="false">Subscriptions</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button id="filtersTab" class="nav-link rounded-1" data-bs-toggle="tab" data-bs-target="#filtersTabPane" type="button" aria-controls="filtersTabPane" aria-selected="false">Content Filters</button>
                            </li>
                            <li class="nav-item" role="presentation">
                                <button id="contentTab" class="nav-link rounded-1" data-bs-toggle="tab" data-bs-target="#contentTabPane" type="button" aria-controls="contentTabPane" aria-selected="false">Tracked Content</button>
                            </li>
                        </ul>
                        <div class="tab-pane-buttons">
                            <div class="tab-pane-buttons-item" data-tab="subscriptionsTab">
                                <button type="button" id="refreshSubscriptionBtn" class="btn btn-outline-secondary rounded-1 me-3">
                                    <i class="bi bi-arrow-clockwise"></i>
                                </button>
                                <button type="button" id="addSubscriptionBtn" class="btn btn-primary rounded-1 me-3">
                                    <i class="bi bi-plus-lg"></i>
                                </button>
                                <button type="button" id="deleteSelectedSubscriptionsBtn" class="btn btn-danger rounded-1 ms-0" disabled>
                                    <i class="bi bi-trash3"></i>
                                </button>
                            </div>
                            <div class="tab-pane-buttons-item" data-tab="filtersTab">
                                <button type="button" id="refreshFilterBtn" class="btn btn-outline-secondary rounded-1 me-3">
                                    <i class="bi bi-arrow-clockwise"></i>
                                </button>
                                <button type="button" id="addFilterBtn" class="btn btn-primary rounded-1 me-3">
                                    <i class="bi bi-plus-lg"></i>
                                </button>
                                <button type="button" id="deleteSelectedFiltersBtn" class="btn btn-danger rounded-1 ms-0">
                                    <i class="bi bi-trash3"></i>
                                </button>
                            </div>
                            <div class="tab-pane-buttons-item" data-tab="contentTab">
                                <button type="button" id="refreshContentBtn" class="btn btn-outline-secondary rounded-1 me-3">
                                    <i class="bi bi-arrow-clockwise"></i>
                                </button>
                                <button type="button" id="deleteSelectedContentBtn" class="btn btn-danger rounded-1 ms-0">
                                    <i class="bi bi-trash3"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-12">
                    <div id="serverTabContent" class="tab-content">
                        <div id="subscriptionsTabPane" class="tab-pane fade" role="tabpanel" aria-labelledby="subscriptionsTab" tabindex="0"></div>
                        <div id="filtersTabPane" class="tab-pane fade includes-table includes-table-controls includes-table-search" role="tabpanel" aria-labelledby="filtersTab" tabindex="0">  </div>
                        <div id="contentTabPane" class="tab-pane fade" role="tabpanel" aria-labelledby="contentTab" tabindex="0"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% include "home/includes/servermodal.html" %}
{% include "home/includes/submodal.html" %}
{% include "home/includes/filtermodal.html" %}
{% endblock content %}

{% block javascript %}
<script id="serverItemTemplate" type="text/template">
    <li class="nav-item server-item" data-id="" data-bs-toggle="tooltip" data-bs-placement="right">
        <button type="button" class="btn border-0 server-item-selector mb-2">
            <img src="" alt="Guild Icon" class="rounded-circle" width="46" height="46">
        </button>
    </li>
</script>
<script src="{% static 'js/api.js' %}"></script>
<script src="{% static 'js/table.js' %}"></script>
<script src="{% static 'js/home/index.js' %}"></script>
<script src="{% static 'js/home/servers.js' %}"></script>
<script src="{% static 'js/home/subscriptions.js' %}"></script>
<script src="{% static 'js/home/filters.js' %}"></script>
<script src="{% static 'js/home/content.js' %}"></script>
{% endblock javascript %}