<template>
  <view class="order-detail-container">
    <!-- 顶部导航栏 -->
    <view class="nav-bar">
      <view class="back" @tap="goBack">
        <uni-icons type="left" size="20" color="#222" />
      </view>
      <text class="nav-title">订单详情</text>
      <view class="nav-icons">
        <!-- <uni-icons type="more" size="24" color="#222" /> -->
      </view>
    </view>

    <view class="main-content">

      <!-- 回收信息卡片（高保真，参考流程卡片） -->
      <view class="info-card process-card">
        <view v-if="order.cancelReason" class="cancel-reason">{{ order.cancelReason }}</view>
        <view class="info-card-header">
          <view class="info-title-wrap">
            <text class="info-title">回收信息</text>
            <view v-if="order.statusText === '不包邮'" class="tag-nobaoyou">不包邮</view>
          </view>
          <view class="status-tag" :class="order.statusClass" style="margin-left:auto;">{{ order.statusLabel }}</view>
        </view>
        <!-- 步骤条（横向卡片式） -->
        <view class="steps-bar">
          <view v-for="(step, idx) in steps" :key="step.text" :class="['step-item', { active: idx === currentStep }]">
            <image :src="step.icon" class="step-icon" />
            <view class="step-label" :class="{ active: idx === currentStep }">
              <text class="step-text">{{ step.text }}</text>
            </view>
          </view>
        </view>
        <!-- 订单基础信息（左对齐，分隔线，按钮、箭头、标签等细节） -->
        <view class="base-info">
          <view v-for="(item, i) in baseInfo" :key="item.label" class="base-info-row"
            :class="{ 'user-stat-trigger': item.label === '用户名' }"
            @tap="item.label === '用户名' ? onUserStatClick() : null">
            <view class="base-label-wrap">
              <text class="base-label">{{ item.label }}</text>
            </view>
            <view class="base-value-wrap">
              <text class="base-value">{{ item.value }}</text>
              <view class="base-actions">
                <text v-if="item.viewLogistics" class="view-logistics-btn"
                  @tap="viewLogistics(item.value, item.expressCompany)">查看物流</text>
                <text v-if="item.copy" class="copy-btn" @tap="copyText(item.value)">复制</text>
              </view>
              <uni-icons v-if="item.arrow" type="right" size="18" color="#bbb" />
            </view>
            <view v-if="i < baseInfo.length - 1" class="divider"></view>
          </view>
        </view>
      </view>

      <!-- 用户统计弹窗 -->
      <view v-if="showUserStatModal" class="user-stat-modal-mask">
        <view class="user-stat-modal-box">
          <view class="user-stat-modal-title">{{ userStatData.name }}</view>
          <view class="user-stat-modal-row">
            <text class="user-stat-label">回收总次数</text>
            <text class="user-stat-value">{{ userStatData.unit_num }}</text>
          </view>
          <view class="user-stat-modal-divider"></view>
          <view class="user-stat-modal-row">
            <text class="user-stat-label">总件数</text>
            <text class="user-stat-value">{{ userStatData.sum }}</text>
          </view>
          <view class="user-stat-modal-divider"></view>
          <view class="user-stat-modal-row">
            <text class="user-stat-label">回收总额</text>
            <text class="user-stat-value">{{ userStatData.order_money }}元</text>
          </view>
          <button class="user-stat-modal-btn" @tap="showUserStatModal = false">我了解了</button>
        </view>
      </view>

      <!-- 订单明细卡片：开始质检状态 -->
      <view v-if="order.status === 2 && order.state === 1" class="info-card detail-card custom-inspect-card">
        <view class="custom-header-bg">
          <view class="custom-card-title">订单详情</view>
        </view>
        <view class="custom-detail-content">
          <!-- 只显示商品明细 -->
          <view v-for="item in order.commonOrderList" :key="item.id" class="custom-goods-row">
            <image :src="item.image" class="custom-goods-img" />
            <view class="custom-goods-info">
              <text class="custom-goods-name">{{ item.title }}</text>
              <text class="custom-goods-desc">{{ item.pinName }}</text>
              <view class="custom-goods-desc" v-if="item.brandName && item.styleName">品牌：{{ item.brandName }} | 款式：{{
                item.styleName }}</view>
              <view class="custom-goods-desc" v-else-if="item.brandName">品牌：{{ item.brandName }}</view>
              <view class="custom-goods-desc" v-else-if="item.styleName">款式：{{ item.styleName }}</view>
              <text class="custom-goods-desc" v-else>{{ item.details }}</text>
              <view class="custom-goods-meta">
                <text class="custom-goods-price" v-if="shouldShowSinglePrice(item.estimatedPrice)">¥{{ item.onePrice
                }}<text class="custom-goods-unit"> /{{ item.unit }}</text></text>
                <text class="custom-goods-price" v-else>¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }}<text
                    class="custom-goods-unit"> /{{ item.unit }}</text></text>
                <text class="custom-goods-count">x{{ item.num }}</text>
              </view>
            </view>
            <text class="custom-goods-total" v-if="shouldShowSinglePrice(item.estimatedPrice)">¥{{
              parseFloat(item.estimatedPrice.split('-')[0]).toFixed(2) }}</text>
            <text class="custom-goods-total" v-else>¥{{ item.estimatedPrice.replace('-', '~') }}</text>
          </view>
        </view>
      </view>

      <!-- 现金打款时展示完整订单详情卡片 -->
      <view v-else-if="order.status === 3" class="info-card detail-card custom-inspect-card">
        <view class="custom-header-bg">
          <view class="custom-card-title">订单详情</view>
        </view>
        <view class="custom-detail-content">
          <view class="custom-detail-row">
            <text class="custom-detail-label">订单编号</text>
            <text class="custom-detail-value">{{ order.ordeNo || order.id }}</text>
          </view>
          <view class="custom-detail-row">
            <text class="custom-detail-label">预估回收</text>
            <text class="custom-detail-value highlight">¥ {{ order.estimatedPrice }}</text>
          </view>
          <view class="custom-detail-row">
            <text class="custom-detail-label">合格结算</text>
            <text class="custom-detail-value highlight">¥ {{ order.price || order.estimate }}</text>
          </view>
          <view class="custom-detail-row">
            <text class="custom-detail-label">运费扣除</text>
            <text class="custom-detail-value">¥ 0</text>
          </view>
          <view class="custom-detail-row total-row">
            <text class="custom-detail-label">结算金额</text>
            <text class="custom-detail-value total highlight">¥ {{ order.price || order.estimate }}</text>
          </view>
          <view class="custom-divider"></view>
          <!-- 商品明细 -->
          <view v-for="item in order.commonOrderList" :key="item.id" class="custom-goods-row">
            <image :src="item.image" class="custom-goods-img" />
            <view class="custom-goods-info">
              <text class="custom-goods-name">{{ item.title }}</text>
              <text class="custom-goods-desc">{{ item.pinName }}</text>
              <view class="custom-goods-desc" v-if="item.brandName && item.styleName">品牌：{{ item.brandName }} | 款式：{{
                item.styleName }}</view>
              <view class="custom-goods-desc" v-else-if="item.brandName">品牌：{{ item.brandName }}</view>
              <view class="custom-goods-desc" v-else-if="item.styleName">款式：{{ item.styleName }}</view>
              <text class="custom-goods-desc" v-else>{{ item.details }}</text>
              <view class="custom-goods-meta">
                <text class="custom-goods-price" v-if="shouldShowSinglePrice(item.estimatedPrice)">¥{{ item.onePrice
                }}<text class="custom-goods-unit"> /{{ item.unit }}</text></text>
                <text class="custom-goods-price" v-else>¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }}<text
                    class="custom-goods-unit"> /{{ item.unit }}</text></text>
                <text class="custom-goods-count">x{{ item.num }}</text>
              </view>
            </view>
            <text class="custom-goods-total" v-if="shouldShowSinglePrice(item.estimatedPrice)">¥{{
              parseFloat(item.estimatedPrice.split('-')[0]).toFixed(2) }}</text>
            <text class="custom-goods-total" v-else>¥{{ item.estimatedPrice.replace('-', '~') }}</text>
          </view>
        </view>
      </view>

      <!-- 质检结果卡片 -->
      <view v-if="order.status === 3" class="inspect-card">
        <view class="inspect-header">
          <text class="inspect-title">质检结果</text>
        </view>
        <view class="inspect-content">
          <view v-for="(item, i) in qcInfo" :key="item.label" class="inspect-row">
            <text class="inspect-label">{{ item.label }}</text>
            <text class="inspect-value">{{ item.value }}</text>
            <view v-if="i < qcInfo.length - 1" class="inspect-divider"></view>
          </view>
          <view class="inspect-btn" @tap="goToInspection">点此查看质检报告详情</view>
        </view>
      </view>

      <!-- 已预约状态下订单详情卡片 -->
      <view v-else-if="order.status === 1 || order.status === 0" class="info-card detail-card custom-inspect-card">
        <view class="custom-header-bg">
          <view class="custom-card-title">订单详情</view>
        </view>
        <view class="custom-detail-content">
          <view class="custom-detail-row">
            <text class="custom-detail-label">预估回收</text>
            <text class="custom-detail-value highlight">¥ {{ order.estimatedPrice }}</text>
          </view>
          <view class="custom-divider"></view>
          <!-- 商品明细 -->
          <view v-for="item in order.commonOrderList" :key="item.id" class="custom-goods-row">
            <image :src="item.image" class="custom-goods-img" />
            <view class="custom-goods-info">
              <text class="custom-goods-name">{{ item.title }}</text>
              <text class="custom-goods-desc">{{ item.pinName }}</text>
              <view class="custom-goods-desc" v-if="item.brandName && item.styleName">品牌：{{ item.brandName }} | 款式：{{
                item.styleName }}</view>
              <view class="custom-goods-desc" v-else-if="item.brandName">品牌：{{ item.brandName }}</view>
              <view class="custom-goods-desc" v-else-if="item.styleName">款式：{{ item.styleName }}</view>
              <text class="custom-goods-desc" v-else>{{ item.details }}</text>
              <view class="custom-goods-meta">
                <text class="custom-goods-price" v-if="shouldShowSinglePrice(item.estimatedPrice)">¥{{ item.onePrice
                }}<text class="custom-goods-unit"> /{{ item.unit }}</text></text>
                <text class="custom-goods-price" v-else>¥{{ getSinglePriceRange(item.estimatedPrice, item.num) }}<text
                    class="custom-goods-unit"> /{{ item.unit }}</text></text>
                <text class="custom-goods-count">x{{ item.num }}</text>
              </view>
            </view>
            <text class="custom-goods-total" v-if="shouldShowSinglePrice(item.estimatedPrice)">¥{{
              parseFloat(item.estimatedPrice.split('-')[0]).toFixed(2) }}</text>
            <text class="custom-goods-total" v-else>¥{{ item.estimatedPrice.replace('-', '~') }}</text>
          </view>
        </view>
      </view>
    </view>

    <!-- 底部操作按钮 -->
    <view v-if="order.status === 0" class="footer-btns">
      <button class="btn-outline" @tap="rejectOrderAction">驳回</button>
      <button class="btn-main" @tap="passOrderAction">通过</button>
    </view>
    <view v-else-if="order.status === 2 && order.state === 1" class="footer-btns">
      <button class="btn-main" @tap="goToInspect">开始质检</button>
    </view>
  </view>
