<template>
  <div class="page-canvas">
    <header class="page-topbar">
      <div class="topbar-center">
        <div class="model-title">{{ displayTitle }}</div>
      </div>
      <div v-if="$slots['topbar-right']" class="topbar-right">
        <slot name="topbar-right"></slot>
      </div>
    </header>

    <section class="model-stage">
      <slot name="model">
        <ModelPlaceholder />
      </slot>
    </section>

    <slot />
  </div>
</template>

<script setup>
import ModelPlaceholder from "../model-placeholder/index.vue";
import { computed } from "vue";
import { useModelCenterStore } from "../../stores/modelCenter.js";

const props = defineProps({
  title: {
    type: String,
    default: "",
  },
});

const modelCenterStore = useModelCenterStore();
const displayTitle = computed(() => props.title || modelCenterStore.activeModelName);
</script>

<style scoped>
.page-canvas {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(98, 191, 206, 0.34);
  background: radial-gradient(circle at 50% 30%, #bcc9d6 0%, #b2c3d2 60%, #a8b8c9 100%);
  box-shadow: inset 0 0 0 8px rgba(214, 230, 241, 0.55);
}

.page-topbar {
  position: absolute;
  inset: 0 0 auto;
  height: 120px;
  z-index: 30;
}

.topbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 16px;
  display: grid;
  justify-items: center;
  gap: 10px;
}

.topbar-right {
  position: absolute;
  right: 24px;
  top: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

.model-title {
  font-size: 20px;
  letter-spacing: 1px;
  font-weight: 700;
  color: rgba(255, 128, 52, 0.95);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.model-stage {
  position: absolute;
  inset: 0;
}
</style>
