<template>
  <div class="portal-wrap">
    <!-- 固定顶部 -->
    <div class="fixed-top">
      <!-- 顶部公告条 -->
      <div class="top-bar">
        <div class="top-bar-inner">
          <span class="top-bar-left">欢迎访问集团人才招募平台</span>
          <div class="top-bar-right">
            <template v-if="auth.isLoggedIn">
              <router-link v-if="auth.isSeeker" to="/seeker/applications" class="top-link">我的投递</router-link>
              <router-link v-else to="/admin/jobs" class="top-link">管理后台</router-link>
              <span class="top-divider">|</span>
              <span class="top-link clickable" @click="logout">退出登录</span>
            </template>
          </div>
        </div>
      </div>

      <!-- 主导航 -->
      <header class="main-header">
      <div class="header-inner">
        <!-- Logo 区域 -->
        <router-link to="/home" class="logo-area">
          <div class="logo-emblem">
            <div class="emblem-ring">
              <span class="emblem-char">招</span>
            </div>
          </div>
          <div class="logo-text-block">
            <span class="logo-title">集团招聘平台</span>
            <span class="logo-sub">GROUP TALENT RECRUITMENT</span>
          </div>
        </router-link>

        <!-- 导航 -->
        <nav class="main-nav">
          <router-link to="/home" class="nav-link" active-class="active">首页</router-link>
          <router-link to="/companies" class="nav-link" active-class="active">公司介绍</router-link>
        </nav>

        <!-- 操作区 -->
        <div class="header-actions">
          <template v-if="!auth.isLoggedIn">
            <router-link to="/login">
              <button class="btn-ghost">登录</button>
            </router-link>
            <router-link to="/register">
              <button class="btn-ghost">立即注册</button>
            </router-link>
          </template>
          <template v-else>
            <div class="user-badge">
              <span class="user-avatar">{{ auth.user?.username?.[0]?.toUpperCase() }}</span>
              <span class="user-name">{{ auth.user?.username }}</span>
            </div>
          </template>
        </div>
      </div>

      <!-- 红色底线 -->
      <div class="header-underline">
        <div class="underline-fill"></div>
      </div>
    </header>
    </div>

    <!-- 内容区 -->
    <main class="portal-main">
      <router-view />
    </main>

    <!-- 页脚（全屏面板页隐藏） -->
    <footer class="portal-footer" v-if="$route.name !== 'Home'">
      <div class="footer-inner">
        <div class="footer-logo">
          <div class="f-emblem">招</div>
          <span>集团招聘平台</span>
        </div>
        <div class="footer-copy">
          Copyright © 集团招聘平台 · All Rights Reserved · 为国家建设输送优秀人才
        </div>
      </div>
    </footer>
  </div>
</template>

<script setup>
import { useAuthStore } from '@/stores/auth'
import { useRouter } from 'vue-router'
const auth = useAuthStore()
const router = useRouter()
const logout = () => { auth.logout(); router.push('/') }
</script>

<style scoped>
:root {
  --c-red: var(--brand-red);
  --c-dark: var(--brand-red-2);
  --c-gold: var(--brand-red);
  --c-cream: var(--bg-page);
  --c-border: var(--border);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; }

.portal-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #FBF5F5;
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

/* 固定顶部容器 */
.fixed-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

/* 顶部公告条 */
.top-bar {
  background: #F2F3F5;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.05em;
}
.top-bar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 6px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-bar-left::before {
  content: '★';
  color: var(--brand-red);
  margin-right: 6px;
  font-size: 10px;
}
.top-bar-right { display: flex; align-items: center; gap: 6px; }
.top-link { color: var(--text-muted); transition: color 0.2s; }
.top-link:hover, .clickable:hover { color: var(--brand-red); cursor: pointer; }
.top-divider { color: #C9CDD4; }

/* 主导航 */
.main-header {
  background: #FFFFFF;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  height: 72px;
  display: flex;
  align-items: center;
  gap: 48px;
}

/* Logo */
.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.logo-emblem { position: relative; }
.emblem-ring {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--brand-red);
  background: linear-gradient(135deg, rgba(235,44,38,0.12), rgba(235,44,38,0.04));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 16px rgba(235,44,38,0.25), inset 0 0 8px rgba(235,44,38,0.08);
}
.emblem-char {
  font-size: 20px;
  font-weight: 900;
  color: var(--brand-red);
  letter-spacing: -1px;
}
.logo-text-block { display: flex; flex-direction: column; }
.logo-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: 0.15em;
  line-height: 1.2;
}
.logo-sub {
  font-size: 9px;
  color: var(--brand-red);
  opacity: 0.75;
  letter-spacing: 0.2em;
  margin-top: 2px;
}

/* 导航链接 */
.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.nav-link {
  position: relative;
  padding: 8px 20px;
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.08em;
  transition: color 0.2s;
  border-radius: 4px;
}
.nav-link::after {
  content: '';
  position: absolute;
  bottom: 4px; left: 50%; right: 50%;
  height: 2px;
  background: var(--brand-red);
  border-radius: 1px;
  transition: left 0.25s ease, right 0.25s ease;
}
.nav-link:hover { color: var(--brand-red); }
.nav-link:hover::after, .nav-link.active::after { left: 20%; right: 20%; }
.nav-link.active { color: var(--brand-red); font-weight: 600; }

/* 操作区 */
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.btn-ghost {
  padding: 7px 20px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 3px;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-ghost:hover { border-color: var(--brand-red); color: var(--brand-red); }
.btn-primary {
  padding: 7px 20px;
  background: #FFFFFF;
  border: 1px solid #FFFFFF;
  color: #fff;
  border-radius: 3px;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  font-weight: 600;
  font-family: inherit;
}
.btn-primary:hover { background: #F0F0F0; border-color: #F0F0F0; }
.user-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  background: var(--brand-red-bg);
  border: 1px solid var(--border);
  border-radius: 24px;
}
.user-avatar {
  width: 26px; height: 26px;
  background: var(--brand-red);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.user-name { color: var(--text-main); font-size: 13px; }

/* 底线装饰 */
.header-underline { height: 3px; background: #FFFFFF; }
.underline-fill {
  height: 100%;
  background: var(--brand-red);
}

/* 内容区 — top-bar(~28px) + header(72px) + underline(3px) = ~103px */
.portal-main {
  flex: 1;
  width: 100%;
  margin: 0 auto;
  padding-top: 97px;
}
.portal-main:has(.two-panel) {
  max-width: none;
  padding: 97px 0 0;
}
.portal-main:not(:has(.two-panel)) {
  max-width: 1280px;
  padding: 97px 32px 0;
}

/* 页脚 */
.portal-footer {
  background: #1D2129;
  border-top: 3px solid var(--brand-red);
  padding: 20px 0;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-logo {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,0.7);
  font-size: 14px; letter-spacing: 0.1em;
}
.f-emblem {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--brand-red);
  color: var(--brand-red); font-weight: 900; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.footer-copy {
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.05em;
}
</style>
