<template>
    <div class="page-container">
        <!-- 统计卡片 -->
        <StatCards />

        <!-- 主体：目录树 + 列表 + 详情 -->
        <div class="main-layout">
            <div class="left-panel">
                <CategoryTree @select-category="onSelectCategory" />
            </div>
            <div class="right-panel">
                <CorpusList :categoryId="categoryId"  />
            </div>
        </div>
    </div>
</template>
<script setup>
import { ref } from 'vue'
import StatCards from './components/StatCards.vue'
import CategoryTree from './components/CategoryTree.vue'
import CorpusList from './components/CorpusList.vue'

const categoryId = ref('')

const onSelectCategory = (node) => {
  categoryId.value = node.id
}

</script>
<style lang="scss" scoped>
.page-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    height: 100%;
    overflow: auto;
}

.main-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    align-items: start;
    flex: 1;
}

.left-panel {
    position: sticky;
    top: 20px;
    height: 100%;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detail-wrapper {
    min-height: 200px;
}

@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .left-panel {
        position: static;
    }
}
</style>