</template>

<script>
import pullRefreshMixin from '../mixins/pullRefreshMixin.js'
export default {
  mixins: [pullRefreshMixin],
  data() {
    return {
      statusBarHeight: 0,
      order: {},
      // 固定4步流程
      steps: [],
      currentStep: 0,
      baseInfo: [],
      qcInfo: [],
      showUserStatModal: false,
      userStatData: { name: '', unit_num: '', sum: '', order_money: '' }
    }
  },
  onLoad(options) {
    this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
    this.getAreaList();
    if (options && options.id) {
      this.fetchOrderDetail(options.id)
    }
  },
  onShow() {
    this.getAreaList()
  },
  methods: {
    async fetchOrderDetail(orderId) {
      this.$api('getOrderDetail', { orderId }, res => {
        if (res && res.code === 200 && res.result) {
          const data = res.result
          this.order = data
          // 步骤条高亮
          this.currentStep = this.getCurrentStep(data.status, data.state)
          // 基础信息
          this.baseInfo = [
            { label: '订单编号', value: data.ordeNo || data.id, copy: true },
            ...(data.wliuNo && data.wliu ? [{ label: '快递单号', value: data.wliuNo, copy: true, viewLogistics: true, expressCompany: data.wliu }] : []),
            { label: '用户名', value: data.name, arrow: true },
            { label: '取件地址', value: (data.address || '') + (data.addressDetail || '') },
            { label: '预约时间', value: data.goTime || data.createTime }
          ]
          // 质检信息（如有）

          let sum = (data.qualifiedNum || 0) + (data.noQualifiedNum || 0) + (data.unrecyclable || 0)

          this.qcInfo = [
            { label: '质检数量', value: sum ? sum + ' 件' : '' },
            { label: '质检合格', value: data.qualifiedNum ? data.qualifiedNum + ' 件' : '' },
            { label: '质量问题', value: data.noQualifiedNum ? data.noQualifiedNum + ' 件' : '' },
            { label: '不可回收', value: data.unrecyclable ? data.unrecyclable + ' 件' : '' }
          ]
        }
      })
    },
    getCurrentStep(status, state) {
      // status: 0=在线预约, 1=快递上门, 2=透明质检, 3=现金打款
      // state: 0=待取件, 1=已取件, 2=已完成, 3=已取消
      if (state == 3) return -1; // 已取消，不高亮任何步骤
      if (status == 0) return 0; // 在线预约
      if (status == 1) return 1; // 快递上门
      if (status == 2) return 2; // 透明质检
      if (status == 3) return 3; // 现金打款
      return 0;
    },
    async onRefresh() {
      if (this.order.id) await this.fetchOrderDetail(this.order.id)
    },
    goBack() {
      uni.navigateBack()
    },
    copyText(text) {
      uni.setClipboardData({ data: text })
    },
    viewLogistics(expressNumber, expressCompany) {
      if (!expressNumber) {
        uni.showToast({ title: '暂无快递单号', icon: 'none' });
        return;
      }
      uni.navigateTo({
        url: `/pages/subcomponent/logistics?wliuNo=${expressNumber}&expressCompany=${expressCompany || ''}`
      });
    },
    maskPhone(phone) {
      if (!phone) return '';
      return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
    },
    goToInspect() {
      const orderData = encodeURIComponent(JSON.stringify(this.order))
      uni.navigateTo({
        url: `/pages/manager/inspect?orderData=${orderData}`
      })
    },
    async onUserStatClick() {
      if (!this.order || !this.order.userId) return;
      this.$api('getUserOrderNum', { userId: this.order.userId }, res => {
        if (res && res.code === 200 && res.result) {
          this.userStatData = {
            name: this.order.name,
            unit_num: res.result.unit_num,
            sum: res.result.sum,
            order_money: res.result.order_money
          }
          this.showUserStatModal = true
        }
      })
    },
    getAreaList() {
      this.$api('getAreaList', {}, (res) => {
        console.log(res, 'getAreaList');
        if (res.code == 200 && Array.isArray(res.result)) {
          // 按sort升序排序
          const sorted = res.result.slice().sort((a, b) => a.sort - b.sort)
          this.steps = sorted.map(item => ({
            // id: item.id,
            icon: item.image,
            text: item.title
          }))
        }
      })
    },
    passOrderAction() {
      if (!this.order.id) return;
      this.$api('passOrder', { orderId: this.order.id }, res => {
        if (res && res.code === 200) {
          uni.showToast({ title: '操作成功', icon: 'success' })
          this.fetchOrderDetail(this.order.id)
        } else {
          uni.showToast({ title: res.msg || '操作失败', icon: 'none' })
        }
      })
    },
    rejectOrderAction() {
      if (!this.order.id) return;
      this.$api('rejectOrder', { orderId: this.order.id }, res => {
        if (res && res.code === 200) {
          uni.showToast({ title: '操作成功', icon: 'success' })
          this.fetchOrderDetail(this.order.id)
        } else {
          uni.showToast({ title: res.msg || '操作失败', icon: 'none' })
        }
      })
    },
    goToInspection() {
      if (!this.order.id) return;
      uni.navigateTo({
        url: `/pages/subcomponent/inspection-report?orderId=${this.order.id}&isSelf=true`
      })
    },
    // 判断是否显示单价格（根据estimatedPrice格式判断）
    shouldShowSinglePrice(estimatedPrice) {
      if (!estimatedPrice || typeof estimatedPrice !== 'string') return true;

      // 解析estimatedPrice，格式如"25-0"或"25-50"
      const parts = estimatedPrice.split('-');
      if (parts.length !== 2) return true;

      const maxPrice = parseFloat(parts[1]);
      return maxPrice === 0;
    },
    // 从总价反推单件价格区间
    getSinglePriceRange(estimatedPrice, quantity) {
      if (!estimatedPrice || typeof estimatedPrice !== 'string' || !quantity) return '';

      // 解析estimatedPrice，格式如"25-50"
      const parts = estimatedPrice.split('-');
      if (parts.length !== 2) return estimatedPrice;

      const minTotal = parseFloat(parts[0]);
      const maxTotal = parseFloat(parts[1]);

      // 反推单件价格
      const minPrice = (minTotal / quantity).toFixed(2);
      const maxPrice = (maxTotal / quantity).toFixed(2);

      return `${minPrice}~${maxPrice}`;
    },
  }
}
</script>

