<script lang="ts">
  import { onMount } from 'svelte';
  import { profileStore } from '$lib/client/profile.svelte';
  import ProfileSwitcher from '$lib/components/ProfileSwitcher.svelte';

  let { children } = $props();

  onMount(() => {
    profileStore.load();
  });
</script>

<header class="bar">
  <a href="/" class="brand">Kochwas</a>
  <div class="bar-right">
    <a href="/admin" class="admin-link" aria-label="Einstellungen">⚙️</a>
    <ProfileSwitcher />
  </div>
</header>

<main>
  {@render children()}
</main>

<style>
  :global(html, body) {
    margin: 0;
    padding: 0;
    background: #f8faf8;
    color: #1a1a1a;
    font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  :global(a) {
    color: #2b6a3d;
  }
  :global(*) {
    box-sizing: border-box;
  }
  .bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #e4eae7;
  }
  .brand {
    font-size: 1.15rem;
    font-weight: 700;
    text-decoration: none;
    color: #2b6a3d;
  }
  .bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 1.15rem;
  }
  .admin-link:hover {
    background: #f4f8f5;
  }
  main {
    padding: 0 1rem 4rem;
    max-width: 760px;
    margin: 0 auto;
  }
</style>
