{% set company = guest.system_company %}
<!DOCTYPE html>
<html lang="{{ lang }}">
<head>
    <title>{% block meta_title %}{% endblock %} {{ settings.meta_title }}</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <meta property="bb:url" content="{{ constant('BB_URL') }}">
    <meta property="bb:client_area" content="{{ '/'|link }}">

    <meta name="description" content="{% block meta_description %}{{ settings.meta_description }}{% endblock %}">
    <meta name="keywords" content="{% block meta_keywords %}{{ settings.meta_keywords }}{% endblock %}">
    <meta name="robots" content="{% if settings.meta_robots|default %}{{ settings.meta_robots }}{% else %}index, follow{% endif %}">
    <meta name="author" content="{{ settings.meta_author }}">

    {% if settings.favicon %}
        <link rel="icon" href="{{ settings.favicon }}">
    {% endif %}

    <!-- Bootstrap Core CSS -->
    {% if settings.theme != 'default' %}
        <link href="{{ 'css/themes/theme-'|asset_url }}{{ settings.theme }}.min.css" rel="stylesheet">
    {% else %}
        <link href="{{ 'css/bootstrap.min.css'|asset_url }}" rel="stylesheet">
    {% endif %}

    <!-- Bootstrap Markdown Editor -->
    <link href="{{ 'css/bootstrap-markdown.min.css'|asset_url }}" rel="stylesheet">

    {% if settings.inject_css|default %}
        <!-- Custom CSS -->
        <style>
            {{ settings.inject_css|raw }}
        </style>
    {% endif %}

    <!-- Font Awesome -->
    <link href="{{ 'font-awesome/css/fontawesome.min.css'|asset_url }}" rel="stylesheet">
    <link href="{{ 'font-awesome/css/solid.min.css'|asset_url }}" rel="stylesheet">

    {% block opengraph %}{% endblock %}
    {% block head %}{% endblock %}
</head>

