<template>
  <div id="header" v-if="booleanHeader">
    <div id="header-profile">
      <div id="header-profile-left">
        <!-- 用户信息悬浮菜单 -->
        <Dropdown :menu="{ items: userMenu }" trigger="hover">
          <div class="user-info-container">
            <div class="user-avatar-wrapper">
              <Avatar size="large" src="https://api.dicebear.com/7.x/avataaars/svg?seed=user123" class="user-avatar" />
              <span class="user-online-indicator"></span>
            </div>
            <div class="user-info-text">
              <span class="user-name">用户名</span>
              <span class="user-level">Lv.3</span>
            </div>
            <span class="user-arrow">▼</span>
          </div>
          <template #overlay>
            <div class="user-info-menu">
              <div class="user-info-menu-item">
                <a href="javascript:;">1st menu item</a>
              </div>
              <div class="user-info-menu-item">
                <a href="javascript:;">2nd menu item</a>
              </div>
              <div class="user-info-menu-item">
                <a href="javascript:;">3rd menu item</a>
              </div>
            </div>
          </template>
        </Dropdown>
      </div>
      <div id="header-profile-right">
        <!-- 右侧功能菜单 -->
        <Dropdown :menu="{ items: rightMenu }" trigger="hover">
          <Button type="text" class="header-more-btn">更多 <i class="iconfont icon-zhankaishouqi"></i></Button>
        </Dropdown>
        <a href="/" class="header-nav-link">首页</a>
        <Button type="primary" @click="router.push('/cart')" class="header-cart-btn">
          <i class="iconfont icon-gouwuche"></i> 购物车
        </Button>
        <Button type="primary" @click="router.push('/order')" class="header-order-btn">
          <i class="iconfont icon-dingdan"></i> 订单
        </Button>
      </div>
    </div>
    <Row id="header-nav-row" v-if="booleanSearch">
      <Col class="header-nav-Logo" :span="4">
        <a href="/">TaoTaoWang</a>
      </Col>
      <Col class="header-nav-search" :span="16">
        <div class="search-input-container" :class="{ 'search-focused': showHistory }">
          <div class="search-wrapper">
            <!-- 搜索类型选择 -->
            <div class="search-type-selector">
              <ul>
                <li class="search-type-item active" @click="setSearchType('宝贝', $event)">宝贝</li>
                <li class="search-type-item" @click="setSearchType('店铺', $event)">店铺</li>
              </ul>
            </div>

            <!-- 搜索输入区域 -->
            <div class="search-input-wrapper">
              <div class="search-input-prefix">
                <i class="iconfont icon-sousuo prefix-icon"></i>
              </div>
              <Input v-model:value="searchValue" placeholder="请输入搜索关键词" style="width: 100%" @search="onSearch"
                @focus="onInputFocus" @blur="onInputBlur" class="custom-search-input" />
              <div class="search-input-suffix" v-if="searchValue">
                <i class="iconfont icon-guanbi" @click="clearSearch"></i>
              </div>
            </div>

            <!-- 搜索按钮 -->
            <div class="search-button-container" @onclick="onSearch">
              <span class="search-button-text">搜索</span>
              <div class="search-button-icon">
                <i class="iconfont icon-sousuo"></i>
              </div>
            </div>
          </div>
        </div>
        <div class="search-history-container" v-if="showHistory">
          <div class="search-history-header">
            <span class="history-title">搜索历史</span>
            <a class="clear-history" @click="clearHistory" href="javascript:void(0)">
              清空历史
            </a>
          </div>
          <div class="search-history-tags" v-if="historyList.length > 0">
            <Tag v-for="(item, index) in historyList" :key="index" class="history-tag" @click="onClickHistory(item)">
              {{ item }}
            </Tag>
          </div>
          <div class="no-history" v-else>
            暂无搜索历史
          </div>
        </div>
      </Col>
      <Col class="header-nav-product" :span="4">
        <a href="#">随便放点东西显得对称</a>
        <!-- 其他页面的时候修改布局 -->
      </Col>
    </Row>
  </div>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { Button, Col, Row, Space, Dropdown, Avatar, Menu, Divider, Tag } from 'ant-design-vue';
