<template>
  <header>
    <div class="header-title">
      <h1>Evangelische Miriamgemeinde Frankfurt am Main</h1>
      <button class="reload-icon" type="button" @click="reloadMenu" aria-label="Menü neu laden">
        &#x27F3;
      </button>
    </div>
    <NavbarComponent />
    <BreadcrumbsComponent />
  </header>
</template>

<script>
import NavbarComponent from './NavbarComponent.vue';
import BreadcrumbsComponent from './BreadcrumbsComponent.vue';
import { mapActions } from 'vuex';

export default {
  name: 'HeaderComponent',
  components: {
    NavbarComponent,
    BreadcrumbsComponent,
  },
  methods: {
    ...mapActions(['loadMenuData']),
    async reloadMenu() {
      await this.loadMenuData();
      // Für den Test-Reload den aktuellen Pfad behalten und sauber neu initialisieren.
      window.location.reload();
    }
  }
};
</script>

<style scoped>
header {
  display: flex;
  flex-direction: column;
  width: 100%;
  background-color: var(--color-bg-page);
}

.header-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-2) var(--space-3);
}

header h1 {
  margin: 0;
  flex: 1;
  text-align: center;
  text-shadow: 1px 1px 0 var(--color-brand-tint);
  padding-bottom: var(--space-1);
}

.reload-icon {
  font-size: 0.82rem;
  cursor: pointer;
  margin-left: var(--space-3);
  background-color: transparent;
  color: var(--color-text-muted);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  line-height: 1;
  opacity: 0.65;
}

.reload-icon:hover,
.reload-icon:focus-visible {
  color: var(--color-brand-primary-hover);
  border-color: rgba(122, 0, 209, 0.45);
  opacity: 1;
}
</style>
