<template>
  <div class="default-layout">
    <header class="default-header">
      <NuxtLink to="/projects">
        <img
          src="/logo.svg"
          alt="logo"
          draggable="false"
        >
      </NuxtLink>

      <LangSwitcher />
    </header>

    <main class="default-main">
      <slot />
    </main>

    <footer class="default-footer">
      <div class="default-footer__left">
        <UiButton
          type="link"
          color="secondary"
          href="#"
        >
          {{ $t('privacy_policy') }}
        </UiButton>
      </div>

      <div class="default-footer__middle">
        <span class="default-footer__copyright">
          {{ $t('copyright', { year }) }}
        </span>
      </div>

      <div class="default-footer__right">
        <UiButton
          icon="circle-question"
          type="link"
          color="secondary"
          href="#"
        >
          {{ $t('support') }}
        </UiButton>
      </div>
    </footer>
  </div>
</template>

<script setup lang="ts">
const route = useRoute()
const { t } = useI18n({ useScope: 'global' })
const year = computed(() => new Date().getFullYear())

const headerAction = computed(() => {
  switch (route.name) {
    case 'login':
      return {
        name: t('register'),
        link: '/register',
      }
    case 'register':
      return {
        name: t('login'),
        link: '/login',
      }
    default:
      return undefined
  }
})
</script>

<style lang="scss">
.default-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.default-header {
  display: flex;
  padding: 32px 56px 0 56px;
  justify-content: space-between;
  align-items: center;
}

.default-main {
  flex: 1;
  display: flex;
  align-items: center;
  padding-block: 30px;
}

.default-footer {
  padding: 24px 56px 32px;

  display: flex;
  justify-content: space-between;
  align-items: center;

  > * {
    flex: 1;
  }

  &__left {
    text-align: start;
  }

  &__middle {
    text-align: center;
  }

  &__right {
    text-align: end;
  }

  &__copyright {
    color: $clr-grey-400;
  }
}
</style>
