{{define "layout.tmpl"}}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{block "title" .}}Decor By Hannahs{{end}}</title>
<link rel="stylesheet" href="/static/css/styles.css">
<script src="/static/js/alpine.js" defer></script>
<script src="/static/htmx/htmx.min.js" defer></script>
<script src="/static/js/drawer.js" defer></script>
<link rel="icon" href="/assets/balloon.png" type="image/png">
</head>

<body>
<!-- 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="/" {{block "nav-home-active" .}}{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-home"/></svg>
          Home
        </a>
        <a href="/catalog" {{block "nav-catalog-active" .}}{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-catalog"/></svg>
          Catalog
        </a>
        <a href="/gallery" {{block "nav-gallery-active" .}}{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-image"/></svg>
          Gallery
        </a>
        <a href="/booking" {{block "nav-booking-active" .}}{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-calendar"/></svg>
          Book
        </a>
        <a href="/profile" {{block "nav-profile-active" .}}{{end}}>
          <svg class="drawer-nav-icon"><use href="/static/icons.svg#icon-user"/></svg>
          Profile
        </a>
      </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">
      <img src="/assets/balloon.png" alt="Decor By Hannahs">
      Decor By Hannahs
    </a>
  </div>
  <div style="display: flex; align-items: center; gap: 1rem;">
    <nav class="header-nav">
      <a href="/" {{block "header-home-active" .}}{{end}}>Home</a>
      <a href="/catalog" {{block "header-catalog-active" .}}{{end}}>Catalog</a>
      <a href="/gallery" {{block "header-gallery-active" .}}{{end}}>Gallery</a>
      <a href="/booking" {{block "header-booking-active" .}}{{end}}>Book</a>
      <a href="/profile" {{block "header-profile-active" .}}{{end}}>Profile</a>
    </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>

<main>
{{block "content" .}}{{end}}
</main>

<footer>
<small>© 2025 Decor By Hannahs. All rights reserved.</small>
</footer>

<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>
{{block "scripts" .}}{{end}}
</body>
</html>
{{end}}