<body class="bg-light">
    {% if guest.extension_is_on({ 'mod': 'cookieconsent' }) %}
        {% include 'mod_cookieconsent_index.phtml' ignore missing %}
    {% endif %}

    <header>
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-5" role="navigation" aria-label="Navigation">
            <div class="container">
                <button class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#mainmenu" aria-controls="mainmenu" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <a class="navbar-brand" href="{{ '/'|link }}">{{ company.name }}</a>
                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="mainmenu">
                    <ul class="nav navbar-nav ms-auto">
                        <li class="nav-item position-relative">
                            <a href="{{ 'cart'|link }}" class="nav-link" title="{{ 'Shopping cart'|trans }}">
                                <i class="fa fa-shopping-cart me-2"></i>
                                {% if guest.cart_get.items|length > 0 %}
                                    <span class="badge rounded-pill bg-danger">{{ guest.cart_get.items|length }}</span>
                                {% endif %}
                            </a>
                        </li>
                        {# {% if settings.side_menu_home %}
                        <li class="nav-item d-sm-none">
                            <a href="{{ ''|link }}" class="nav-link" title="{{ 'Home'|trans }}">
                                <i class="fa fa-home me-2"></i>{{ 'Home'|trans }}</a>
                        </li>
                        {% endif %} #}
                        {% if settings.side_menu_order %}
                        <li class="nav-item d-sm-none">
                            <a href="{{ '/order'|link }}" class="nav-link" title="{{ 'Order'|trans }}">
                                <i class="fa fa-shopping-cart me-2"></i>{{ 'Order'|trans }}</a>
                        </li>
                        {% endif %}
                        {% if settings.side_menu_blog and guest.extension_is_on({ 'mod': 'news' }) %}
                        <li class="nav-item d-sm-none">
                            <a href="{{ '/news'|link }}" class="nav-link" title="{{ 'Blog'|trans }}">
                                <i class="fa fa-bullhorn me-2"></i>{{ 'Blog'|trans }}</a>
                        </li>{% endif %}
                        {% if settings.side_menu_forum and guest.extension_is_on({ 'mod': 'forum' }) %}
                        <li class="nav-item d-sm-none">
                            <a href="{{ '/forum'|link }}" class="nav-link">
                                <i class="fa fa-comments me-2"></i>{{ 'Forum'|trans }}</a>
                        </li>
                        {% endif %}
                        {% if settings.side_menu_kb and guest.extension_is_on({ 'mod': 'kb' }) %}
                        <li class="nav-item d-sm-none">
                            <a href="{{ 'kb'|link }}" class="nav-link" title="{{ 'Knowledge base'|trans }}">
                                <i class="fa fa-graduation-cap me-2"></i>{{ 'Knowledge base'|trans }}</a>
                        </li>
                        {% endif %}
                        {% if settings.side_menu_contact %}
                        <li class="nav-item d-sm-none">
                            <a href="{{ '/support/contact-us'|link }}" class="nav-link">
                                <i class="fa fa-envelope me-2"></i>{{ 'Contact us'|trans }}</a>
                        </li>
                        {% endif %}

                        {% if client %}
                            {% set profile = client.client_get %}

                            {% if settings.side_menu_home %}
                            <li class="nav-item d-md-none">
                                <a href="{{ '/'|link }}" class="nav-link" title="{{ 'Dashboard'|trans }}">
                                    <i class="fa fa-home me-2"></i>{{ 'Dashboard'|trans }}</a>
                            </li>
                            {% endif %}
                            {% if settings.side_menu_services %}
                            <li class="nav-item d-sm-none">
                                <a href="{{ 'order/service'|link }}" class="nav-link" title="{{ 'Services'|trans }}">
                                    <i class="fa fa-cog me-2"></i>{{ 'Services'|trans }}</a>
                            </li>
                            {% endif %}
                            {% if settings.side_menu_invoices %}
                            <li class="nav-item d-md-none">
                                <a href="{{ 'invoice'|link }}" class="nav-link" title="{{ 'Invoices'|trans }}">
                                    <i class="fa fa-credit-card me-2"></i>{{ 'Invoices'|trans }}</a>
                            </li>
                            {% endif %}
                            {% if settings.side_menu_support %}
                            <li class="nav-item d-md-none">
                                <a href="{{ 'support'|link }}" class="nav-link" title="{{ 'Tickets'|trans }}">
                                    <i class="fa fa-life-ring me-2"></i>{{ 'Support'|trans }}</a>
                            </li>
                            {% endif %}
                            <li class="nav-item dropdown">
                                <a href="#" class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    <i class="fa fa-user me-2"></i> {{ (profile.first_name ~ " " ~ profile.last_name) }}</a>
                                <ul class="dropdown-menu dropdown-menu-end">
                                    <li class="text-center">
                                        <img src="{{ profile.email|gravatar }}&size=100" class="img-thumbnail rounded-circle" alt="{{ 'Gravatar'|trans }}">
                                    </li>
                                    <li><hr class="dropdown-divider"></li>
                                    {% if settings.show_client_balance %}
                                    <li>
                                        <a href="{{ 'client/balance'|link }}" class="dropdown-item">
                                            <i class="fa fa-wallet me-2"></i>{{ 'Balance'|trans }}: {{ profile.balance | money(profile.currency) }}</a>
                                        </li>
                                    {% endif %}
                                    <li>
                                        <a href="{{ 'client/me'|link }}" class="dropdown-item" title="{{ 'Profile'|trans }}">
                                            <i class="fa fa-user me-2"></i>{{ 'Manage profile'|trans }}</a>
                                    </li>
                                    {% if settings.show_client_emails %}
                                    <li>
                                        <a href="{{ 'email'|link }}" class="dropdown-item" title="{{ 'Emails'|trans }}">
                                            <i class="fa fa-envelope me-2"></i>{{ 'Emails'|trans }}</a>
                                    </li>
                                    {% endif %}
                                    <li>
                                        <a href="{{ 'client/logout'|link }}" class="dropdown-item" title="{{ 'Sign out'|trans }}">
                                            <i class="fa fa-sign-out-alt me-2"></i>{{ 'Sign out'|trans }}</a>
                                    </li>
                                </ul>
                            </li>
                        {% else %}
                            <li class="nav-item">
                                <a href="#" class="nav-link" data-bs-toggle="modal" data-bs-target="#login">{{ 'Login'|trans }}</a>
                            </li>
                            <li class="nav-item">
                                <a href="#" class="nav-link" data-bs-toggle="modal" data-bs-target="#registration">{{ 'Register'|trans }}</a>
                            </li>
                        {% endif %}
                    </ul>
                </div>
            </div>
        </nav>
    </header>

    {% block content_banner %}{% endblock %}
    <main class="container">
        <div class="row">
            <aside class="d-none {% if side_menu != 'hidden' %}d-lg-block{% endif %} col-md-3">
                {% if company.logo_url %}
                    <a href="{{ ''|link }}" class="d-block mb-3">
                        <img src="{{ company.logo_url }}" alt="{{ company.name }}" class="img-fluid">
                    </a>
                {% else %}
                    <a href="{{ ''|link }}" class="d-block mb-3">
                        <img src=" {{ 'images/logo.png'|asset_url }}" alt="{{ company.name }}" class="img-fluid">
                    </a>
                {% endif %}

                {% include '_menu.phtml' %}

                {% set languages = guest.extension_languages %}

                {% if languages|length > 1 %}
                    <select class="form-select mt-3 language_selector" name="lang">
                        {% for lang in languages %}
                            <option value="{{ lang }}">{{ lang|trans }}</option>
                        {% endfor %}
                    </select>
                {% endif %}

                {% block sidebar %}{% endblock %}

                {% if settings.sidebar_note_enabled %}
                    <div class="card mt-3">
                        <h5 class="card-header">{{ settings.sidebar_note_title }}</h5>
                        <p class="card-body mb-0">{{ settings.sidebar_note_content }}</p>
                    </div>
                {% endif %}

                {% block sidebar2 %}{% endblock %}
            </aside>
            <div class="col">
                {% block content_before %}{% endblock %}

                {% include 'partial_message.phtml' %}

                {% block content %}{% endblock %}
                {% block content_after %}{% endblock %}

                {% if not client %}
                    {% include 'Modal/_login.phtml' %}
                    {% include 'Modal/_registration.phtml' %}
                {% endif %}
            </div>
        </div>
    </main>

    {% if settings.show_page_footer %}
        <footer>
            <hr class="my-5">
            <div class="container">
                <div class="row text-center">
                    <div class="col">
                        <p class="text-secondary">
                            {% if settings.footer_signature|default %}
                                {{ settings.footer_signature|raw }}
                            {% else %}
                                {{ company.name }} - © {{ now|date('Y') }} {{ company.signature }}
                            {% endif %}
                        </p>
                        <ul class="list-inline">
                            <div>
                                <li class="list-inline-item">
                                    <a href="{{ '/about-us'|link }}" class="link-dark text-decoration-none">{{ 'About us'|trans }}</a>
                                </li>
                                <li class="list-inline-item">
                                    <a href="{{ '/tos'|link }}" class="link-dark text-decoration-none">{{ 'Terms and Conditions'|trans }}</a>
                                </li>
                                <li class="list-inline-item">
                                    <a href="{{ '/privacy-policy'|link }}" class="link-dark text-decoration-none">{{ 'Privacy Policy'|trans }}</a>
                                </li>
                            </div>
                            {% for i in 1..5 %}
                                {% if settings['footer_link_' ~ loop.index ~ '_enabled'] %}
                                <li>
                                    {% if 'http://' in settings['footer_link_' ~ loop.index ~ '_page'] or  'https://' in settings['footer_link_' ~ loop.index ~ '_page'] %}
                                    <a href="{{ settings['footer_link_' ~ loop.index ~ '_page'] }}">{{ settings['footer_link_' ~ loop.index ~ '_title'] }}</a>
                                    {% else %}
                                    <a href="{{ settings['footer_link_' ~ loop.index ~ '_page'] | link }}">{{ settings['footer_link_' ~ loop.index ~ '_title'] }}</a>
                                    {% endif %}
                                </li>
                                {% endif %}
                            {% endfor %}
                            {% if guest.extension_is_on({ 'mod': 'branding' }) or settings.footer_branding_enabled %}
                                <li>
                                    <a href="https://github.com/boxbilling/boxbilling" class="link-secondary text-decoration-none" title="Billing Software" target="_blank">{{ 'Powered by the BoxBilling Community'|trans }}</a>
                                </li>
                            {% endif %}
                        </ul>
                    </div>
                    {% if settings.footer_to_top_enabled %}
                        <a href="#top" class="position-fixed d-flex justify-content-center btn btn-outline-dark rounded-circle opacity-25" style="width: 50px; height: 50px; bottom: 2.25rem; right: 2.25rem;">
                            <i class="fa fa-2x fa-arrow-up"></i>
                        </a>
                    {% endif %}
                </div>
            </div>
        </footer>
    {% endif %}

    <script src="{{ 'js/jquery.js'|asset_url }}"></script>
    <script src="{{ 'js/bootstrap.min.js' | asset_url }}"></script>
    <script src="{{ 'js/boxbilling.js'|asset_url }}"></script>
    <!-- Bootstrap Markdown Editor -->
    <script src="{{ 'js/bootstrap-markdown.js'|asset_url }}"></script>
    <script src="{{ 'js/to-markdown.js'|asset_url }}"></script>
    <script src="{{ 'js/markdown.js'|asset_url }}"></script>

    {% if settings.inject_javascript|default %}
        <!-- Custom Javascript -->
        <script>
            {{ settings.inject_javascript|raw }}
        </script>
    {% endif %}

    {% block js %}{% endblock %}

    <noscript>NOTE: Many features on BoxBilling require Javascript and cookies. You can enable both via your browser's preference settings.</noscript>
</body>
</html>