<style lang="scss" scoped>
$order-card-radius: 32px;
$order-card-padding: 40px 28px;

.order-detail-container {
  background: #f8f8f8;
  min-height: 100vh;
  font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.nav-bar {
  display: flex;
  align-items: center;
  height: calc(150rpx + var(--status-bar-height));
  padding: 0 32rpx;
  padding-top: var(--status-bar-height);
  background: #fff;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 999;
  box-sizing: border-box;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);

  .back {
    padding: 20rpx;
    margin-left: -20rpx;
  }

  .nav-title {
    flex: 1;
    text-align: center;
    font-size: 32rpx;
    font-weight: 500;
    color: #222;
  }

  .nav-icons {
    display: flex;
    align-items: center;
    gap: 30px;
  }
}

.main-content {
  margin-top: calc(200rpx + var(--status-bar-height));
  width: 100vw;
  min-width: 0;
  box-sizing: border-box;
  padding: 0 16px 60px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.info-card {
  width: 100%;
  max-width: 375px;
  min-width: 0;
  box-sizing: border-box;
  margin: 0 auto 28px auto;
  padding: 16px 8px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);

  // color: blue;
  &.process-card {
    position: relative;

    .status-tag {
      position: absolute;
      right: 18px;
      top: 18px;
      font-size: 13px;
      border-radius: 12px;
      padding: 2px 10px;
      font-weight: 500;
      background: #e6f9e6;
      color: #1ecb1e;
      height: 22px;
      line-height: 18px;
      display: flex;
      align-items: center;

      &.orange {
        background: #fff7e6;
        color: #ffb400;
        font-size: 14px;
        border-radius: 12px;
        padding: 2px 14px;
        font-weight: 400;
        height: 22px;
        display: flex;
        align-items: center;
      }

      &.gray {
        background: #f5f5f5;
        color: #444;
        font-size: 14px;
        border-radius: 12px;
        padding: 2px 14px;
        font-weight: 400;
        height: 22px;
        display: flex;
        align-items: center;
      }

      &.blue {
        background: #eaf6ff;
        color: #2a9cfb;
        font-size: 14px;
        border-radius: 12px;
        padding: 2px 14px;
        font-weight: 400;
        height: 22px;
        display: flex;
        align-items: center;
      }
    }

    .status-tag.red {
      background: #fff0f0;
      color: #ff4d4f;
    }
  }

  .info-card-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;

    .info-title-wrap {
      display: flex;
      align-items: center;

      .info-title {
        font-size: 18px;
        font-weight: bold;
        color: #222;
      }

      .tag-nobaoyou {
        margin-left: 8px;
        background: #fff0f0;
        color: #ff4d4f;
        font-size: 14px;
        border-radius: 12px;
        padding: 2px 14px;
        font-weight: 400;
        height: 22px;
        display: flex;
        align-items: center;
      }
    }

    .status-tag {
      margin-left: auto;
    }
  }

  .steps-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 24px 0 24px 0;
    gap: 14px;

    .step-item {
      background: #fff8ea;
      border-radius: 16px;
      width: 76px;
      height: 76px;
      display: flex;
      flex-direction: column;
      align-items: center;
      box-shadow: 0 2px 8px rgba(255, 156, 0, 0.04);
      overflow: hidden;
      position: relative;
      transition: all 0.3s ease;

      .step-icon {
        width: 44px;
        height: 44px;
        margin: 6px 0 0 0;
        transition: transform 0.3s ease;
      }

      .step-label {
        width: 100%;
        height: 28px;
        background: transparent;
        position: absolute;
        left: 0;
        bottom: 0;
        border-radius: 0 0 12px 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        overflow: hidden;
        line-height: 1;

        .step-num,
        .step-text {
          font-size: 11px;
          color: #9b9b9b;
          font-weight: 600;
          line-height: 1;
          vertical-align: middle;
          transition: color 0.3s ease;
        }

        .step-num {
          margin-right: 2px;
        }
      }

      &.active {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255, 156, 0, 0.08);

        .step-icon {
          transform: scale(1.05);
        }

        .step-label {
          background: linear-gradient(90deg, #ffd01e 0%, #ff8917 100%);
        }

        .step-num,
        .step-text {
          color: #fff;
          font-weight: bold;
        }
      }

      &:not(.active):hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 12px rgba(255, 156, 0, 0.06);
      }
    }
  }

  .base-info {
    margin-top: 18px;

    .base-info-row {
      display: flex;
      align-items: flex-start;
      padding: 0 0 0 0;
      position: relative;
      min-height: 36px;
      justify-content: space-between;
      align-items: center;

      .base-label-wrap {
        min-width: 80px;
        text-align: left;
        color: #8b8b8b;
        font-size: 13px;
      }

      .base-value-wrap {
        display: flex;
        align-items: center;
        flex: 1;
        justify-content: flex-end;
      }

      .base-value {
        color: #222;
        font-size: 15px;
        font-weight: 600;
        word-break: break-all;
        text-align: right;
      }

      .base-actions {
        display: flex;
        align-items: center;
        gap: 8px;
      }

      .view-logistics-btn {
        color: #2a9cfb;
        font-size: 13px;
        font-weight: 400;
        padding: 1px 6px;
        border-radius: 6px;
        transition: background 0.2s;
      }

      .view-logistics-btn:active {
        background: #eaf6ff;
      }

      .copy-btn {
        color: #ffb400;
        font-size: 13px;
        font-weight: 400;
        padding: 1px 6px;
        border-radius: 6px;
        transition: background 0.2s;
      }

      .copy-btn:active {
        background: #fff7e6;
      }

      .divider {
        position: absolute;
        left: 16px;
        right: 16px;
        bottom: -1px;
        height: 1px;
        background: #f0f0f0;
      }

      uni-icons {
        margin-left: 6px;
      }
    }

    .base-info-row .base-value-wrap {
      flex-wrap: wrap;
    }

    .base-info-row .base-value {
      white-space: pre-line;
      line-height: 1.5;
    }
  }

  &.detail-card {
    position: relative;
    padding: 0;
    background: transparent;

    .card-header-bg {
      height: 56px;
      background: linear-gradient(180deg, #fff7e6 0%, #fff 100%);
      border-radius: 20px 20px 0 0;
      display: flex;
      align-items: flex-end;
      padding-left: 20px;
      padding-top: 12px;
    }

    .detail-content {
      background: #fff;
      border-radius: 0 0 20px 20px;
      padding: 20px 16px 16px 16px;
    }

    .detail-row {
      display: flex;
      align-items: center;
      min-height: 32px;

      .detail-label {
        color: #bcbcbc;
        font-size: 14px;
        width: 90px;
        flex-shrink: 0;
      }

      .detail-value {
        color: #222;
        font-size: 15px;
        font-weight: 500;
        text-align: left;
        margin-left: 0;
        flex: 1;
      }

      &.total-row .detail-value.total {
        color: #ffb400;
        font-size: 20px;
        font-weight: bold;
        text-align: right;
        flex: unset;
        margin-left: auto;
        min-width: 100px;
      }

      .orange {
        color: #ffb400;
      }
    }

    .divider {
      height: 1px;
      background: #f0f0f0;
      margin: 16px 0;
    }

    .goods-row {
      display: flex;
      align-items: flex-start;
      margin-bottom: 18px;
    }

    .goods-img {
      width: 48px;
      height: 48px;
      border-radius: 12px;
      margin-right: 12px;
    }

    .goods-info {
      flex: 1;
    }

    .goods-name {
      font-size: 15px;
      font-weight: bold;
      color: #222;
      margin-bottom: 2px;
    }

    .goods-desc {
      font-size: 13px;
      color: #bbb;
      margin-bottom: 8px;
    }

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

    .goods-price {
      color: #ffb400;
      font-size: 15px;
      font-weight: bold;
      margin-right: 8px;
    }

    .goods-unit {
      font-size: 13px;
      color: #bbb;
    }

    .goods-count {
      color: #bbb;
      font-size: 13px;
      margin-left: 8px;
    }

    .goods-total {
      color: #222;
      font-size: 15px;
      font-weight: bold;
      margin-left: auto;
    }
  }
}

