<template>
  <nav class="bottom-nav">
    <router-link to="/" class="nav-item" :class="{ active: $route.path === '/' }">
      <div class="nav-icon">
        <img :src="$route.path === '/' ? '/assets/bottom/home-1.svg' : '/assets/bottom/home-0.svg'" alt="首页" class="nav-icon-img" />
      </div>
      <div class="nav-text">首页</div>
    </router-link>
    
    <div class="nav-item" @click="handleDiscoveryClick">
      <div class="nav-icon">
        <img src="/assets/bottom/faxian-0.svg" alt="交流" class="nav-icon-img" />
      </div>
      <div class="nav-text">交流</div>
    </div>
    
    <router-link to="/lottery-info" class="nav-item" :class="{ active: $route.path === '/lottery-info' }">
      <div class="nav-icon">
        <img :src="$route.path === '/lottery-info' ? '/assets/bottom/kaijiang-1.svg' : '/assets/bottom/kaijiang-0.svg'" alt="开奖" class="nav-icon-img" />
      </div>
      <div class="nav-text">开奖</div>
    </router-link>
    
    <router-link to="/data-analysis" class="nav-item" :class="{ active: $route.path === '/data-analysis' }">
      <div class="nav-icon">
        <img :src="$route.path === '/data-analysis' ? '/assets/bottom/tuice-1.svg' : '/assets/bottom/tuice-0.svg'" alt="分析" class="nav-icon-img" />
      </div>
      <div class="nav-text">分析</div>
    </router-link>

    <router-link to="/profile" class="nav-item" :class="{ active: $route.path === '/profile' }">
      <div class="nav-icon">
        <img :src="$route.path === '/profile' ? '/assets/bottom/wode-1.svg' : '/assets/bottom/wode-0.svg'" alt="我的" class="nav-icon-img" />
      </div>
      <div class="nav-text">我的</div>
    </router-link>
  </nav>
</template>

<script>
export default {
  name: 'BottomNavigation',
  methods: {
    handleDiscoveryClick() {
      // 触发自定义事件通知父组件
      this.$emit('discovery-click')
    }
  }
}
</script>

<style scoped>
/* 底部导航栏 */
.bottom-nav {
  height: 70px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 1000;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  max-width: 850px;
  width: 100%;
  padding: 0 4px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #999;
  transition: color 0.2s ease, transform 0.15s ease;
  padding: 6px 12px;
  min-width: 60px;
  position: relative;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
  color: var(--color-primary, #e53e3e);
}

.nav-item:hover .nav-icon-img {
  transform: scale(1.08);
}

.nav-item:active {
  transform: scale(0.92);
}

.nav-item.active {
  color: var(--color-primary, #e53e3e);
}

.nav-item.active .nav-icon {
  transform: translateY(-1px);
}

.nav-item.active .nav-text {
  color: var(--color-primary, #e53e3e);
  font-weight: 600;
}

.nav-icon {
  margin-bottom: 4px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.nav-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.nav-text {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  transition: color 0.2s ease;
  line-height: 1;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .bottom-nav {
    height: 65px;
    max-width: 100%;
  }
  
  .nav-item {
    padding: 4px 8px;
    min-width: 55px;
  }
  
  .nav-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 3px;
  }
  
  .nav-icon-img {
    width: 22px;
    height: 22px;
  }
  
  .nav-text {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .bottom-nav {
    height: 60px;
    max-width: 100%;
  }
  
  .nav-item {
    padding: 3px 6px;
    min-width: 50px;
  }
  
  .nav-icon {
    width: 26px;
    height: 26px;
    margin-bottom: 2px;
  }
  
  .nav-icon-img {
    width: 20px;
    height: 20px;
  }
  
  .nav-text {
    font-size: 9px;
  }
}
</style>
