<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}PsalmbordOnline{% endblock %}</title>
    <link rel="icon" type="image/png" href="{{ url_for('static', filename='favicon.ico') }}">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Lora&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400..700;1,400..700&family=Quicksand:wght@300..700&display=swap" rel="stylesheet">
    <!-- Tailwind CSS CDN -->
    <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
    <style>
        h1, h2, h3, h4, h5, h6 {
            font-family: 'Lora', serif;
            font-weight: 600;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }

body {
  font-family: 'Quicksand';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Floating scrollbar style for WebKit browsers */
  overflow-y: scroll;
}

/* Webkit Floating Scrollbar */
body::-webkit-scrollbar {
  width: 8px;
  background: transparent;
  position: fixed;
}

body::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.3);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* Firefox Floating scrollbar */
@-moz-document url-prefix() {
  html {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
  }
}
    </style>
</head>
<body class="bg-white text-gray-900 font-sans min-h-screen flex flex-col">
  <nav class="bg-white border-b border-gray-200 shadow-sm">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
      <div class="flex items-center justify-between h-20">
        <!-- Logo -->
        <div class="flex-shrink-0 flex items-center w-24">
          {% if current_user.is_authenticated and current_user.church and current_user.church.logo_filename %}
          <a href="{{ url_for('index') }}"><img src="{{ url_for('uploaded_file', filename=current_user.church.logo_filename) }}" alt="Logo" class="h-10 w-auto object-contain"></a>
          {% else %}
          <a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='default_logo.png') }}" alt="Default Logo" class="h-10 w-auto object-contain"></a>
          {% endif %}
        </div>
        <!-- Desktop Nav -->
        <div class="hidden sm:flex flex-1 justify-center">
          <div id="nav-links" class="flex flex-row gap-2 items-center">
            {% if current_user.is_authenticated %}
      <a href="/portal" class="text-black px-6 py-3 rounded font-semibold hover:bg-[#f7d91a] hover:text-black transition">Mijn schermen</a>
      <a href="{{ url_for('global_schedules') }}" class="text-black px-6 py-3 rounded font-semibold hover:bg-[#f7d91a] hover:text-black transition">Geplande diensten</a>
      <a href="{{ url_for('church_settings') }}" class="text-black px-6 py-3 rounded font-semibold hover:bg-[#f7d91a] hover:text-black transition">Instellingen</a>
      {% if current_user.is_admin %}
      <a href="{{ url_for('admin_dashboard') }}" class="text-black px-6 py-3 rounded font-semibold hover:bg-[#f7d91a] hover:text-black transition">Admin</a>
      {% endif %}
      <a href="/logout" class="text-black px-6 py-3 rounded font-semibold hover:bg-[#f7d91a] hover:text-black transition">Uitloggen</a>
      {% else %}
      <a href="/login" class="text-black px-6 py-3 rounded font-semibold hover:bg-[#f7d91a] hover:text-black transition">Inloggen</a>
      <a href="/register" class="text-black px-6 py-3 rounded font-semibold hover:bg-[#f7d91a] hover:text-black transition">Registreren</a>
            {% endif %}
          </div>
        </div>
        <!-- Current Time -->
        <div id="current-time" class="text-gray-700 font-semibold text-right text-sm w-24" title="Huidige datum en tijd">
          <div id="current-date"></div>
          <div id="current-clock" class="mt-0"></div>
        </div>
        <!-- Mobile hamburger -->
        <div class="flex sm:hidden">
          <button id="menu-button" class="p-2 rounded-md focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-600" aria-label="Open menu">
            <svg class="h-7 w-7 text-gray-700" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
            </svg>
          </button>
        </div>
      </div>
      <!-- Mobile nav menu -->
      <div id="nav-mobile" class="sm:hidden hidden">
        <div class="flex flex-col gap-2 py-3 items-center border-t border-gray-100">
          {% if current_user.is_authenticated %}
          <a href="/portal" class="bg-[#f7d91a] text-black px-6 py-3 rounded font-semibold hover:bg-yellow-300 transition w-full text-center">Mijn schermen</a>
          <a href="{{ url_for('global_schedules') }}" class="bg-[#f7d91a] text-black px-6 py-3 rounded font-semibold hover:bg-yellow-300 transition w-full text-center">Geplande diensten</a>
          <a href="{{ url_for('church_settings') }}" class="bg-[#f7d91a] text-black px-6 py-3 rounded font-semibold hover:bg-yellow-300 transition w-full text-center">Kerk instellingen</a>
          {% if current_user.is_admin %}
          <a href="{{ url_for('admin_dashboard') }}" class="bg-[#f7d91a] text-black px-6 py-3 rounded font-semibold hover:bg-yellow-300 transition w-full text-center">Admin instellingen</a>
          {% endif %}
          <a href="/logout" class="bg-[#f7d91a] text-black px-6 py-3 rounded font-semibold hover:bg-yellow-300 transition w-full text-center">Logout</a>
          {% else %}
          <a href="/login" class="bg-[#f7d91a] text-black px-6 py-3 rounded font-semibold hover:bg-yellow-300 transition w-full text-center">Login</a>
          <a href="/register" class="bg-[#f7d91a] text-black px-6 py-3 rounded font-semibold hover:bg-yellow-300 transition w-full text-center">Register</a>
          {% endif %}
        </div>
      </div>
    </div>
  </nav>
  <script>
    const menuButton = document.getElementById('menu-button');
    const navMobile = document.getElementById('nav-mobile');

    menuButton.addEventListener('click', () => {
      navMobile.classList.toggle('hidden');
    });

    function updateTime() {
      const now = new Date();
      const dateOptions = { year: 'numeric', month: 'short', day: 'numeric' };
      const timeOptions = { hour: '2-digit', minute: '2-digit', second: '2-digit' };
      const dateStr = now.toLocaleDateString('nl-NL', dateOptions);
      const timeStr = now.toLocaleTimeString('nl-NL', timeOptions);
      document.getElementById('current-date').textContent = dateStr;
      document.getElementById('current-clock').textContent = timeStr;
    }

    setInterval(updateTime, 1000);
    updateTime();
  </script>
  <main class="flex-grow max-w-7xl mx-auto w-full px-6 py-8 sm:py-12">
    {% with messages = get_flashed_messages() %}
      {% if messages %}
        <div class="bg-blue-100 border border-blue-400 text-blue-700 px-6 py-4 rounded mb-6">
          {% for message in messages %}
            <div>{{ message }}</div>
          {% endfor %}
        </div>
      {% endif %}
    {% endwith %}
    {% block content %}{% endblock %}
  </main>
  <footer class="bg-gray-100 text-gray-600 text-center py-4 text-sm">
    &copy; {{ current_year }} PsalmbordOnline &nbsp;|&nbsp; Contact: <a href="mailto:info@psalmbord.online" class="text-blue-600 hover:underline">info@psalmbord.online</a>
  </footer>
</body>
</html>