.footer-btns {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  display: flex;
  gap: 16px;
  padding: 16px 24px 32px 24px;
  z-index: 101;

  .btn-outline {
    flex: 1;
    height: 40px;
    border-radius: 16px;
    border: 1px solid #ffe09a;
    color: #ffb400;
    background: #fff0d2;
    font-size: 15px;
    font-weight: 500;
    box-shadow: none;
    padding: 0 18px;
  }

  .btn-main {
    flex: 1;
    height: 40px;
    border-radius: 16px;
    background: linear-gradient(90deg, #ffbe3d 0%, #ffac04 100%);
    color: #fff;
    border: none;
    font-size: 15px;
    font-weight: 500;
    box-shadow: none;
    padding: 0 18px;
  }
}

.cancel-reason {
  color: #bbb;
  font-size: 13px;
  margin-bottom: 10px;
  padding-left: 2px;
}

.inspect-card {
  max-width: 335px;
  width: 100%;
  margin: 0 auto 28px auto;
  border-radius: 24px;
  overflow: hidden;

  .inspect-header {
    height: 60px;
    background: linear-gradient(180deg, #fff7e6 0%, #fffbe6 100%);
    border-radius: 24px 24px 0 0;
    display: flex;
    align-items: flex-end;
    padding-left: 24px;
  }

  .inspect-title {
    font-size: 20px;
    font-weight: bold;
    color: #222;
    line-height: 60px;
  }

  .inspect-content {
    background: #fff;
    border-radius: 0 0 24px 24px;
    padding: 24px 24px 20px 24px;
  }

  .inspect-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;

    .inspect-label {
      color: #bcbcbc;
      font-size: 16px;
    }

    .inspect-value {
      color: #222;
      font-size: 16px;
      font-weight: 500;
    }

    .inspect-divider {
      height: 1px;
      background: #f0f0f0;
      margin: 0;
      width: 100%;
      position: absolute;
      left: 0;
      bottom: 0;
    }

    position: relative;
  }

  .inspect-btn {
    width: 100%;
    margin: 24px 0 0 0;
    height: 48px;
    border-radius: 24px;
    border: 1.5px solid #ffb400;
    color: #ffb400;
    background: #fff0d2;
    font-size: 18px;
    font-weight: 500;
    box-shadow: none;
    text-align: center;
    line-height: 48px;
  }
}

.card-title {
  font-size: 20px;
  font-weight: bold;
  color: #222;
  margin-bottom: 12px;
}

.custom-inspect-card {
  background: linear-gradient(180deg, #fffbe6 0%, #fff 90%);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(255, 156, 0, 0.03);
  padding: 0;
  margin: 24rpx 0 0 0;
  overflow: hidden;
}

.custom-header-bg {
  height: 56px;
  background: linear-gradient(180deg, #fff7e6 0%, #fff 100%);
  border-radius: 20px 20px 0 0;
  display: flex;
  align-items: flex-end;
  padding-left: 24px;
  padding-top: 12px;
}

.custom-card-title {
  font-size: 20px;
  font-weight: bold;
  color: #222;
  margin-bottom: 12px;
}

.custom-detail-content {
  background: #fff;
  border-radius: 0 0 20px 20px;
  padding: 20px 16px 16px 16px;
}

.custom-detail-row {
  display: flex;
  align-items: center;
  min-height: 32px;
  font-size: 15px;

  .custom-detail-label {
    color: #bcbcbc;
    font-size: 14px;
    width: 90px;
    flex-shrink: 0;
  }

  .custom-detail-value {
    color: #222;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    margin-left: 0;
    flex: 1;
  }

  &.total-row .custom-detail-value.total {
    color: #ffb400;
    font-size: 20px;
    font-weight: bold;
    text-align: right;
    flex: unset;
    margin-left: auto;
    min-width: 100px;
  }

  .highlight {
    color: #ffb400;
    font-size: 18px;
    font-weight: bold;
  }
}

.custom-divider {
  width: 100%;
  height: 1px;
  background: #f0f0f0;
  margin: 16px 0;
}

.custom-goods-row {
  background: #fff;
  border-radius: 24px;
  display: flex;
  align-items: center;
  padding: 24px 16px;
  box-shadow: 0 2px 8px rgba(255, 156, 0, 0.04);
  position: relative;
  margin-bottom: 18px;
  min-width: 0;
  flex-wrap: nowrap;
}

.custom-goods-img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin-right: 12px;
  flex-shrink: 0;
}

.custom-goods-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  margin-right: 16px;
}

.custom-goods-name {
  font-size: 15px;
  color: #222;
  font-weight: bold;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-goods-desc {
  font-size: 13px;
  color: #bcbcbc;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  &:last-child {
    margin-bottom: 10px;
  }
}

.custom-goods-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.custom-goods-price {
  color: #ffb400;
  font-size: 15px;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
}

.custom-goods-unit {
  color: #bcbcbc;
  font-size: 13px;
  font-weight: normal;
}

.custom-goods-count {
  color: #bcbcbc;
  font-size: 13px;
  margin-left: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.custom-goods-total {
  color: #222;
  font-size: 15px;
  font-weight: bold;
  margin-left: 12px;
  flex-shrink: 0;
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

.user-stat-modal-mask {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-stat-modal-box {
  width: 80vw;
  max-width: 420px;
  background: linear-gradient(180deg, #fff7f2 0%, #fff 100%);
  border-radius: 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  padding: 38px 0 32px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.user-stat-modal-title {
  font-size: 24px;
  font-weight: bold;
  color: #222;
  text-align: center;
  margin-bottom: 32px;
}

.user-stat-modal-row {
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  margin: 0 auto;
  padding: 12px 0;
}

.user-stat-label {
  color: #999;
  font-size: 16px;
}

.user-stat-value {
  color: #222;
  font-size: 18px;
  font-weight: 500;
}

.user-stat-modal-divider {
  width: 80%;
  height: 1px;
  background: #f0f0f0;
  margin: 0 auto;
}

.user-stat-modal-btn {
  width: 80%;
  margin: 32px auto 0 auto;
  height: 48px;
  border-radius: 24px;
  background: #fffbe6;
  color: #ffb400;
  font-size: 20px;
  font-weight: bold;
  border: 2px solid #ffd01e;
  text-align: center;
  line-height: 48px;
}

.user-stat-trigger {
  color: #222;
  font-weight: 500;
  cursor: pointer;
}
</style>