<template>
  <header class="header">
    <nav class="container header-nav">
      <div class="logo">
        <span class="logo-text">教师团队管理系统</span>
      </div>
      <div class="menu">
        <router-link to="/" class="menu-item">首页</router-link>
        <router-link to="/shared-library" class="menu-item">共享资料库</router-link>
        <template v-if="isAdmin">
          <router-link to="/admin/accounts" class="menu-item">账号管理</router-link>
          <router-link to="/admin/files" class="menu-item">资料库管理</router-link>
        </template>
      </div>
      <div class="auth">
        <template v-if="!isLoggedIn">
          <router-link to="/login" class="auth-link">登录</router-link>
          <router-link to="/register" class="auth-link">注册</router-link>
        </template>
        <template v-else>
          <UserMenu v-if="!isAdmin" />
          <AdminMenu v-else />
        </template>
      </div>
    </nav>
  </header>
</template>

<script setup>
import { computed } from 'vue';
import UserMenu from './UserMenu.vue';
import AdminMenu from './AdminMenu.vue';
import { useAuthStore } from '@/store/modules/auth';

const store = useAuthStore();
const isLoggedIn = computed(() => store.isAuthenticated);
const isAdmin = computed(() => store.isAdmin);
</script>

<style scoped>
.header {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  box-shadow: var(--shadow-md);
  padding: 1rem 0;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
  animation: shimmer 15s infinite linear;
  pointer-events: none;
}

@keyframes shimmer {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.header-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
  z-index: 1;
}

.logo-text {
  font-size: 1.5rem;
  color: var(--light-text-color);
  font-weight: bold;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.menu {
  display: flex;
  gap: 1.5rem;
}

.menu-item, .auth-link {
  color: var(--light-text-color);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-base);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.menu-item::after, .auth-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--light-text-color);
  transform: scaleX(0);
  transition: transform var(--transition-base);
}

.menu-item:hover::after, .auth-link:hover::after {
  transform: scaleX(1);
}

.menu-item:hover, .auth-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.auth {
  display: flex;
  gap: 1rem;
}

@media (max-width: 768px) {
  .header-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .menu, .auth {
    margin-top: 1rem;
  }

  .menu {
    flex-wrap: wrap;
  }
}
</style>




