<template>
  <view v-if="loading" class="loading-state">
    <view class="loading-dot"></view>
    <view class="loading-dot"></view>
    <view class="loading-dot"></view>
  </view>

  <view v-else-if="empty" class="empty-state">
    <view class="empty-card">
      <image class="empty-image tui-skeleton-rect" :src="emptyImage" mode="aspectFit"></image>
      <text class="empty-title tui-skeleton-rect">还没有消息</text>
      <text class="empty-text tui-skeleton-rect">{{ emptyText }}</text>
    </view>
  </view>

  <view v-else-if="noMore" class="no-more">
    <view class="no-more-line"></view>
    <text class="no-more-text">{{ noMoreText }}</text>
    <view class="no-more-line"></view>
  </view>
</template>

<script setup lang="ts">
defineProps({
  loading: {
    type: Boolean,
    default: false,
  },
  empty: {
    type: Boolean,
    default: false,
  },
  noMore: {
    type: Boolean,
    default: false,
  },
  emptyImage: {
    type: String,
    required: true,
  },
  emptyText: {
    type: String,
    default: "暂无短信",
  },
  noMoreText: {
    type: String,
    default: "已经到底了",
  },
});
</script>

<style scoped lang="scss">
.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 42rpx 0;
  height: 42rpx;
}

.loading-dot {
  width: 14rpx;
  height: 14rpx;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff92b6, #8bcfff);
  margin: 0 7rpx;
  animation: loadingDot 1.4s infinite ease-in-out both;

  &:nth-child(1) {
    animation-delay: -0.32s;
  }

  &:nth-child(2) {
    animation-delay: -0.16s;
  }
}

@keyframes loadingDot {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 70rpx 24rpx;
  min-height: 58vh;
}

.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  padding: 58rpx 34rpx 62rpx;
  border-radius: 28rpx;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(247, 252, 255, 0.74)),
    rgba(255, 255, 255, 0.72);
  border: 1rpx solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 18rpx 42rpx rgba(93, 107, 139, 0.08);
}

.empty-image {
  width: 330rpx;
  height: 230rpx;
  margin-bottom: 24rpx;
  opacity: 0.86;
}

.empty-title {
  color: #263044;
  font-size: 32rpx;
  font-weight: 700;
  line-height: 1.4;
}

.empty-text {
  margin-top: 8rpx;
  font-size: 24rpx;
  color: #8c96a8;
  text-align: center;
  line-height: 1.5;
}

.no-more {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24rpx 0 34rpx;
}

.no-more-line {
  height: 1rpx;
  width: 120rpx;
  background: linear-gradient(90deg, transparent, rgba(153, 170, 190, 0.35));

  &:last-child {
    background: linear-gradient(90deg, rgba(153, 170, 190, 0.35), transparent);
  }
}

.no-more-text {
  color: #9aa3b2;
  font-size: 22rpx;
  margin: 0 18rpx;
}
</style>
