<script setup>
import { useLayout } from "../../composables/layout/layout.js";
import { useRoute } from "vue-router";
import { computed } from "vue";
import notFoundLight from "../../assets/images/landing/404.png";
import notFoundDark from "../../assets/images/landing/404-dark.png";

const { isDarkTheme } = useLayout();
const route = useRoute();

const heroSrc = computed(() =>
  isDarkTheme.value ? notFoundDark : notFoundLight,
);

const errorMessage = computed(() => {
  if (route.query.message) {
    return decodeURIComponent(route.query.message);
  }
  // Default message for 404 errors
  return "The page you're looking for doesn't exist or has been moved.";
});
</script>

<template>
  <section
    class="animate-fadein animate-duration-300 animate-ease-in landing-container mx-auto min-h-[75vh] lg:min-h-screen flex flex-col items-center justify-center"
  >
    <img
      class="w-64 lg:w-96"
      :src="heroSrc"
      alt="Page Not Found"
    />
    <h1 class="title-h5 lg:title-h1 mt-8">Page Not Found</h1>
    <p class="body-small lg:body-large mt-2 lg:mt-4 text-center max-w-md">
      {{ errorMessage }}
    </p>
    <router-link
      to="/dashboard"
      class="body-button bg-red-600 w-fit mt-8 hover:bg-red-500 px-4"
      >Go to Dashboard</router-link
    >
  </section>
</template>
