{{define "header"}}
<!-- Navigation Drawer -->
<div id="nav-drawer" class="drawer">
  <div class="drawer-overlay"></div>
  <div class="drawer-content">
    <div class="drawer-header">
      <div class="drawer-title">Menu</div>
      <button class="drawer-close" aria-label="Close menu">
        <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-x"/></svg>
      </button>
    </div>
    <div class="drawer-body">
      <nav class="drawer-nav">
        <a href="/" {{if eq .ActivePage "home"}}class="active"{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-home"/></svg>
          Home
        </a>
        <a href="/catalog" {{if eq .ActivePage "catalog"}}class="active"{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-catalog"/></svg>
          Catalog
        </a>
        <a href="/gallery" {{if eq .ActivePage "gallery"}}class="active"{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-image"/></svg>
          Gallery
        </a>
        <a href="/booking" {{if eq .ActivePage "booking"}}class="active"{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-calendar"/></svg>
          Book
        </a>
        {{if .Authenticated}}
        <a href="/profile" {{if eq .ActivePage "profile"}}class="active"{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-user"/></svg>
          Profile
        </a>
        {{else}}
        <a href="{{.OryLoginURL}}">
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-user"/></svg>
          Login
        </a>
        {{end}}
      </nav>
    </div>
  </div>
</div>

<!-- Header -->
<header class="header-bar">
  <div style="display: flex; align-items: center; gap: 1rem;">
    <button class="menu-btn" onclick="window.navDrawer?.toggle()" aria-label="Toggle menu">
      <div class="menu-icon">
        <span></span>
        <span></span>
        <span></span>
      </div>
    </button>
    <a href="/" class="header-brand" style="position: relative;">
      <img src="/assets/balloon.png" alt="Decor By Hannahs">
      Decor By Hannahs
      <img src="/assets/party-icons/party-hat.png" alt="" style="position: absolute; top: -8px; right: -15px; width: 25px; height: 25px; transform: rotate(20deg);">
    </a>
  </div>
  <div style="display: flex; align-items: center; gap: 1rem;">
    <nav class="header-nav">
      <a href="/" {{if eq .ActivePage "home"}}class="active"{{end}}>Home</a>
      <a href="/catalog" {{if eq .ActivePage "catalog"}}class="active"{{end}}>Catalog</a>
      <a href="/gallery" {{if eq .ActivePage "gallery"}}class="active"{{end}}>Gallery</a>
      <a href="/booking" {{if eq .ActivePage "booking"}}class="active"{{end}}>Book</a>
      {{if .Authenticated}}
      <a href="/profile" {{if eq .ActivePage "profile"}}class="active"{{end}}>Profile</a>
      {{else}}
      <a href="{{.OryLoginURL}}" class="btn btn-primary" style="padding: 0.5rem 1rem; text-decoration: none;">Login</a>
      {{end}}
    </nav>
    <button id="themeToggle" class="btn btn-outline" aria-label="Toggle theme">
      <svg id="sunIcon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
      <svg id="moonIcon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
    </button>
  </div>
</header>
{{end}}

{{define "footer"}}
<footer style="position: relative;">
<img src="/assets/party-icons/penguin-wearing-party-hat.png" alt="" style="position: absolute; bottom: 10px; left: 20px; width: 50px; height: 50px; opacity: 0.6;">
<img src="/assets/party-icons/party-hat-with-horn.png" alt="" style="position: absolute; bottom: 10px; right: 20px; width: 50px; height: 50px; opacity: 0.6; transform: rotate(-20deg);">
<small>© 2025 Decor By Hannahs. All rights reserved.</small>
</footer>
{{end}}

{{define "theme-script"}}
<script>
(function() {
  const themeToggle = document.getElementById('themeToggle');
  const sunIcon = document.getElementById('sunIcon');
  const moonIcon = document.getElementById('moonIcon');
  const html = document.documentElement;

  const savedTheme = localStorage.getItem('theme') || 'light';
  html.setAttribute('data-theme', savedTheme);
  updateIcons(savedTheme);

  function updateIcons(theme) {
    if (theme === 'dark') {
      sunIcon.style.display = 'none';
      moonIcon.style.display = 'block';
    } else {
      sunIcon.style.display = 'block';
      moonIcon.style.display = 'none';
    }
  }

  themeToggle.addEventListener('click', () => {
    const currentTheme = html.getAttribute('data-theme');
    const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
    html.setAttribute('data-theme', newTheme);
    localStorage.setItem('theme', newTheme);
    updateIcons(newTheme);
  });
})();
</script>
{{end}}
