<template>
  <view class="store-cart-skeleton">
    <!-- 标题区域 -->
    <view class="title-section">
      <view class="title-skeleton skeleton-item"></view>
    </view>

    <!-- 商品列表 -->
    <view class="cart-items-section">
      <template v-for="i in 5" :key="i">
        <view class="cart-item-skeleton">
          <!-- 商品图片 -->
          <view class="item-image-skeleton skeleton-item"></view>

          <!-- 商品信息 -->
          <view class="item-info">
            <view class="item-name-skeleton skeleton-item"></view>
            <view class="item-specs-skeleton skeleton-item"></view>
            <view class="price-row">
              <view class="current-price-skeleton skeleton-item"></view>
              <view class="original-price-skeleton skeleton-item"></view>
              <view class="member-price-skeleton skeleton-item"></view>
            </view>
          </view>

          <!-- 数量控制 -->
          <view class="quantity-control-skeleton skeleton-item"></view>
        </view>
      </template>
    </view>

    <!-- 添加商品按钮 -->
    <view class="add-items-section">
      <view class="add-items-btn-skeleton skeleton-item"></view>
    </view>

    <!-- 分隔线 -->
    <view class="divider-skeleton skeleton-item"></view>

    <!-- 选项备注工具 -->
    <view class="options-section">
      <!-- 餐具选项 -->
      <view class="utensils-option">
        <view class="option-icon-skeleton skeleton-item"></view>
        <view class="option-text-skeleton skeleton-item"></view>
        <view class="option-toggle-skeleton skeleton-item"></view>
      </view>
    </view>

    <!-- 底部结算栏 -->
    <view class="checkout-bar">
      <!-- 会员优惠提示 -->
      <view class="member-discount-skeleton skeleton-item"></view>

      <!-- 结算信息 -->
      <view class="checkout-info">
        <view class="total-price-section">
          <view class="total-label-skeleton skeleton-item"></view>
          <view class="total-amount-skeleton skeleton-item"></view>
        </view>
        <view class="checkout-btn-skeleton skeleton-item"></view>
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
// 骨架屏组件
</script>

<style scoped lang="scss">
// 通用骨架屏样式
.skeleton-item {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

// 闪烁动画
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.store-cart-skeleton {
  background-color: #fff;
  min-height: 100vh;
  position: relative;
}

// 导航栏区域
.navbar-skeleton {
  height: 88rpx;
  width: 100%;
}

// 标题区域
.title-section {
  padding: 20rpx 30rpx 22rpx;

  .title-skeleton {
    width: 300rpx;
    height: 46rpx;
    border-radius: 8rpx;
  }
}

// 商品列表
.cart-items-section {
  .cart-item-skeleton {
    padding: 32rpx 30rpx;
    display: flex;
    align-items: center;
    border-bottom: 1rpx solid #F2F2F2;

    // 商品图片
    .item-image-skeleton {
      width: 136rpx;
      height: 136rpx;
      border-radius: 16rpx;
      flex-shrink: 0;
    }

    // 商品信息
    .item-info {
      margin-left: 20rpx;
      flex: 1;

      .item-name-skeleton {
        width: 200rpx;
        height: 30rpx;
        border-radius: 6rpx;
        margin-bottom: 20rpx;
      }

      .item-specs-skeleton {
        width: 250rpx;
        height: 24rpx;
        border-radius: 6rpx;
        margin-bottom: 18rpx;
      }

      .price-row {
        display: flex;
        align-items: center;

        .current-price-skeleton {
          width: 80rpx;
          height: 30rpx;
          border-radius: 6rpx;
        }

        .original-price-skeleton {
          width: 70rpx;
          height: 24rpx;
          border-radius: 6rpx;
          margin-left: 10rpx;
        }

        .member-price-skeleton {
          width: 170rpx;
          height: 28rpx;
          border-radius: 14rpx;
          margin-left: 10rpx;
        }
      }
    }

    // 数量控制
    .quantity-control-skeleton {
      width: 160rpx;
      height: 56rpx;
      border-radius: 32rpx;
    }
  }
}

// 添加商品按钮
.add-items-section {
  height: 148rpx;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 30rpx;

  .add-items-btn-skeleton {
    width: 212rpx;
    height: 64rpx;
    border-radius: 64rpx;
  }
}

// 分隔线
.divider-skeleton {
  height: 10rpx;
  width: 100%;
}

// 选项备注工具
.options-section {
  padding: 52rpx 30rpx 72rpx;

  // 餐具选项
  .utensils-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 52rpx;

    .option-icon-skeleton {
      width: 44rpx;
      height: 44rpx;
      border-radius: 22rpx;
    }

    .option-text-skeleton {
      width: 250rpx;
      height: 32rpx;
      border-radius: 6rpx;
      margin-left: 28rpx;
      margin-right: auto;
    }

    .option-toggle-skeleton {
      width: 44rpx;
      height: 44rpx;
      border-radius: 22rpx;
    }
  }

  // 添加备注
  .note-option {
    .option-icon-skeleton {
      width: 44rpx;
      height: 44rpx;
      border-radius: 22rpx;
      margin-right: 28rpx;
      display: inline-block;
      vertical-align: middle;
    }

    .option-text-skeleton {
      width: 150rpx;
      height: 32rpx;
      border-radius: 6rpx;
      display: inline-block;
      vertical-align: middle;
      margin-bottom: 24rpx;
    }

    .note-textarea-skeleton {
      margin-left: 72rpx;
      height: 180rpx;
      border-radius: 20rpx;
    }
  }
}

// 底部结算栏
.checkout-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 204rpx;

  // 会员优惠提示
  .member-discount-skeleton {
    height: 76rpx;
    width: 100%;
    border-radius: 0;
  }

  // 结算信息
  .checkout-info {
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18rpx 30rpx 0;

    .total-price-section {
      .total-label-skeleton {
        width: 120rpx;
        height: 30rpx;
        border-radius: 6rpx;
        margin-bottom: 8rpx;
      }

      .total-amount-skeleton {
        width: 100rpx;
        height: 36rpx;
        border-radius: 6rpx;
      }
    }

    .checkout-btn-skeleton {
      width: 360rpx;
      height: 92rpx;
      border-radius: 16rpx;
    }
  }
}

// 响应式设计
@media (max-width: 750rpx) {
  .cart-items-section {
    .cart-item-skeleton {
      .item-info {
        .price-row {
          flex-wrap: wrap;
        }
      }
    }
  }
}
</style>