{% load static %}
{% load solo_tags %}
{% load show_menu %}
{% get_solo 'portal.SiteConfiguration' as site_conf %}

<!doctype html>
<html lang="en" data-bs-theme="auto">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="color-scheme" content="light dark">
    <meta name="description" content="{{ site_conf.about}}">
    <meta name="author" content="{{ site_conf.site_author }}">
    <meta name="generator" content="Django Framework">
    <title>{% block title %}{{ title }}{% endblock %} - {{ site_conf.site_name }}</title>
    <link rel="icon" href="{% static "favicon.png" %}" sizes="any">
    <link rel="icon" href="{% static "favicon.svg" %}" type="image/svg+xml">
    {% if site_conf.use_cdn %}
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" rel="stylesheet">
    {% else %}
    <link href="{% static "bootstrap@5.3.2/dist/css/bootstrap.min.css" %}" rel="stylesheet">
    <link href="{% static "bootstrap-icons@1.11.1/font/bootstrap-icons.css" %}" rel="stylesheet">
    {% endif %}
    <link href="{% static "css/main.css" %}?v={{ site_conf.version }}" rel="stylesheet">
    <style>
      .bd-placeholder-img {
        font-size: 1.125rem;
        text-anchor: middle;
        -webkit-user-select: none;
        -moz-user-select: none;
        user-select: none;
      }
      @media (min-width: 768px) {
        .bd-placeholder-img-lg {
          font-size: 3.5rem;
        }
      }
    </style>
    <script>
      /*!
      * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
      * Copyright 2011-2023 The Bootstrap Authors
      * Licensed under the Creative Commons Attribution 3.0 Unported License.
      */

      (() => {
        'use strict'

        const getStoredTheme = () => localStorage.getItem('theme')
        const setStoredTheme = theme => localStorage.setItem('theme', theme)

        const getPreferredTheme = () => {
          const storedTheme = getStoredTheme()
          if (storedTheme) {
            return storedTheme
          }

          return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
        }

        const setTheme = theme => {
          if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
            document.documentElement.setAttribute('data-bs-theme', 'dark')
          } else {
            document.documentElement.setAttribute('data-bs-theme', theme)
          }
        }

        setTheme(getPreferredTheme())

        const showActiveTheme = (theme, focus = false) => {
          const themeSwitcher = document.querySelector('#bd-theme')

          if (!themeSwitcher) {
            return
          }

          const activeThemeIcon = document.querySelector('.theme-icon-active i')
          const btnToActive = document.querySelector(`[data-bs-theme-value="${theme}"]`)
          const biOfActiveBtn = btnToActive.querySelector('.theme-icon i').getAttribute('class')

          document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
            element.classList.remove('active')
            element.setAttribute('aria-pressed', 'false')
          })

          btnToActive.classList.add('active')
          btnToActive.setAttribute('aria-pressed', 'true')
          activeThemeIcon.setAttribute('class', biOfActiveBtn)

          if (focus) {
            themeSwitcher.focus()
          }
        }

        window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
          const storedTheme = getStoredTheme()
          if (storedTheme !== 'light' && storedTheme !== 'dark') {
            setTheme(getPreferredTheme())
          }
        })

        window.addEventListener('DOMContentLoaded', () => {
          showActiveTheme(getPreferredTheme())
          document.querySelectorAll('[data-bs-theme-value]')
            .forEach(toggle => {
              toggle.addEventListener('click', () => {
                const theme = toggle.getAttribute('data-bs-theme-value')
                setStoredTheme(theme)
                setTheme(theme)
                showActiveTheme(theme, true)
              })
            })
          })
       })()
    </script>
    <script>
      document.addEventListener('DOMContentLoaded', function () {
      var selectElement = document.getElementById('tabSelector');
      selectElement.addEventListener('change', function () {
        var selectedTabId = this.value;
        var tabs = document.querySelectorAll('.tab-pane');
        tabs.forEach(function (tab) {
        tab.classList.remove('show', 'active');
        });
        document.getElementById(selectedTabId).classList.add('show', 'active');
      });
      });
    </script>
    {% block extra_head %}
    {{ site_conf.extra_head | safe }}
    {% endblock %}
  </head>
  <body>
    <header>
      <nav class="navbar navbar-expand-sm bg-body-tertiary shadow-sm">
        <div class="container d-flex">
          <div class="me-auto">
            <a href="{% url 'index' %}" class="navbar-brand d-flex align-items-center">
              <svg class="me-2" width="26" height="16" viewBox="0 0 26 16" xmlns="http://www.w3.org/2000/svg">
                <path d="m2.8125 0.0010991a1.0001 1.0001 0 0 0-0.8125 1c0 0.55455-0.44545 1-1 1a1.0001 1.0001 0 0 0-1 1v10a1.0001 1.0001 0 0 0 1 1c0.55455 0 1 0.44546 1 1a1.0001 1.0001 0 0 0 1 1h20a1.0001 1.0001 0 0 0 1-1c0-0.55454 0.44546-1 1-1a1.0001 1.0001 0 0 0 1-1v-10a1.0001 1.0001 0 0 0-1-1c-0.55454 0-1-0.44545-1-1a1.0001 1.0001 0 0 0-1-1h-20a1.0001 1.0001 0 0 0-0.09375 0 1.0001 1.0001 0 0 0-0.09375 0zm0.78125 2h14.406v1h2v-1h2.4062c0.30628 0.76906 0.82469 1.2875 1.5938 1.5938v8.8125c-0.76906 0.30628-1.2875 0.82469-1.5938 1.5938h-2.4062v-1h-2v1h-14.406c-0.30628-0.76906-0.82469-1.2875-1.5938-1.5938v-8.8125c0.76906-0.30628 1.2875-0.82469 1.5938-1.5938zm14.406 2v2h2v-2zm0 3v2h2v-2zm0 3v2h2v-2z" stroke-width="2" />
                <style>
                  path {
                    text-indent:0;
                    text-transform:none;
                  }
                </style>
              </svg>
              <strong>{{ site_conf.site_name }}</strong>
            </a>
         </div>
         {% include 'includes/login.html' %}
        </div>
      </nav>
    </header>
    <main>
      <div class="container py-2">
        <nav class="navbar navbar-expand-lg">
          <div class="container-fluid g-0">
            <a class="navbar-brand" href="{% url 'index' %}">Home</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarSupportedContent">
              <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                  <a class="nav-link" href="{% url 'roster' %}">Roster</a>
                </li>
                <li class="nav-item">
                  <a class="nav-link" href="{% url 'consists' %}">Consists</a>
                </li>
                <li class="nav-item dropdown">
                  <a class="nav-link dropdown-toggle" href="#" id="filterDropdownMenu" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                    Search by
                  </a>
                  <ul class="dropdown-menu" aria-labelledby="filterDropdownMenu">
                    <li class="ps-2 text-secondary">Model</li>
                    <li><a class="dropdown-item" href="{% url 'scales' %}">Scale</a></li>
                    <li><a class="dropdown-item" href="{% url 'manufacturers' category='model' %}">Manufacturer</a></li>
                    <li><hr class="dropdown-divider"></li>
                    <li class="ps-2 text-secondary">Prototype</li>
                    <li><a class="dropdown-item" href="{% url 'types' %}">Type</a></li>
                    <li><a class="dropdown-item" href="{% url 'companies' %}">Company</a></li>
                    <li><a class="dropdown-item" href="{% url 'manufacturers' category='real' %}">Manufacturer</a></li>
                  </ul>
                </li>
                {% show_bookshelf_menu %}
                {% show_flatpages_menu %}
              </ul>
              {% include 'includes/search.html' %}
            </div>
          </div>
        </nav>
      </div>
      <section class="py-4 text-center container">
        <div class="row">
          <div class="mx-auto">
            <h1 class="fw-light">{{ title }}</h1>
            {% block header %}
            {% endblock %}
          </div>
        </div>
      </section>
      <div class="album py-4 bg-body-tertiary">
        <div class="container">
          {% block carousel %}
          {% endblock %}
          <a id="main-content"></a>
          {% block cards_layout %}
          {% endblock %}
        </div>
        <div class="container">{% block pagination %}{% endblock %}</div>
      </div>
      {% block extra_content %}{% endblock %}
    </main>
    {% include 'includes/footer.html' %}
    {% if site_conf.use_cdn %}
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    {% else %}
    <script src="{% static "bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" %}"></script>
    {% endif %}
  </body>
</html>
