<template>
  <div class="welcome-page">
    <div class="welcome-header">
      <h2>欢迎回来 👋</h2>
      <p>选择下方快捷入口，开始管理你的博客</p>
    </div>
    <div class="menu-sections">
      <div class="menu-section" v-for="menu in menus" :key="menu.name">
        <div class="section-title">
          <el-icon><component :is="menu.icon" /></el-icon>
          <span>{{ menu.title }}</span>
        </div>
        <div class="section-items">
          <router-link
            :to="submenu.path"
            v-for="submenu in menu.child"
            :key="submenu.path"
            class="menu-item"
          >
            <span class="item-label">{{ submenu.title }}</span>
            <el-icon class="item-arrow"><ArrowRight /></el-icon>
          </router-link>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import menus from '../config/menu'
</script>
<style lang="less" scoped>
.welcome-page {
  padding: 32px;
  max-width: 900px;
}

.welcome-header {
  margin-bottom: 32px;
  h2 {
    font-size: 26px;
    font-weight: 700;
    color: #1d2129;
    margin: 0 0 8px;
  }
  p {
    font-size: 14px;
    color: #86909c;
    margin: 0;
  }
}

.menu-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.menu-section {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #f0f0f0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #4e5969;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f5f5f5;

  .el-icon {
    font-size: 17px;
    color: var(--el-color-primary);
  }
}

.section-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f7f8fa;
  text-decoration: none;
  color: #1d2129;
  font-size: 14px;
  transition: all 0.2s;
  border: 1px solid transparent;

  .item-arrow {
    font-size: 13px;
    color: #c9cdd4;
    transition: transform 0.2s, color 0.2s;
  }

  &:hover {
    background: var(--el-color-primary-light-9);
    border-color: var(--el-color-primary-light-5);
    color: var(--el-color-primary);

    .item-arrow {
      color: var(--el-color-primary);
      transform: translateX(3px);
    }
  }
}
</style>