<template>
  <div class="app-container">
    <transition name="layout-fade">
      <SplashScreen v-if="!store.isInitialized" :status-text="store.initStatus" />
    </transition>

    <template v-if="store.isInitialized">
      <Sidebar />
      <div class="main-content">
        <router-view v-slot="{ Component }">
          <transition name="page-fade" mode="out-in">
            <component :is="Component" />
          </transition>
        </router-view>
      </div>
    </template>
  </div>
</template>

<script setup lang="ts">
import Sidebar from './components/Sidebar.vue'
import SplashScreen from './components/SplashScreen.vue'
import { useSoftwareStore } from './store/software'
import { onMounted } from 'vue'

const store = useSoftwareStore()

onMounted(async () => {
  store.initListener()
  await store.initializeApp()
})
</script>

<style>
:root {
  --primary-color: #007AFF;
  --primary-hover: #0063CC;
  --bg-light: #FBFBFD;
  --sidebar-bg: #F8FAFD;
  --text-main: #1D1D1F;
  --text-sec: #86868B;
  --border-color: #E5E5E7;
  --card-shadow: 0 12px 30px rgba(0, 0, 0, 0.04);
  --btn-shadow: 0 4px 12px rgba(0, 122, 255, 0.25);
  --radius-card: 24px;
  --radius-btn: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.main-content {
  flex: 1;
  height: 100vh;
  display: flex; /* 让子元素（页面）能撑满高度 */
  flex-direction: column;
  overflow: hidden; /* 禁用全局容器滚动 */
  position: relative;
}

/* 1. 布局级别过渡 (Splash -> App) */
.layout-fade-enter-active,
.layout-fade-leave-active {
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.layout-fade-leave-to {
  opacity: 0;
  transform: scale(1.05);
}

/* 2. 页面级别过渡 */
.page-fade-enter-active,
.page-fade-leave-active {
  transition: opacity 0.15s ease;
}

.page-fade-enter-from,
.page-fade-leave-to {
  opacity: 0;
}
</style>
