<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{% block title %}{{ config.APP_NAME }}{% endblock %}</title>
  <link rel="icon" href="{{ url_for('static', filename='favicon.svg') }}" type="image/svg+xml">

  <!-- Fonts -->
  <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=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Fraunces:ital,opsz,wght@0,9..144,100..900;1,9..144,100..900&display=swap" rel="stylesheet">

  <!-- Tailwind CSS -->
  <link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">

  {% block head %}{% endblock %}
</head>
<body>
  <!-- Navigation -->
  <nav class="nav-bar">
    <div class="nav-inner">
      <a href="{{ url_for('public.landing') }}" class="nav-logo">{{ config.APP_NAME }}</a>
      <button class="nav-hamburger" aria-label="Toggle menu" onclick="document.querySelector('.nav-links').classList.toggle('open')">
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
          <line x1="3" y1="6" x2="21" y2="6"/>
          <line x1="3" y1="12" x2="21" y2="12"/>
          <line x1="3" y1="18" x2="21" y2="18"/>
        </svg>
      </button>
      <div class="nav-links">
        <a href="{{ url_for('public.features') }}">Features</a>
        <a href="{{ url_for('billing.pricing') }}">Pricing</a>
        {% if user %}
        <a href="{{ url_for('dashboard.index') }}">Dashboard</a>
        {% if session.get('is_admin') %}
        <a href="{{ url_for('admin.index') }}"><span class="nav-badge">Admin</span></a>
        {% endif %}
        <form method="post" action="{{ url_for('auth.logout') }}" class="nav-form">
          <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
          <button type="submit" class="btn-outline btn-sm">Sign Out</button>
        </form>
        {% else %}
        <a href="{{ url_for('auth.login') }}">Sign In</a>
        <a href="{{ url_for('auth.signup') }}" class="nav-auth-btn">Get Started</a>
        {% endif %}
      </div>
    </div>
  </nav>

  <!-- Flash messages -->
  {% with messages = get_flashed_messages(with_categories=true) %}
  {% if messages %}
  <div class="container-page mt-4">
    {% for category, message in messages %}
    <div class="{% if category == 'error' %}flash-error{% elif category == 'success' %}flash-success{% elif category == 'warning' %}flash-warning{% else %}flash{% endif %}">
      {{ message }}
    </div>
    {% endfor %}
  </div>
  {% endif %}
  {% endwith %}

  {% block content %}{% endblock %}

  <!-- Footer -->
  <footer class="bg-latte mt-20">
    <div class="container-page py-12">
      <div class="grid-3">
        <div>
          <strong class="heading-display text-lg">{{ config.APP_NAME }}</strong>
          <p class="text-sm text-stone mt-2 max-w-xs">Coffee commodity data for traders who refuse to overpay for market intelligence.</p>
        </div>
        <div>
          <strong class="text-espresso text-sm">Product</strong>
          <ul class="list-none p-0 mt-2 space-y-1.5 text-sm">
            <li><a href="{{ url_for('public.features') }}">Features</a></li>
            <li><a href="{{ url_for('billing.pricing') }}">Pricing</a></li>
            <li><a href="{{ url_for('public.about') }}">About</a></li>
            <li><a href="{{ url_for('public.methodology') }}">Methodology</a></li>
          </ul>
        </div>
        <div>
          <strong class="text-espresso text-sm">Legal</strong>
          <ul class="list-none p-0 mt-2 space-y-1.5 text-sm">
            <li><a href="{{ url_for('public.terms') }}">Terms</a></li>
            <li><a href="{{ url_for('public.privacy') }}">Privacy</a></li>
          </ul>
        </div>
      </div>
      <div class="border-t border-parchment mt-8 pt-6 text-center text-xs text-stone">
        &copy; {{ now.year }} {{ config.APP_NAME }}. All rights reserved.
      </div>
    </div>
  </footer>

  <!-- HTMX -->
  <script src="https://unpkg.com/htmx.org@2.0.4"></script>

  {% include "_feedback_widget.html" %}

  {% block scripts %}{% endblock %}
</body>
</html>
