<template>
  <footer class="footer">
    <div class="left-links">
      <router-link v-if="!isLoggedIn" class="login-link" to="/auth/login">Login</router-link>
      <a v-if="isLoggedIn" @click="handleLogout" class="logout-link">Logout</a>
    </div>
    <div class="right-links">
      <router-link to="/terms">Impressum</router-link>
      <router-link to="/privacy-policy">Datenschutzerklärung</router-link>
    </div>
  </footer>
</template>

<script>
import { mapGetters, mapActions } from 'vuex';

export default {
  name: 'FooterComponent',
  computed: {
    ...mapGetters(['isLoggedIn'])
  },
  methods: {
    ...mapActions(['logout']),
    async handleLogout() {
      try {
        await this.logout();
      } catch (error) {
        console.error('Fehler beim Logout:', error);
      }
    }
  }
};
</script>

<style scoped>
.footer {
  background-color: var(--color-footer-bg);
  bottom: 0;
  left: 0;
  width: 100%;
  position: relative;
  z-index: 2;
  padding: var(--space-2) var(--space-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.left-links {
  display: flex;
  align-items: center;
}

.right-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.footer a {
  color: var(--color-footer-link);
  padding-right: var(--space-5);
  text-decoration: none;
  text-underline-offset: 2px;
}

.footer a:hover,
.footer a:focus-visible {
  color: var(--color-footer-link-hover);
  text-decoration: underline;
}

.footer a.logout-link {
  cursor: pointer;
}
</style>
