<template>
  <el-container class="layout-container">
    <el-aside width="220px" class="sidebar">
      <div class="logo">
        <span class="logo-icon">AFM</span>
        <span class="logo-text">轴向磁通电机仿真系统</span>
      </div>
      <el-menu
        :default-active="activeMenu"
        router
        background-color="#1e293b"
        text-color="#94a3b8"
        active-text-color="#3b82f6"
      >
        <el-menu-item index="/projects">
          <el-icon><Folder /></el-icon>
          <span>项目管理</span>
        </el-menu-item>
        <el-menu-item index="/experience">
          <el-icon><Collection /></el-icon>
          <span>经验库</span>
        </el-menu-item>
        <el-menu-item index="/dashboard">
          <el-icon><DataAnalysis /></el-icon>
          <span>结果分析</span>
        </el-menu-item>
        <el-menu-item index="/tasks">
          <el-icon><List /></el-icon>
          <span>任务管理</span>
        </el-menu-item>
        <el-menu-item index="/monitor">
          <el-icon><Monitor /></el-icon>
          <span>实时监控</span>
        </el-menu-item>
        <el-menu-item index="/visualization">
          <el-icon><DataLine /></el-icon>
          <span>高级可视化</span>
        </el-menu-item>
        <el-sub-menu index="ai">
          <template #title>
            <el-icon><MagicStick /></el-icon>
            <span>AI智能</span>
          </template>
          <el-menu-item index="/ai/plan-generator">AI方案生成</el-menu-item>
          <el-menu-item index="/ai/l0-prescreen">L0预筛选</el-menu-item>
          <el-menu-item index="/ai/adaptive-optimize">自适应优化</el-menu-item>
          <el-menu-item index="/ai/result-analysis">AI结果分析</el-menu-item>
          <el-menu-item index="/ai/fidelity-calibration">多保真度校准</el-menu-item>
          <el-menu-item index="/ai/experience-enhance">经验库AI增强</el-menu-item>
        </el-sub-menu>
      </el-menu>
      <div class="sidebar-footer">
        <span class="version">v1.0.0</span>
      </div>
    </el-aside>
    <el-container>
      <el-header class="header">
        <div class="header-left">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/projects' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item v-if="currentTitle">{{ currentTitle }}</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="header-right">
          <el-tag type="success" size="small">后端已连接</el-tag>
        </div>
      </el-header>
      <el-main class="main-content">
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { Folder, Collection, DataAnalysis, MagicStick, List, Monitor, DataLine } from '@element-plus/icons-vue'

const route = useRoute()
const activeMenu = computed(() => route.path)
const currentTitle = computed(() => route.meta.title as string)
</script>

<style scoped>
.layout-container {
  height: 100vh;
}

.sidebar {
  background: #1e293b;
  display: flex;
  flex-direction: column;
}

.logo {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid #334155;
}

.logo-icon {
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
  margin-right: 10px;
}

.logo-text {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
}

.sidebar :deep(.el-menu) {
  border-right: none;
  flex: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #334155;
}

.version {
  color: #64748b;
  font-size: 11px;
}

.header {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.main-content {
  background: #f0f2f5;
  padding: 0;
  overflow-y: auto;
}
</style>