import Input from 'ant-design-vue/es/input';
const router = useRouter()
// 定义搜索框绑定的变量
const searchValue = ref('')
// 控制历史记录显示状态
const showHistory = ref(false)
// 标志：是否正在清空历史记录
const isClearingHistory = ref(false)
// 控制搜索框是否显示
const booleanSearch = ref(true)
// 控制Header是否显示
const booleanHeader = ref(true)
// 监听路由变化 当路由变化时 更新搜索框的显示状态
watch(() => router.currentRoute.value.name, (newName) => {
  // 如果是搜索页面 则更新查询参数
  if (newName === 'search') {
    searchValue.value = router.currentRoute.value.query.keyword as string
  }
  // 如果是商品页面 则显示搜索框
  if (newName === 'productDetail' || newName === 'chat') {
    booleanSearch.value = true
  }
  // 如果在登录页面 则隐藏搜索框
  if (newName === 'login') {
    booleanHeader.value = false
  }
  console.log(newName)
})
// 定义搜索框的搜索事件
const onSearch = (value: string) => {
  console.log('搜索关键词:', value)
  // 跳转到搜索结果页面
  if (value.trim()) {
    // 添加到历史记录
    if (!historyList.value.includes(value)) {
      historyList.value.unshift(value)
      // 限制历史记录数量
      if (historyList.value.length > 10) {
        historyList.value.pop()
      }
    }
    // 判断是否在搜索界面 如果不在 则跳转到搜索界面 如果在搜索界面 则更新查询参数
    if (router.currentRoute.value.name !== 'search') {
      router.push({ name: 'search', query: { keyword: value } })
    } else {
      router.push({ name: 'search', query: { keyword: value } })
    }
  }
}

// 搜索历史记录
const historyList = ref(['手机', '电脑', '耳机', '键盘', '鼠标'])

// 清空历史记录
const clearHistory = () => {
  isClearingHistory.value = true
  historyList.value = []
  // 300ms后重置标志，确保onInputBlur的200ms延迟执行完毕
  setTimeout(() => {
    isClearingHistory.value = false
  }, 300)
}

// 点击历史记录
const onClickHistory = (item: string) => {
  searchValue.value = item
  onSearch(item)
}

// 搜索框获得焦点
const onInputFocus = () => {
  showHistory.value = true
}

// 搜索框失去焦点
const onInputBlur = () => {
  // 使用setTimeout确保点击历史记录的事件能先执行
  setTimeout(() => {
    // 如果正在清空历史记录，则不隐藏历史记录容器
    if (!isClearingHistory.value) {
      showHistory.value = false
    }
  }, 200)
}

// 当前搜索类型
const currentSearchType = ref('宝贝')

// 设置搜索类型
const setSearchType = (type: string, event: MouseEvent) => {
  const typeItems = document.querySelectorAll('.search-type-item')
  // 找到当前活跃的元素
  const currentActiveItem = document.querySelector('.search-type-item.active')
  // 保存点击的元素引用
  const clickedTarget = event.currentTarget as HTMLElement

  // 为当前活跃的元素添加消失动画
  if (currentActiveItem && currentActiveItem !== clickedTarget) {
    if (currentSearchType.value === '宝贝' && type === '店铺') {
      // 宝贝 -> 店铺：宝贝元素从左往右消失
      currentActiveItem.classList.add('animate-right-out')
    } else if (currentSearchType.value === '店铺' && type === '宝贝') {
      // 店铺 -> 宝贝：店铺元素从右往左消失
      currentActiveItem.classList.add('animate-left-out')
    }

    // 等待消失动画完成后再继续
    setTimeout(() => {
      // 移除所有元素的类
      typeItems.forEach(item => {
        item.classList.remove('active', 'animate-left', 'animate-right', 'animate-left-out', 'animate-right-out')
      })

      // 添加active类到点击的元素
      if (clickedTarget) {
        // 判断切换方向
        if (currentSearchType.value === '宝贝' && type === '店铺') {
          // 宝贝 -> 店铺：从左往右出现
          clickedTarget.classList.add('active', 'animate-right')
        } else if (currentSearchType.value === '店铺' && type === '宝贝') {
          // 店铺 -> 宝贝：从右往左出现
          clickedTarget.classList.add('active', 'animate-left')
        } else {
          // 默认动画
          clickedTarget.classList.add('active')
        }
        currentSearchType.value = type
      }
      console.log('搜索类型:', type)

    }, 300)
  } else {
    // 如果点击的是当前活跃的元素，直接返回
    return
  }
}

