<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="color-scheme" content="light dark">
        <link rel="stylesheet" href="{{pico_css_path}}">
        <link rel="stylesheet" href="/static/default/pico-style.css">
        <link rel="stylesheet" href="/static/default/style.css">
        {% for css_path in css_path_list -%}
        <link rel="stylesheet" href="{{css_path}}">
        {% endfor %}
        <link rel="icon" href="{{favicon_path}}" sizes="32x32" type="image/png">
        <title>{{title}}</title>
    </head>
    <body>
        <button class="hamburger-menu" aria-label="Menu">☰</button>
        <div class="layout-container">
            <aside>
                <nav>
                    <ul>
                        {% for navigation in navigations %}
                            {% if navigation|attr("pages") %}
                            <li>
                                <details {% if navigation.active %}open{% endif %}>
                                    <summary>{{navigation.caption}}</summary>
                                    <ul>
                                        {% for page in navigation.pages %}
                                        <li><a href="{{page.url}}" class="{{ 'active-link' if page.active else '' }}">{{page.caption}}</a></li>
                                        {% endfor %}
                                    </ul>
                                </details>
                            </li>
                            {% else %}
                                <li><a href="{{navigation.url}}" class="{{ 'active-link' if navigation.active else '' }}">{{navigation.caption}}</a></li>
                            {% endif %}
                        {% endfor %}
                    </ul>
                </nav>
                <div class="theme-switcher">
                    <label for="theme-select">Theme:</label>
                    <select id="theme-select">
                        <option value="auto">🌗 Auto</option>
                        <option value="light">☀️ Light</option>
                        <option value="dark">🌙 Dark</option>
                    </select>
                </div>
            </aside>
            <div class="content-wrapper">
                <main class="content">
                    <header>
                        <hgroup>
                            <h1>{{title}}</h1>
                            <p>{{subtitle}}</p>
                        </hgroup>
                        {% if show_user_info %}
                        <nav>
                            <ul></ul>
                            <ul>
                                <li>
                                    {% if current_user is none %}
                                        <p>Hi Visitor <a href="/login">🔓</a></p>
                                    {% elif current_user.is_guest %}
                                        <p>Hi {{current_user.username}} <a href="/login">🔓</a></p>
                                    {% else %}
                                        <p>Hi {{current_user.username}} <a href="/logout">🔒</a></p>
                                    {% endif %}
                                </li>
                            </ul>
                        </nav>
                        {% endif %}
                    </header>
                    <script src="/static/common/util.js"></script>
                    {{content}}
                    <footer>{{footer}}</footer>
                </main>
            </div>
        </div>
        {% for js_path in js_path_list -%}
        <script src="{{js_path}}"></script>
        {% endfor %}
        <script src="/static/default/script.js"></script>
        <script>
            {% if should_refresh_session %}
            UTIL.refreshAccessTokenPeriodically({{refresh_session_interval_seconds}});
            {% endif %}
        </script>
    </body>
</html>