<template>
  <div class="layout">
    <header class="header">
      <div class="header__container">
        <Icon name="lucide:menu" class="cursor-pointer ml20 w-6 h-6 text-gray-700" />

        <h1
          class="header__headline"
          @click="router.push(`/`)"
        >
          PAXTON
        </h1>

        <div
          class="header__cart"
          @click="router.push(`/cart`)"
        >
          <Icon
            name="lucide:shopping-cart"
            class="cursor-pointer w-6 h-6 text-gray-700"
          />
          <div v-if="cart?.line_items?.length" class="header__cart-count">
            {{ cart.line_items.length }}
          </div>
        </div>
      </div>
    </header>

    <main class="main">
      <UContainer class="container">
        <slot />
      </UContainer>
    </main>

    <footer class="footer">
      Footer
    </footer>
  </div>
</template>

<script setup lang="ts">
const router = useRouter()
const { cart } = useCart()
</script>

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

.container {
  --ui-container: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  height: 54px;
  background: white;

  &__container {
    height: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    padding: 0 16px;
  }

  &__headline {
    font-size: 32px;
    color: black;
    cursor: pointer;
  }

  &__cart {
    position: relative;
    display: inline-block;
  }

  &__cart-count {
    cursor: pointer;
    position: absolute;
    top: -6px;
    right: -6px;
    background: red;
    color: white;
    font-size: 12px;
    font-weight: bold;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.main {
  flex: 1;
  margin-top: 54px;
}

.footer {
  margin-top: auto;
}
</style>