// 清除搜索输入
const clearSearch = () => {
  searchValue.value = ''
  console.log('已清除搜索输入')
}

// 左侧用户菜单
const userMenu = [
  {
    key: '1',
    label: '个人中心'
  },
  {
    key: '2',
    label: '设置'
  },
  {
    key: '3',
    label: '退出登录',
    danger: true
  }
]

// 右侧功能菜单
const rightMenu = [
  {
    key: '1',
    label: '浏览记录'
  },
  {
    key: '2',
    label: '收藏夹'
  },
  {
    key: '3',
    label: '帮助中心'
  }
]
</script>
<style scoped>
#header {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  position: relative;
  z-index: 1000;
}

#header-nav-row {
  height: 60px;
  align-items: center;
}

#header-profile {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#header-profile-left {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

#header-profile-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--spacing-md);
}

/* 用户信息容器样式 */
.user-info-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-3xl);
  cursor: pointer;
  transition: all var(--transition-transform);
}

.user-info-container:hover {
  background-color: var(--bg-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* 用户头像区域 */
.user-avatar-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar {
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.user-info-container:hover .user-avatar {
  transform: scale(1.05);
}

.user-online-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background-color: var(--success-color);
  border: 2px solid var(--card-bg);
  border-radius: var(--border-radius-full);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(82, 196, 26, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(82, 196, 26, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(82, 196, 26, 0);
  }
}

/* 用户信息文本区域 */
.user-info-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.user-level {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--warning-color);
  background-color: #fff7e6;
  padding: 1px 6px;
  border-radius: var(--border-radius-xl);
  align-self: flex-start;
}

.user-arrow {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  transition: transform var(--transition-transform);
}

.user-info-container:hover .user-arrow {
  transform: rotate(180deg) scale(1.1);
  color: var(--text-secondary);
}
/* 用户信息菜单样式 */
.user-info-menu {
  display: flex;
  flex-direction: column;
  padding: var(--spacing-md);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  z-index: 1000;
  transition: all var(--transition-transform);
  background-color: var(--card-bg);
}

.user-info-menu-item {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-2xl);
  transition: all var(--transition-transform);
}

.user-info-menu-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.user-info-menu-item:hover {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

/* 右侧功能菜单样式 */
.header-more-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--border-radius-2xl);
  transition: all var(--transition-transform);
  font-size: var(--font-size-sm);
}

.header-more-btn:hover {
  background-color: var(--bg-color);
  color: var(--text-primary);
}

.header-nav-link {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--border-radius-2xl);
  transition: all var(--transition-transform);
  position: relative;
}

.header-nav-link:hover {
  color: var(--primary-color);
  background-color: var(--bg-primary-lightest);
}

.header-nav-link::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 0;
  height: 2px;
  background-color: var(--primary-color);
  border-radius: 1px;
  transition: all var(--transition-transform);
}

.header-nav-link:hover::after {
  width: 80%;
  left: 10%;
}

/* 购物车和订单按钮样式 */
.header-cart-btn,
.header-order-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-3xl);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-transform);
  position: relative;
  overflow: hidden;
}

.header-cart-btn {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  border: none;
}

.header-order-btn {
  background: linear-gradient(135deg, var(--secondary-color), var(--secondary-hover));
  border: none;
}

.header-cart-btn:hover,
.header-order-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.header-cart-btn:active,
.header-order-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-cart-btn::before,
.header-order-btn::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(45deg);
  animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
  0% {
    transform: rotate(45deg) translateX(-100%) translateY(-100%);
    opacity: 0;
  }

  50% {
    opacity: 0.8;
  }

  100% {
    transform: rotate(45deg) translateX(100%) translateY(100%);
    opacity: 0;
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  #header-profile {
    padding: 8px 0;
  }

  .user-info-container {
    gap: 8px;
    padding: 8px 12px;
  }

  .user-name {
    font-size: 13px;
  }

  .user-level {
    font-size: 11px;
    padding: 1px 4px;
  }

  #header-profile-right {
    gap: 8px;
  }

  .header-nav-link {
    font-size: 13px;
    padding: 4px 8px;
  }

  .header-cart-btn,
  .header-order-btn {
    padding: 6px 12px;
    font-size: 13px;
  }

  .header-cart-btn i,
  .header-order-btn i,
  .header-more-btn i {
    font-size: 14px;
  }
}

