{% extends 'base.html.twig' %}

{% block header %}
<header class="site-header">
    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container">
            <a class="navbar-brand" href="{{ path('website_home') }}">
                <img src="{{ asset('images/logo.png') }}" alt="{{ 'site.name'|trans }}">
                {{ 'site.name'|trans }}
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#siteNav"
                    aria-controls="siteNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="siteNav">
                <ul class="navbar-nav ms-auto align-items-lg-center gap-lg-2">
                    <li class="nav-item">
                        <a class="nav-link" href="{{ path('website_home') }}">{{ 'nav.home'|trans }}</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ path('game_dashboard') }}">{{ 'nav.game'|trans }}</a>
                    </li>
                    {% if app.user %}
                        {% if is_granted('ROLE_ADMIN') %}
                            <li class="nav-item">
                                <a class="nav-link" href="{{ path('game_admin_dashboard') }}">{{ 'nav.admin'|trans }}</a>
                            </li>
                        {% endif %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ path('app_logout') }}">{{ 'nav.logout'|trans }}</a>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ path('app_register') }}">{{ 'nav.register'|trans }}</a>
                        </li>
                        <li class="nav-item">
                            <a class="btn btn-sm btn-outline-light ms-lg-2" href="{{ path('app_login') }}">{{ 'nav.login'|trans }}</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>
</header>
{% endblock %}

{% block main %}
<main class="site-main">
    <div class="container py-4">
        {% for label, messages in app.flashes %}
            {% for message in messages %}
                <div class="alert alert-{{ label }} alert-dismissible fade show" role="alert">
                    {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
            {% endfor %}
        {% endfor %}
        {% block body %}{% endblock %}
    </div>
</main>
{% endblock %}

{% block footer %}
<footer class="site-footer py-4">
    <div class="container text-center small">
        <div class="mb-1">
            <a href="{{ path('website_help_wanted') }}" class="link-light">{{ 'footer.help_wanted'|trans }}</a>
        </div>
        &copy; {{ "now"|date("Y") }} {{ 'site.name'|trans }}
    </div>
</footer>
{% endblock %}
