<template>
  <view class="like-income-board">
    <text class="section-title">点赞收益看板</text>

    <!-- 错误/骨架态 -->
    <view v-if="error" class="error-box" @tap="$emit('retry')">
      <text class="error-text">加载失败，点击重试</text>
    </view>
    <view v-else-if="loading || !stats" class="skeleton-board">
      <view class="skeleton-stats"></view>
      <view class="skeleton-list"></view>
    </view>

    <!-- 正常态 -->
    <view v-else class="board-row">
      <!-- 左侧统计 -->
      <view class="left-stats">
        <view class="stat-block">
          <text class="stat-num">{{ stats.total_like_count }}</text>
          <text class="stat-text">累积点赞</text>
        </view>
        <view class="stat-block">
          <text class="stat-num">{{ stats.total_income }}</text>
          <text class="stat-text">累计收益</text>
        </view>
      </view>

      <!-- 右侧等级列表 -->
      <view class="right-list">
        <view
          v-for="(item, idx) in levels"
          :key="idx"
          class="level-row"
        >
          <view class="level-thumb">
            <view class="thumb-circle" :class="`level-${item.level}`">
              <text class="thumb-letter">{{ item.level }}</text>
            </view>
          </view>
          <text class="level-name">{{ item.level }}</text>
          <text class="level-income">{{ item.total_income }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
defineProps({
  stats: { type: Object, default: null }, // { total_like_count, total_income }
  levels: { type: Array, default: () => [] },
  loading: { type: Boolean, default: false },
  error: { type: String, default: null },
})
defineEmits(['retry'])
</script>

<style lang="scss" scoped>
.like-income-board {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border-radius: 22rpx;
  padding: 24rpx;
  margin: 24rpx 0;
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.15);
}

.section-title {
  display: block;
  font-size: 36rpx;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 24rpx;
  text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.3);
}

.board-row {
  display: flex;
  gap: 16rpx;
}

.left-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24rpx;
  padding-right: 16rpx;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-block {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 40rpx;
  font-weight: 700;
  color: #FFFABD;
  font-family: 'Baloo Bhai', sans-serif;
  text-shadow: -1px 1px 4px rgba(206, 9, 9, 0.84);
  margin-bottom: 6rpx;
}

.stat-text {
  font-size: 22rpx;
  color: rgba(255, 255, 255, 0.7);
}

.right-list {
  flex: 1.5;
  display: flex;
  flex-direction: column;
  gap: 12rpx;
}

.level-row {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12rpx;
  padding: 12rpx;
  gap: 16rpx;
}

.level-thumb {
  width: 56rpx;
  height: 56rpx;
  flex-shrink: 0;
}

.thumb-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.thumb-letter {
  font-size: 18rpx;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.level-UR { background: linear-gradient(135deg, #FF8A65 0%, #FFD740 100%); }
.level-SSR { background: linear-gradient(135deg, #FF5E9C 0%, #FFB199 100%); }
.level-SR { background: linear-gradient(135deg, #B17BFF 0%, #FF8FE6 100%); }
.level-R { background: linear-gradient(135deg, #5EDFFF 0%, #6FA9FF 100%); }
.level-N { background: linear-gradient(135deg, #C5C5C5 0%, #8C8C8C 100%); }

.level-name {
  flex: 0 0 60rpx;
  font-size: 22rpx;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.level-income {
  flex: 1;
  font-size: 28rpx;
  font-weight: 700;
  color: #FFFABD;
  font-family: 'Baloo Bhai', sans-serif;
  text-align: right;
}

/* 骨架/错误 */
.skeleton-board {
  display: flex;
  flex-direction: column;
  gap: 16rpx;
}

.skeleton-stats,
.skeleton-list {
  height: 200rpx;
  border-radius: 17rpx;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.error-box {
  height: 240rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 100, 100, 0.15);
  border: 2rpx solid rgba(255, 100, 100, 0.4);
  border-radius: 17rpx;
}

.error-text {
  color: #ff8080;
  font-size: 28rpx;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
</style>