@media (max-width: 576px) {
  .user-info-text {
    display: none;
  }

  .user-info-container {
    padding: 6px;
    border-radius: 50%;
  }

  .header-nav-link {
    font-size: 12px;
  }

  .header-cart-btn span,
  .header-order-btn span {
    display: none;
  }

  .header-cart-btn,
  .header-order-btn {
    padding: 8px;
    border-radius: 50%;
    min-width: unset;
  }
}

/* Logo样式 */
.header-nav-Logo a {
  font-size: 24px;
  font-weight: bold;
  color: #1890ff;
  text-decoration: none;
  transition: color 0.3s ease;
}

.header-nav-Logo a:hover {
  color: #40a9ff;
}

/* 搜索框样式 */
.header-nav-search {
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.search-input-container {
  width: 100%;
  display: block;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.search-input-container.search-focused {
  /* box-shadow: 0 4px 16px rgba(255, 80, 0, 0.2); */
}

/* 搜索框整体布局 */
.search-wrapper {
  display: flex;
  align-items: center;
  background-color: #ffffff;
  border: 2px solid #e8e8e8;
  border-radius: 28px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
}

.search-input-container.search-focused .search-wrapper {
  border-color: #ff5000;
  box-shadow: 0 4px 20px rgba(255, 80, 0, 0.2);
  transform: translateY(-1px);
}

/* 搜索类型选择器 */
.search-type-selector {
  padding: 3.5px 16px;
  border-right: 1px solid #e8e8e8;
  background-color: #fafafa;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-radius: 28px 0 0 28px;
}

.search-type-selector:hover {
  background-color: #f5f5f5;
}

.search-type-selector ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 20px;
}

.search-type-item {
  padding: 14px 0;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  user-select: none;
  letter-spacing: 0.5px;
}

.search-type-item:hover {
  color: #ff5000;
  transform: translateY(-1px);
}

.search-type-item.active {
  color: #ff5000;
  font-weight: 600;
}

.search-type-item.active::after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: -10%;
  width: 120%;
  height: 2px;
  background-color: #ff5000;
  border-radius: 1px;
}

/* 从左往右动画 */
.search-type-item.animate-right::after {
  animation: slideInRight 0.3s ease-out;
}

/* 从右往左动画 */
.search-type-item.animate-left::after {
  animation: slideInLeft 0.3s ease-out;
}

/* 从左往右消失动画 */
.search-type-item.animate-right-out::after {
  animation: slideOutRight 0.3s ease-out;
}

/* 从右往左消失动画 */
.search-type-item.animate-left-out::after {
  animation: slideOutLeft 0.3s ease-out;
}

/* 搜索类型选择器从左往右动画 */
@keyframes slideInRight {
  from {
    width: 0;
    left: -10%;
  }

  to {
    width: 120%;
    left: -10%;
  }
}

/* 搜索类型选择器从右往左动画 */
@keyframes slideInLeft {
  from {
    width: 0;
    left: 120%;

  }

  to {
    width: 120%;
    left: -10%;
  }
}

/* 从左往右消失动画 */
@keyframes slideOutRight {
  from {
    width: 120%;
    left: -10%;
  }

  to {
    width: 0;
    left: 200%;
  }
}

/* 从右往左消失动画 */
@keyframes slideOutLeft {
  from {
    width: 100%;
    right: -10%;
  }

  to {
    width: 0%;
    right: -200%;
  }
}

/* 搜索输入区域 */
.search-input-wrapper {
  flex: 1;
  position: relative;
  padding: 0 16px;
  display: flex;
  align-items: center;
}

.search-input-prefix {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 18px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 1;
}

.search-input-container.search-focused .search-input-prefix {
  color: #ff5000;
  transform: translateY(-50%) scale(1.1);
}

.custom-search-input {
  font-size: 16px;
  min-height: 52px;
  height: 52px;
  padding: 0 25px 0 15px;
  border: none;
  box-shadow: none;
  background-color: transparent;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  font-weight: 400;
  letter-spacing: 0.5px;
  box-sizing: border-box;
  /* 关键！ */
  outline: none;
  /* 避免默认焦点轮廓 */
}

/* 可选：焦点状态 */
.custom-search-input:focus {
  background-color: rgba(255, 255, 255, 0.03);
}

