<script setup lang="ts">
const route = useRoute()
const contentFrame = computed(() => route.meta.contentFrame)
const contentContent = computed(() => {
  switch (contentFrame.value) {
    case 'cf-container-lg':
      return 'cf-frame cf-container-lg-content'
    case 'cf-container-md':
      return 'cf-frame cf-container-md-content'
    case 'cf-container-sm':
      return 'cf-frame cf-container-sm-content'
    case 'cf-full-width':
      return 'cf-frame-width'
    default:
      return 'cf-frame'
  }
})
</script>

<template>
  <SidebarProvider>
    <LayoutAppSidebar />
    <SidebarInset>
      <LayoutHeader />
      <div class="w-full min-w-0 flex-1 overflow-x-auto p-4 lg:p-6">
        <div v-if="contentFrame !== 'cf-no-frame'" class="contentFrame">
          <div :class="`${contentContent} ${contentFrame}`">
            <slot />
          </div>
        </div>
        <slot v-else />
      </div>
    </SidebarInset>
  </SidebarProvider>
</template>

<style scoped>
.cf-container,
.cf-container-lg,
.cf-container-md,
.cf-container-sm {
  container-type: inline-size;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  border-radius: 0.375rem;
  padding-bottom: 5rem;
  padding-left: 1rem;
  padding-right: 1rem;
}

.cf-container > *,
.cf-container-lg > *,
.cf-container-md > *,
.cf-container-sm > *,
.cf-full-width {
  margin-left: auto;
  margin-right: auto;
  padding: 0.75rem; /* p-3 */
  padding-bottom: 5rem; /* pb-20 */
  background-color: hsl(var(--background));
  border-radius: 0.375rem;
  border: 1px solid hsl(var(--border));
  border-color: rgb(226 232 240); /* slate-200 */
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.cf-container-lg > * {
  max-width: 992px;
}

.cf-container-md > * {
  max-width: 768px;
}

.cf-container-sm > * {
  max-width: 576px;
}

.cf-frame-width {
  margin-left: auto;
  margin-right: auto;
  background-color: hsl(var(--background));
  border-radius: 0.375rem;
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-width: 100%;
  padding: 1rem;
}

.cf-frame {
  margin-left: auto;
  margin-right: auto;
  padding: 1rem;
  background-color: hsl(var(--background));
  border-radius: 0.375rem;
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

@media (min-width: 640px) {
  .cf-container,
  .cf-container-lg,
  .cf-container-md,
  .cf-container-sm {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .cf-frame {
    padding: 2rem;
  }

  .cf-frame-width {
    padding: 2rem;
  }
}

@media (min-width: 1024px) {
  .cf-container,
  .cf-container-lg,
  .cf-container-md,
  .cf-container-sm {
    padding-left: 3rem;
    padding-right: 3rem;
  }

  .cf-frame {
    padding: 3rem;
  }

  .cf-frame-width {
    padding: 3rem;
  }
}
</style>
