<template>
  <div>
    <button
      v-if="button?.hasTitle && button?.hasLink"
      class="pretty-button"
      type="button"
      @click="button.performAction"
    >
      <div class="button-content">
        <img :src="arrowIcon" alt="Arrow Icon" width="22" height="22" />
        <div style="margin-left: 4px">
          {{ button.title }}
        </div>
      </div>
    </button>
  </div>
</template>

<script setup lang="ts">
import {
  useButtonElementContent,
} from '@lightspeed/crane';
import { Content } from '../../type.ts';
import arrowIcon from '../../assets/arrow.svg';

const button = useButtonElementContent<Content>('button');
</script>

<style lang="scss" scoped>
.button-content {
  display: flex;
  justify-content: center;
  align-items: center;
}
.pretty-button {
  background-color: #FFFFFF;
  border: 1px solid #222222;
  border-radius: 8px;
  box-sizing: border-box;
  color: #222222;
  cursor: pointer;
  display: inline-block;
  font-family: Circular, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  margin: 0;
  outline: none;
  padding: 12px 20px;
  position: relative;
  text-align: center;
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.1s ease;
  user-select: none;
  -webkit-user-select: none;
  width: auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

  &:hover {
    background-color: #F7F7F7;
    border-color: #222222;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
  }

  &:active {
    background-color: #F7F7F7;
    border-color: #000000;
    transform: scale(0.96);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  &:focus-visible {
    box-shadow: #222222 0 0 0 2px, rgba(255, 255, 255, 0.8) 0 0 0 4px;
    transition: box-shadow 0.2s;
  }

  &:disabled {
    background-color: #FFFFFF;
    border-color: #DDDDDD;
    color: #DDDDDD;
    cursor: not-allowed;
    opacity: 1;
    box-shadow: none;
  }
}
</style>
