{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>{% block title %}{{ page_title|default:project_name }}{% endblock %}</title>
  <meta name="description" content="{% block meta_description %}{{ meta_description|default:project_description|default:'Secure business event calendar with a polished public schedule and private admin tools.' }}{% endblock %}">
  {% if noindex %}
  <meta name="robots" content="noindex, nofollow">
  {% endif %}
  {% if project_image_url %}
  <meta property="og:image" content="{{ project_image_url }}">
  <meta property="twitter:image" content="{{ project_image_url }}">
  {% endif %}
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Manrope:wght@500;700;800&display=swap" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
  <link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
  {% block head %}{% endblock %}
</head>
<body class="{% if embedded %}embedded-shell{% else %}app-shell{% endif %}">
  {% if not embedded %}
  <div class="page-glow page-glow-one"></div>
  <div class="page-glow page-glow-two"></div>
  <header class="site-header">
    <div class="container">
      <nav class="navbar navbar-expand-lg py-3">
        <a class="navbar-brand brand-mark d-flex align-items-center gap-3" href="{% url 'home' %}">
          <img src="{% static 'images/just-roasted-coffee-logo.png' %}" alt="Just Roasted Coffee logo" class="brand-logo" width="166" height="52">
          <span class="brand-label">Calendar</span>
        </a>
        <button class="navbar-toggler calendar-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="{% url 'calendar_page' %}">Calendar</a></li>
            <li class="nav-item"><a class="nav-link" href="{% url 'event_list' %}">Events</a></li>
            <li class="nav-item"><a class="nav-link" href="{% url 'calendar_embed' %}">Embed Widget</a></li>
            <li class="nav-item"><a class="nav-link" href="/admin/">Admin</a></li>
            {% if request.user.is_authenticated %}
            <li class="nav-item"><a class="btn btn-ghost ms-lg-2" href="{% url 'event_dashboard' %}">Dashboard</a></li>
            <li class="nav-item"><a class="btn btn-primary-brand ms-lg-2" href="{% url 'logout' %}">Log out</a></li>
            {% else %}
            <li class="nav-item"><a class="btn btn-primary-brand ms-lg-2" href="{% url 'login' %}">Staff login</a></li>
            {% endif %}
          </ul>
        </div>
      </nav>
    </div>
  </header>
  {% endif %}

  {% if messages and not embedded %}
  <div class="container">
    <div class="message-stack">
      {% for message in messages %}
      <div class="alert alert-success shadow-sm border-0" role="alert">{{ message }}</div>
      {% endfor %}
    </div>
  </div>
  {% endif %}

  {% block content %}{% endblock %}

  {% if not embedded %}
  <footer class="site-footer">
    <div class="container d-flex flex-column flex-lg-row justify-content-between gap-3 align-items-lg-center">
      <div>
        <p class="footer-title mb-1">Secure schedule publishing for your website.</p>
        <p class="footer-copy mb-0">Publish dates publicly, manage them privately, and keep your audience informed.</p>
      </div>
      <div class="footer-links d-flex gap-3 flex-wrap">
        <a href="{% url 'calendar_page' %}">View calendar</a>
        <a href="{% url 'calendar_embed' %}">Embed widget</a>
        <a href="/admin/">Admin</a>
      </div>
    </div>
  </footer>
  {% endif %}

  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
  <script src="{% static 'js/calendar.js' %}?v={{ deployment_timestamp }}" defer></script>
  {% block scripts %}{% endblock %}
</body>
</html>
