<!-- Header 头部 -->
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { useUserStore } from '@/stores';
import UserDropdown from './components/UserDropdown.vue';

const route = useRoute();
const userStore = useUserStore();

const searchKeyword = ref('');
</script>

<template>
  <header class="top-header">
    <div class="header-left">
      <div class="breadcrumb-area">
        <h2 class="page-title">{{ route.meta?.title || '工作台' }}</h2>
        <span v-if="route.meta?.subtitle" class="page-subtitle">{{ route.meta.subtitle }}</span>
      </div>
    </div>
    <div class="header-right">
      <el-input
        v-model="searchKeyword"
        placeholder="搜索功能、流程、数据..."
        prefix-icon="Search"
        class="header-search"
        clearable
      />
      <el-tooltip content="消息通知" placement="bottom">
        <el-badge :max="99" class="notification-btn">
          <div class="icon-btn">
            <el-icon :size="20"><Bell /></el-icon>
          </div>
        </el-badge>
      </el-tooltip>     
      <el-divider direction="vertical" />
      <UserDropdown />
    </div>
  </header>
</template>

<style scoped lang="scss">
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 64px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.breadcrumb-area {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 12px;
  color: var(--color-text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-search {
  width: 240px;
  :deep(.el-input__wrapper) {
    border-radius: 10px;
    background: #f5f3f0;
    box-shadow: none;
    border: 1px solid transparent;
    transition: all var(--transition);
    &:hover {
      border-color: #ddd;
    }
    &.is-focus {
      border-color: var(--color-accent);
      background: #fff;
      box-shadow: 0 0 0 3px rgba(29, 90, 243, 0.08);
    }
  }
  :deep(.el-input__inner) {
    font-size: 13px;
  }
  :deep(.el-input__prefix .el-icon) {
    color: #a8a49c;
  }
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition);
  &:hover {
    background: #f0eeeb;
    color: var(--color-text-primary);
  }
}

.notification-btn {
  :deep(.el-badge__content) {
    top: -2px;
    right: 2px;
  }
}
</style>