<template>
  <!-- 整体后台布局容器 -->
  <el-container class="layout-container">
    <!-- 侧边栏 -->
    <el-aside width="220px" class="sidebar">
      <!-- Logo区域 -->
      <div class="logo-container">
        <el-icon class="logo-icon"><ChatDotSquare /></el-icon>
        <span class="logo-title">AI面试官</span>
      </div>
      <!-- 
        el-scrollbar: Element Plus的滚动条组件。
        通过CSS设置其高度为100%，它会自动在内容溢出时显示滚动条，
        否则滚动条不显示，解决了您提出的问题。
      -->
      <el-scrollbar style="height: calc(100% - 60px);"> 
        <el-menu
          :default-active="$route.path"  
          background-color="#0a192f"    
          text-color="#8892b0"          
          active-text-color="#64ffda"   
          :router="true"                 
        >
          <el-menu-item index="/">
            <el-icon><House /></el-icon>
            <span>仪表盘</span>
          </el-menu-item>
          <el-menu-item index="/interview">
            <el-icon><ChatLineRound /></el-icon>
            <span>模拟面试</span>
          </el-menu-item>
          <el-menu-item index="/question-bank">
            <el-icon><MessageBox /></el-icon>
            <span>题库管理</span>
          </el-menu-item>
          <el-menu-item index="/history">
            <el-icon><Finished /></el-icon>
            <span>会话历史</span>
          </el-menu-item>
          <el-menu-item index="/answer-record">
            <el-icon><List /></el-icon>
            <span>答题记录</span>
          </el-menu-item>
        </el-menu>
      </el-scrollbar>
    </el-aside>

    <!-- 右侧主内容区 -->
    <el-container>
      <el-header class="header">
        <div class="header-title">欢迎使用AI模拟面试平台</div>
      </el-header>
      <el-main class="main-content">
        <router-view v-slot="{ Component }">
          <transition name="fade-transform" mode="out-in">
            <component :is="Component" />
          </transition>
        </router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import {House, ChatLineRound, MessageBox, ChatDotSquare, Finished, List} from '@element-plus/icons-vue';
</script>

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

/* 更新后的侧边栏样式 */
.sidebar {
  background-color: #0a192f; /* 更深、更现代的科技蓝 */
  transition: width 0.28s;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  background-color: #0a192f;
  color: #ccd6f6;
  font-size: 1.3em;
  font-weight: 600;
}

.logo-icon {
  margin-right: 12px;
  color: #64ffda; /* 高亮颜色 */
}

.el-menu {
  border-right: none;
}

/* 菜单项激活时的样式 */
.el-menu-item.is-active {
    background-color: #112240 !important; /* 深色背景 */
    border-left: 3px solid #64ffda; /* 左侧高亮条 */
}

.el-menu-item:hover {
    background-color: #112240; /* 悬浮背景色 */
}

.header {
  display: flex;
  align-items: center;
  background-color: #fff;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  padding: 0 20px;
}

.header-title {
  font-size: 1.1em;
  color: #303133;
}

.main-content {
  padding: 20px;
  background-color: #f0f2f5;
}

.fade-transform-enter-active,
.fade-transform-leave-active {
  transition: all 0.5s;
}

.fade-transform-enter-from,
.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(-30px);
}
</style>