.custom-search-input::placeholder {
  color: #ccc;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.3s ease;
}

.custom-search-input:focus {
  border-color: transparent !important;
  box-shadow: none !important;
}

.search-input-container.search-focused .custom-search-input::placeholder {
  color: #ffccb3;
}

.search-input-suffix {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background-color: #f5f5f5;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-50%) scale(0.8);
  }

  to {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

.search-input-suffix:hover {
  color: #ff5000;
  background-color: #fff0e6;
  transform: translateY(-50%) scale(1.1);
}

.search-input-container.search-focused .search-input-suffix {
  color: #ff5000;
}

/* 搜索按钮 */
.search-button-container {
  padding: 16.5px 30px;
  height: 100%;
  background: linear-gradient(135deg, #ff5000, #ff8c00);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  border-radius: 0 28px 28px 0;
}


.search-button-container:active {
  transform: translateX(1px) translateY(0);
  box-shadow: 0 2px 8px rgba(255, 80, 0, 0.3);
}

.search-button-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transform: rotate(45deg);
  animation: shine 2.5s ease-in-out infinite;
}

/* @keyframes shine {
  0% {
    transform: rotate(45deg) translateX(-100%) translateY(-100%);
    opacity: 0;
  }
  50% {
    opacity: 0.8;
  }
  100% {
    transform: rotate(45deg) translateX(100%) translateY(100%);
    opacity: 0;
  }
} */

.search-button-text {
  font-size: 16px;
  font-weight: 600;
  position: relative;
  z-index: 1;
  letter-spacing: 1px;
  transition: all 0.3s ease;
}

.search-button-icon {
  position: relative;
  z-index: 1;
  font-size: 16px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-button-container:hover .search-button-icon {
  transform: scale(1.1) rotate(15deg);
}

.search-button-container:hover .search-button-text {
  transform: translateY(-1px);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .search-type-selector {
    padding: 0 12px;
  }

  .search-type-selector ul {
    gap: 12px;
  }

  .search-type-item {
    padding: 12px 0;
    font-size: 13px;
  }

  .search-input-wrapper {
    padding: 0 12px;
  }

  .custom-search-input {
    font-size: 14px !important;
    height: 48px !important;
    padding: 0 40px 0 40px !important;
  }

  .search-input-prefix {
    font-size: 16px;
  }

  .search-button-container {
    padding: 0 24px;
  }

  .search-button-text {
    font-size: 14px;
  }

  .search-button-icon {
    font-size: 14px;
  }

  .search-button-container:hover .search-button-icon {
    transform: scale(1.05) rotate(10deg);
  }
}

@media (max-width: 576px) {
  .search-type-selector {
    padding: 0 10px;
  }

  .search-type-selector ul {
    gap: 8px;
  }

  .search-type-item {
    font-size: 12px;
  }

  .search-input-wrapper {
    padding: 0 10px;
  }

  .custom-search-input {
    font-size: 13px !important;
    padding: 0 35px 0 35px !important;
  }

  .search-input-prefix {
    font-size: 14px;
  }

  .search-button-container {
    padding: 0 20px;
  }

  .search-button-text {
    font-size: 13px;
  }

  .search-button-icon {
    display: none;
  }
}

/* 搜索历史样式 */
.search-history-container {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  margin-top: 4px;
  background-color: #ffffff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  border: 1px solid #f0f0f0;
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-title {
  font-size: 16px;
  font-weight: 500;
  color: #333;
}

.clear-history {
  font-size: 14px;
  color: #999;
  text-decoration: none;
  transition: color 0.3s ease;
}

.clear-history:hover {
  color: #1890ff;
}

.search-history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-tag {
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  padding: 4px 12px;
  background-color: #f5f5f5;
  border-color: #e8e8e8;
}

.history-tag:hover {
  background-color: #e6f7ff;
  border-color: #91d5ff;
  color: #1890ff;
}

.no-history {
  text-align: center;
  padding: 20px 0;
  color: #999;
  font-size: 14px;
}

/* 商品列表链接样式 */
.header-nav-product a {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  text-decoration: none;
  transition: all 0.3s ease;
  padding: 8px 16px;
  border-radius: 4px;
}

.header-nav-product a:hover {
  color: #1890ff;
  background-color: #e6f7ff;
}
</style>