<script setup lang="ts">
import { RouterView } from "vue-router";
import { useMainStore } from "@/stores/main";
import { onMounted } from "vue";
import LoadingView from "@/components/Loading.vue";
import { storeToRefs } from "pinia";
import NotificationsManager from "@/components/NotificationsManager.vue";
//store
const mainStore = useMainStore();
const mainStoreRef = storeToRefs(mainStore);
//variable
const loggedIn = mainStoreRef.readIsLoggedIn;
//getter

//lifecycle
onMounted(() => {
  let path = location.pathname;
  if (path !== "/qrcode" && path !== "/yt-views" && path !== "/orders") {
    mainStore.checkLoggedIn();
  }
});
</script>

<template>
  <v-app>
    <LoadingView v-if="loggedIn === null" />
    <RouterView v-else />
    <NotificationsManager />
  </v-app>
</template>

<style lang="scss">
:root {
  --main-color: #ea5413;
}

a {
  transition: 0.3s;
  color: var(--main-color);
  text-decoration: none;
  &:hover {
    opacity: 0.7;
  }
}

.v-input__details {
  padding: 3px 16px;
}

.login-form {
  margin: auto;
  max-width: 500px;
  position: relative;

  .v-input__details {
    .v-messages {
      color: #b00020 !important;
      text-align: end;
    }
  }

  .login-btn,
  .google-btn {
    width: 280px;
    display: flex;
    margin: 50px auto 0;
    padding: 25px 40px;
    font-size: 16px;
  }

  .v-alert {
    position: absolute;
    width: 100%;
    bottom: -110px;
    margin-bottom: 10px;
    padding: 10px !important;
    .v-alert__content {
      text-align: start;
    }
    .v-icon--size-default {
      padding: 0;
    }
  }

  .v-input__append {
    position: relative;
    margin-inline-start: 0 !important;
    .material-icons {
      position: absolute !important;
      right: 10px;
    }
  }
}

.banner-item {
  position: relative;
  img {
    width: 100%;
    height: 100vh;
    object-fit: cover;
    margin-bottom: -7px;
    animation: scale 3s ease-in-out;
    filter: brightness(60%); // 圖片遮罩
    @media (max-width: 959px) {
      height: 40vh;
    }
  }
  h2 {
    width: 100%;
    padding: 0 10px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 30px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 1px;
    @media (max-width: 959px) {
      top: 55%;
    }
    @media (max-width: 575px) {
      top: 60%;
      font-size: 22px;
    }
  }
}

@keyframes scale {
  0% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
  }
}

.form-title {
  display: flex;
  flex-direction: column;
  align-items: center;

  h3 {
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 3px;
    @media (max-width: 575px) {
      font-size: 28px;
    }
  }

  span {
    width: 60px;
    height: 3px;
    margin: 20px auto 35px;
    display: block;
    background: var(--main-color);
  }
}
</style>
