<template>
  <div v-show="visible" class="summary-dashboard">
    <topBar
      v-if="topList.length > 0 && userInfo.userType != 9"
      :top-list="topList"
      :moren="defaultTabItem"
      :wait-approval-num="waitApprovalNum"
      :receive-approval-num="receiveApprovalNum"
    />
    <div class="dashboard-cards">
      <!-- 会员数据卡片 -->
      <div class="dashboard-card-group">
        <div class="dashboard-card-title">会员数据</div>
        <div class="dashboard-card-list">
          <!-- <div class="dashboard-card">
            <div class="dashboard-card-label">会员总数</div>
            <div class="dashboard-card-value">{{ memberSummary.memberTotal || 0 }}</div>
          </div> -->
          <div class="dashboard-card dashboard-card--member dashboard-card--month-member">
            <div class="dashboard-card-header">
              <div class="dashboard-card-label">当月新增会员</div>
              <div class="dashboard-card-value">{{ memberSummary.memberMonth || 0 }}</div>
            </div>
            <div v-if="memberSummary.memberMonthLevelList && memberSummary.memberMonthLevelList.length > 0" class="dashboard-card-level-list">
              <div v-for="level in memberSummary.memberMonthLevelList" :key="`month-${level.gradeName}`" class="dashboard-card-level-item">
                <span class="level-name">{{ level.gradeName }}:</span>
                <span class="level-count">{{ level.memberTotal }}人</span>
              </div>
            </div>
          </div>
          <div class="dashboard-card dashboard-card--member dashboard-card--yesterday-member">
            <div class="dashboard-card-header">
              <div class="dashboard-card-label">昨日新增会员</div>
              <div class="dashboard-card-value">{{ memberSummary.memberYesterday || 0 }}</div>
            </div>
            <div v-if="memberSummary.memberYesterdayLevelList && memberSummary.memberYesterdayLevelList.length > 0" class="dashboard-card-level-list">
              <div v-for="level in memberSummary.memberYesterdayLevelList" :key="`yesterday-${level.gradeName}`" class="dashboard-card-level-item">
                <span class="level-name">{{ level.gradeName }}:</span>
                <span class="level-count">{{ level.memberTotal }}人</span>
              </div>
            </div>
          </div>
          <div class="dashboard-card dashboard-card--member dashboard-card--today-member">
            <div class="dashboard-card-header">
              <div class="dashboard-card-label">今日新增会员</div>
              <div class="dashboard-card-value">{{ memberSummary.memberToday || 0 }}</div>
            </div>
            <div v-if="memberSummary.memberTodayLevelList && memberSummary.memberTodayLevelList.length > 0" class="dashboard-card-level-list">
              <div v-for="level in memberSummary.memberTodayLevelList" :key="`today-${level.gradeName}`" class="dashboard-card-level-item">
                <span class="level-name">{{ level.gradeName }}:</span>
                <span class="level-count">{{ level.memberTotal }}人</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 业绩数据卡片 (统一结构) -->
      <div class="dashboard-card-group dashboard-card-group--performance-overview">
        <div class="dashboard-card-title">新增业绩</div>
        <div class="performance-overview-container">
          <!-- 本月业绩 -->
          <div class="performance-section performance-section--month">
            <div class="performance-section-title performance-section-title--month">本月数据</div>
            <div class="performance-summary-header">
              <span class="performance-summary-label">总金额</span>
              <span class="performance-summary-value">{{ getSum(monthlyPerformance.firstAmount, monthlyPerformance.repAmount) }}</span>
            </div>
            <div class="performance-details-list">
              <div class="performance-detail-item">
                <span class="detail-label">首购金额:</span>
                <span class="detail-value">{{ monthlyPerformance.firstAmount || '0.00' }}</span>
              </div>
              <div class="performance-detail-item">
                <span class="detail-label">复购金额:</span>
                <span class="detail-value">{{ monthlyPerformance.repAmount || '0.00' }}</span>
              </div>
            </div>
          </div>
          <!-- 昨日业绩 -->
          <div class="performance-section performance-section--yesterday">
            <div class="performance-section-title performance-section-title--yesterday">昨日数据</div>
            <div class="performance-summary-header">
              <span class="performance-summary-label">总金额</span>
              <span class="performance-summary-value">{{ getSum(dailyPerformance.yesterday && dailyPerformance.yesterday.firstAmount, dailyPerformance.yesterday && dailyPerformance.yesterday.repAmount) }}</span>
            </div>
            <div class="performance-details-list">
              <div class="performance-detail-item">
                <span class="detail-label">首购金额:</span>
                <span class="detail-value">{{ dailyPerformance.yesterday && dailyPerformance.yesterday.firstAmount || '0.00' }}</span>
              </div>
              <div class="performance-detail-item">
                <span class="detail-label">复购金额:</span>
                <span class="detail-value">{{ dailyPerformance.yesterday && dailyPerformance.yesterday.repAmount || '0.00' }}</span>
              </div>
            </div>
          </div>
          <!-- 今日业绩 -->
          <div class="performance-section performance-section--today">
            <div class="performance-section-title performance-section-title--today">今日数据</div>
            <div class="performance-summary-header">
              <span class="performance-summary-label">总金额</span>
              <span class="performance-summary-value">{{ getSum(dailyPerformance.today && dailyPerformance.today.firstAmount, dailyPerformance.today && dailyPerformance.today.repAmount) }}</span>
            </div>
            <div class="performance-details-list">
              <div class="performance-detail-item">
                <span class="detail-label">首购金额:</span>
                <span class="detail-value">{{ dailyPerformance.today && dailyPerformance.today.firstAmount || '0.00' }}</span>
              </div>
              <div class="performance-detail-item">
                <span class="detail-label">复购金额:</span>
                <span class="detail-value">{{ dailyPerformance.today && dailyPerformance.today.repAmount || '0.00' }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 充值汇总模块 -->
      <div class="dashboard-card-group dashboard-card-group--recharge-summary">
        <div class="dashboard-card-title">充值汇总</div>
        <div class="recharge-summary-container">
          <!-- 本月充值 -->
          <div class="recharge-section recharge-section--month">
            <div class="recharge-section-title recharge-section-title--month">本月充值</div>
            <ul v-if="rechargeSummary.rechargeMonthLevelList && rechargeSummary.rechargeMonthLevelList.length > 0" class="recharge-account-list">
              <li v-for="account in rechargeSummary.rechargeMonthLevelList" :key="`month-recharge-${account.accountName}`" class="recharge-account-item">
                <span class="account-name">{{ account.accountName }}</span>
                <span class="account-amount">{{ formatAmountWithCommas(account.rechargeAmount) }}</span>
              </li>
            </ul>
            <div v-else class="no-data-placeholder">暂无数据</div>
          </div>
          <!-- 昨日充值 -->
          <div class="recharge-section recharge-section--yesterday">
            <div class="recharge-section-title recharge-section-title--yesterday">昨日充值</div>
            <ul v-if="rechargeSummary.rechargeYesterdayLevelList && rechargeSummary.rechargeYesterdayLevelList.length > 0" class="recharge-account-list">
              <li v-for="account in rechargeSummary.rechargeYesterdayLevelList" :key="`yesterday-recharge-${account.accountName}`" class="recharge-account-item">
                <span class="account-name">{{ account.accountName }}</span>
                <span class="account-amount">{{ formatAmountWithCommas(account.rechargeAmount) }}</span>
              </li>
            </ul>
            <div v-else class="no-data-placeholder">暂无数据</div>
          </div>
          <!-- 今日充值 -->
          <div class="recharge-section recharge-section--today">
            <div class="recharge-section-title recharge-section-title--today">今日充值</div>
            <ul v-if="rechargeSummary.rechargeTodayList && rechargeSummary.rechargeTodayList.length > 0" class="recharge-account-list">
              <li v-for="account in rechargeSummary.rechargeTodayList" :key="`today-recharge-${account.accountName}`" class="recharge-account-item">
                <span class="account-name">{{ account.accountName }}</span>
                <span class="account-amount">{{ formatAmountWithCommas(account.rechargeAmount) }}</span>
              </li>
            </ul>
            <div v-else class="no-data-placeholder">暂无数据</div>
          </div>
        </div>
      </div>

    </div>
  </div>
</template>

<script>
import topBarMixin from './mixins/top-bar-mixin'
import topBar from '@/components/topBar'
import { getMemberSummary, getRechargeSummary, getDailyPerformance, getMonthlyPerformance } from '@/api/dashboard'
export default {
  name: 'SummaryDashboard',
  components: {
    topBar
  },
  mixins: [topBarMixin],
  data() {
    return {
      memberSummary: {},
      dailyPerformance: {},
      monthlyPerformance: {},
      rechargeSummary: {},
      defaultTabItem: 'summaryDashboard',
      userInfo: {},
      visible: false
    }
  },
  mounted() {
    this.getRoles().then(() => {
      this.visible = true
      this.getMemberSummary()
      this.getDailyPerformance()
      this.getMonthlyPerformance()
      this.getApprovalStatus()
      this.getRechargeSummary()
      this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
    })
  },
  methods: {
    getMemberSummary() {
      getMemberSummary().then(res => {
        this.memberSummary = res.data
      })
    },
    getDailyPerformance() {
      getDailyPerformance().then(res => {
        this.dailyPerformance = res.data
      })
    },
    getMonthlyPerformance() {
      getMonthlyPerformance().then(res => {
        this.monthlyPerformance = res.data
      })
    },

    getRechargeSummary() {
      console.log('getRechargeSummary')
      getRechargeSummary().then(res => {
        console.log('getRechargeSummary', res)
        this.rechargeSummary = res.data
      })
    },
    getSum(a, b) {
      const numA = parseFloat(a) || 0
      const numB = parseFloat(b) || 0
      const sum = numA + numB
      // 直接截取两位小数，不四舍五入
      const truncatedSum = Math.floor(sum * 100) / 100
      // 格式化为两位小数的字符串
      let result = truncatedSum.toString()
      const decimalIndex = result.indexOf('.')
      if (decimalIndex === -1) {
        result += '.00'
      } else {
        const decimalPart = result.substring(decimalIndex + 1)
        if (decimalPart.length === 1) {
          result += '0'
        }
      }
      return result
    },
    formatAmountWithCommas(value) {
      const number = parseFloat(value)
      if (isNaN(number)) {
        return '0'
      }
      return number.toLocaleString('en-US')
    }
  }
}
</script>

<style lang="scss" scoped>
.summary-dashboard {
  padding: 20px;
  background: #f9f9f9;
  font-size: 14px;
}
.dashboard-cards {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.dashboard-card-group {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.06);
  padding: 18px 24px 18px 24px;
}

/* 基础分组标题样式 */
.dashboard-card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px; /* 统一标题下边距 */
  color: #333333; /* 默认标题颜色 */
}

/* 统一业绩分组标题样式 - 继承基础并扩展 */
.dashboard-card-group--today .dashboard-card-title,
.dashboard-card-group--yesterday .dashboard-card-title,
.dashboard-card-group--month .dashboard-card-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-left: 12px;
  position: relative;
}

/* 业绩分组标题左侧装饰线 */
.dashboard-card-group--today .dashboard-card-title::before,
.dashboard-card-group--yesterday .dashboard-card-title::before,
.dashboard-card-group--month .dashboard-card-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 18px; /* 调整装饰线高度 */
  border-radius: 2px;
}

.dashboard-card-group--today .dashboard-card-title {
  color: #357ae8;
  /* font-size, font-weight, margin-bottom will be inherited from .dashboard-card-title */
}
.dashboard-card-group--today .dashboard-card-title::before {
  background-color: #357ae8;
}

.dashboard-card-group--yesterday .dashboard-card-title {
  color: #f59e0b; /* 昨日标题颜色 - 暖黄色 */
  /* font-size, font-weight, margin-bottom will be inherited */
}
.dashboard-card-group--yesterday .dashboard-card-title::before {
  background-color: #f59e0b;
}

.dashboard-card-group--month .dashboard-card-title {
  color: #10b981; /* 本月标题颜色 - 绿色 */
  /* font-size, font-weight, margin-bottom will be inherited */
}
.dashboard-card-group--month .dashboard-card-title::before {
  background-color: #10b981;
  transition: all 0.3s ease;
}

.dashboard-card-list {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.dashboard-card {
  flex: 1 1 240px;
  min-width: 220px;
  background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
  border-radius: 10px;
  box-shadow: 0 1px 6px 0 rgba(253,160,133,0.12);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: all 0.3s ease;
}
.dashboard-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px 0 rgba(253,160,133,0.2);
  /* 会员卡片样式不变 */
}

.dashboard-card-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}
.dashboard-card-value {
  font-size: 28px;
  font-weight: bold;
  color: #222;
}

/* 业绩卡片专属基础样式 */
.dashboard-card--performance {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  flex: 1 1 240px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04); /* 更精致的阴影 */
  transition: all 0.3s ease-in-out;
  position: relative; /* 用于内部绝对定位元素（如有） */
}

.dashboard-card--performance:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.07);
}

.dashboard-card--performance .dashboard-card-label {
  font-size: 14px; /* 标签字号略微增大以保持清晰 */
  color: #4b5563; /* 标签颜色调整，更柔和 */
  margin-bottom: 12px;
}

.dashboard-card--performance .dashboard-card-value {
  font-size: 24px; /* 基础数值字号 */
  font-weight: 700; /* 加粗数值 */
  color: #111827; /* 深色数值，对比度高 */
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  line-height: 1.2; /* 改善行高 */
}

.dashboard-card--performance .dashboard-card-value::after {
  /* content: '¥'; */ /* 去掉人民币符号 */
  font-size: 13px; /* 货币符号大小 */
  font-weight: 500;
  color: #374151; /* 货币符号颜色 */
  margin-left: 4px;
}

/* 今日业绩卡片特殊样式 */
.dashboard-card--today.dashboard-card--performance {
  background: linear-gradient(135deg, #a7d7f9 0%, #7fb2eb 100%); /* 更明显的蓝天到海洋蓝渐变 */
  border-left: 5px solid #357ae8; /* 标题蓝色 */
  border-color: transparent; /* 其他边框透明，突出左边框 */
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-top-left-radius: 0; /* 配合左边框 */
  border-bottom-left-radius: 0; /* 配合左边框 */
}

.dashboard-card--today.dashboard-card--performance .dashboard-card-label {
  color: #2c5282; /* 深蓝标签，配合主色 */
  font-weight: 500;
}

.dashboard-card--today.dashboard-card--performance .dashboard-card-value {
  color: #1e3a8a; /* 更深的蓝，突出数值 */
  font-size: 28px; /* 今日数值更大 */
}

/* 昨日业绩卡片 */
.dashboard-card--yesterday.dashboard-card--performance {
  background: linear-gradient(135deg, #fde68a 0%, #f5c767 100%); /* 更明显的阳光黄到橘黄渐变 */
  border-left: 5px solid #f59e0b; /* 标题黄色 */
  border-color: transparent;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.dashboard-card--yesterday.dashboard-card--performance .dashboard-card-label {
  color: #b45309; /* 深黄/橙色标签 */
}
.dashboard-card--yesterday.dashboard-card--performance .dashboard-card-value {
  color: #78350f; /* 深橙/棕色数值 */
}

/* 本月业绩卡片 */
.dashboard-card--month.dashboard-card--performance {
  background: linear-gradient(135deg, #a7f3d0 0%, #79d7b5 100%); /* 更明显的薄荷绿到青绿渐变 */
  border-left: 5px solid #10b981; /* 标题绿色 */
  border-color: transparent;
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.dashboard-card--month.dashboard-card--performance .dashboard-card-label {
  color: #047857; /* 深绿色标签 */
}
.dashboard-card--month.dashboard-card--performance .dashboard-card-value {
  color: #065f46; /* 更深的绿色数值 */
}

/* 总计行特定样式 */
.dashboard-total-row {
  display: flex;
  gap: 24px; /* 与 .dashboard-card-list 的 gap 保持一致或按需调整 */
  width: 100%; /* 占据整行宽度 */
}

.dashboard-total-row .dashboard-card--performance {
  flex: 1 1 0; /* 让两个卡片均分空间 */
  /* 覆盖一些基础卡片样式，如果需要更紧凑 */
  min-width: 0; /* 允许卡片收缩 */
}

/* 特定对齐调整：确保总金额与金额对齐，总业绩与业绩对齐 */
/* 由于业绩卡片内部已经是 flex-start，主要依赖卡片宽度和内部padding */
/* 如果需要更精确的对齐，可能需要对 .dashboard-card-value 和 .dashboard-card-label 进行微调 */

.dashboard-card--total-amount .dashboard-card-value,
.dashboard-card--total-achievement .dashboard-card-value {
  /* 如果希望文本部分左对齐以模拟效果，可以尝试 */
  /* justify-content: flex-start; */
  /* padding-left: 你可能需要根据实际视觉效果计算一个值 */
}

@media (max-width: 900px) {
  .dashboard-card-list {
    gap: 16px;
  }
  .dashboard-card, .dashboard-card--performance {
    min-width: unset;
    width: 100%;
  }
  .dashboard-card--performance .dashboard-card-value {
    font-size: 22px;
  }
  .dashboard-card--today.dashboard-card--performance .dashboard-card-value {
    font-size: 26px;
  }
}

/* 特定会员卡片基础样式调整 */
.dashboard-card--member {
  background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%); /* 淡紫色到淡蓝色渐变 */
  padding: 16px;
  justify-content: flex-start; /* 内容从顶部开始排列 */
}

.dashboard-card--member .dashboard-card-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.dashboard-card--member .dashboard-card-label {
  color: #4a5568; /* 标签颜色变深一些 */
  font-size: 15px;
  font-weight: 500;
}

.dashboard-card--member .dashboard-card-value {
  color: #2d3748; /* 数值颜色更深 */
  font-size: 26px;
}

.dashboard-card-level-list {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 强制每行展示两个 */
  gap: 8px; /* 等级之间的间隙 */
  margin-top: 8px;
  padding: 8px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
}

.dashboard-card-level-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
  font-size: 13px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.dashboard-card-level-item .level-name {
  color: #555;
  font-weight: 500;
}

.dashboard-card-level-item .level-count {
  color: #333;
  font-weight: bold;
  margin-left: 4px;
}

/* 当月会员卡片 - 最高优先级 */
.dashboard-card--month-member {
  background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); /* 恢复原有的橙色渐变，更醒目 */
  order: 3; /* 通过flex order调整顺序，如果父级是flex */
  /* 或者通过更强的视觉样式，如边框、阴影 */
  box-shadow: 0 6px 15px 0 rgba(253,160,133,0.3);
  transform: scale(1.02); /* 轻微放大 */
}
.dashboard-card--month-member .dashboard-card-label {
  color: #764d16;
}
.dashboard-card--month-member .dashboard-card-value {
  color: #c05621;
  font-size: 28px; /* 强调 */
}
.dashboard-card--month-member .dashboard-card-level-list {
  background-color: rgba(255, 235, 205, 0.3); /* 淡橙色背景 */
}
.dashboard-card--month-member .dashboard-card-level-item .level-name {
  color: #8c5a1e;
}
.dashboard-card--month-member .dashboard-card-level-item .level-count {
  color: #7b341e;
}

/* 昨日会员卡片 - 中等优先级 */
.dashboard-card--yesterday-member {
  background: linear-gradient(135deg, #a8d8ea 0%, #7ea7d8 100%); /* 清爽的蓝绿色渐变 */
  order: 2;
  box-shadow: 0 4px 10px 0 rgba(126,167,216,0.25);
}
.dashboard-card--yesterday-member .dashboard-card-label {
  color: #2c5282;
}
.dashboard-card--yesterday-member .dashboard-card-value {
  color: #1e3a8a;
}
.dashboard-card--yesterday-member .dashboard-card-level-list {
  background-color: rgba(200, 220, 240, 0.3);
}

/* 今日会员卡片 - 普通优先级 */
.dashboard-card--today-member {
  background: linear-gradient(135deg, #c3dae6 0%, #a4c1d2 100%); /* 柔和的灰蓝色 */
  order: 1;
  box-shadow: 0 2px 8px 0 rgba(164,193,210,0.2);
}
.dashboard-card--today-member .dashboard-card-label {
  color: #3a5068;
}
.dashboard-card--today-member .dashboard-card-value {
  color: #2a3f54;
}

/* 移除旧的独立业绩卡片组和卡片样式 */
.dashboard-card-group--performance-month,
.dashboard-card-group--performance-yesterday,
.dashboard-card-group--performance-today,
.dashboard-card--month-performance,
.dashboard-card--yesterday-performance,
.dashboard-card--today-performance {
  /* 这些样式将被新的统一业绩模块样式取代 */
  /* 可以安全地注释或删除，这里暂时保留为空，方便对比 */
}

/* 统一业绩总览模块样式 */
.dashboard-card-group--performance-overview {
  background: #fff; /* 统一的白色背景，保持干净 */
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.07);
  // padding: 24px 32px 24px 32px;
  order: 4; /* 确保在会员数据之后 */
}

.performance-overview-container {
  display: flex;
  gap: 20px; /* 各业绩区块之间的间距 */
  flex-wrap: wrap; /* 允许换行，以适应不同屏幕 */
}

.performance-section {
  flex: 1 1 300px; /* 基础弹性大小，允许增长和收缩，最小宽度300px */
  padding: 20px;
  border-radius: 10px;
  transition: all 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  gap: 15px; /* 内部元素间距 */
  border: 1px solid #e5e7eb; /* 默认边框 */
}

.performance-section:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.performance-section-title {
  font-size: 17px;
  font-weight: 600;
  padding-bottom: 10px;
  border-bottom: 2px solid transparent; /* 默认透明，由具体区块设置颜色 */
  text-align: center;
  margin-bottom: 5px; /* 减少与下方总金额的间距 */
}

.performance-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline; /* 金额与标签基线对齐 */
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.05); /* 保持细分隔线 */
}

.performance-summary-label {
  font-size: 15px; /* 略微减小标签字号 */
  font-weight: 500; /* 降低字重 */
  color: #4a5568; /* 默认标签颜色，会被特定区块覆盖 */
}

.performance-summary-value {
  font-size: 28px; /* 保持数值突出 */
  font-weight: bold;
  /* 颜色由各区块定义 */
}

.performance-details-list {
  display: flex; /* 改为 flex 方便控制子项 */
  flex-direction: column; /* 垂直排列 */
  gap: 8px; /* 详情项之间的间距调整 */
}

.performance-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0px; /* 调整上下内边距，左右由父级或全局控制 */
  font-size: 14px;
  /* 移除背景色和圆角，使其更融入区块背景 */
}

.performance-detail-item .detail-label {
  color: #666; /* 标签颜色调暗，使其不那么突出 */
  font-weight: 400; /* 普通字重 */
  margin-right: 8px;
}

.performance-detail-item .detail-value {
  /* color: #333; */ /* 颜色由各区块定义 */
  font-weight: 600; /* 稍加粗以突出数值 */
  font-size: 14.5px; /* 可略微增大数值字号 */
}

/* 本月业绩区块 - 最高优先级 */
.performance-section--month {
  order: 3; /* 在 performance-overview-container 内的顺序 */
  background: linear-gradient(135deg, #f3f9e6 0%, #e4f5d8 100%); /* 非常淡雅的绿色渐变 */
  border-color: #a3d9a5; /* 边框颜色与渐变协调 */
  box-shadow: 0 6px 15px rgba(163, 217, 165, 0.3);
}
.performance-section--month .performance-section-title {
  color: #38761d; /* 深绿色标题 */
  border-bottom-color: #6aa84f; /* 深绿色下划线 */
}
.performance-section--month .performance-summary-value {
  color: #2a5713; /* 更深的绿色数值 */
  font-size: 30px; /* 更大以突出 */
}
.performance-section--month .performance-summary-label {
  color: #4a7c37;
}
.performance-section--month .detail-label {
  color: #5a8c47;
}
.performance-section--month .detail-value {
  color: #2a5713;
}
.performance-section--month .performance-detail-item {
  /* background-color: rgba(163, 217, 165, 0.15); */ /* 移除独立背景 */
  border-bottom: 1px dashed rgba(106, 168, 79, 0.2); /* 添加虚线分隔 */
}
.performance-section--month .performance-detail-item:last-child {
  border-bottom: none;
}

/* 昨日业绩区块 - 中等优先级 */
.performance-section--yesterday {
  order: 2;
  background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%); /* 非常淡雅的黄色渐变 */
  border-color: #ffd54f; /* 边框颜色 */
  box-shadow: 0 4px 12px rgba(255, 213, 79, 0.25);
}
.performance-section--yesterday .performance-section-title {
  color: #b06000; /* 深黄色/橙色标题 */
  border-bottom-color: #f59e0b;
}
.performance-section--yesterday .performance-summary-value {
  color: #8c4d00;
  font-size: 28px;
}
.performance-section--yesterday .performance-summary-label {
  color: #b06000;
}
.performance-section--yesterday .detail-label {
  color: #c87000;
}
.performance-section--yesterday .detail-value {
  color: #8c4d00;
}
.performance-section--yesterday .performance-detail-item {
  /* background-color: rgba(255, 213, 79, 0.15); */
  border-bottom: 1px dashed rgba(245, 158, 11, 0.25);
}
.performance-section--yesterday .performance-detail-item:last-child {
  border-bottom: none;
}

/* 今日业绩区块 - 普通优先级 */
.performance-section--today {
  order: 1;
  background: linear-gradient(135deg, #e3f2fd 0%, #d0e7fa 100%); /* 非常淡雅的蓝色渐变 */
  border-color: #90caf9; /* 边框颜色 */
  box-shadow: 0 3px 10px rgba(144, 202, 249, 0.2);
}
.performance-section--today .performance-section-title {
  color: #1e3a8a; /* 深蓝色标题 */
  border-bottom-color: #357ae8;
}
.performance-section--today .performance-summary-value {
  color: #1a2c5c;
  font-size: 26px; /* 今日数值略小一点 */
}
.performance-section--today .performance-summary-label {
  color: #2c5282; /* 为今日业绩标签设置颜色 */
}
.performance-section--today .detail-label {
  color: #357ae8; /* 为今日业绩详情标签设置颜色 */
}
.performance-section--today .detail-value {
  color: #1e3a8a; /* 为今日业绩详情数值设置颜色 */
}
.performance-section--today .performance-detail-item {
  /* background-color: rgba(144, 202, 249, 0.15); */
  border-bottom: 1px dashed rgba(53, 122, 232, 0.25);
}
.performance-section--today .performance-detail-item:last-child {
  border-bottom: none;
}

/* 确保 .dashboard-cards 是 flex 容器以使 order 生效 */
.dashboard-cards {
  display: flex;
  flex-direction: column; /* 保持现有的列布局 */
  gap: 24px;
}

@media (max-width: 900px) {
  .dashboard-card-list {
    gap: 16px;
  }
  .dashboard-card, .dashboard-card--performance {
    min-width: unset;
    width: 100%;
  }
  .dashboard-card--performance .dashboard-card-value {
    font-size: 22px;
  }
  .dashboard-card--today.dashboard-card--performance .dashboard-card-value {
    font-size: 26px;
  }
}

/* 充值汇总模块样式 */
.dashboard-card-group--recharge-summary {
  /* order 属性确保其在业绩总览之后，如果需要调整顺序，修改这里的 order 值 */
  order: 5;
  /* 其余基础样式（背景、padding、圆角、阴影）应继承自 .dashboard-card-group */
  /* 如果需要特定调整，可以在这里覆盖，例如：*/
  /* background: #fcfcff; */ /* 一个非常浅的背景色以作区分 */
}

.recharge-summary-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.recharge-section {
  flex: 1 1 300px;
  padding: 20px;
  border-radius: 10px;
  transition: all 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
  gap: 15px;
  border: 1px solid #e0e0e0; /* 默认边框 */
  position: relative; /* 为内部绝对定位元素做准备，如果需要 */
  /* background-clip: padding-box; */ /* 确保背景和边框在padding区域内 */
}

.recharge-section:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.recharge-section-title {
  font-size: 18px; /* 略微增大标题 */
  font-weight: 600;
  padding: 8px 15px; /* 调整标题内边距 */
  border-bottom: none; /* 移除之前的下划线，采用背景色块 */
  text-align: center;
  margin-bottom: 10px; /* 调整与列表的间距 */
  border-radius: 6px 6px 0 0; /* 配合背景色块，给顶部圆角 */
  color: #fff; /* 标题文字统一用白色，依赖背景色区分 */
}

.recharge-account-list {
  list-style: none;
  padding: 0 5px; /* 给列表左右一点空间，避免贴边 */
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px; /* 账户项之间的间距 */
}

.recharge-account-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px; /* 增加列表项内边距 */
  border-radius: 6px;
  font-size: 14px;
  transition: background-color 0.2s ease, transform 0.2s ease;
  border-left: 4px solid transparent; /* 预留左边框位置 */
  background-color: rgba(255,255,255,0.4); /* 非常淡的白色背景，使其略微突出于区块背景 */
}

.recharge-account-item:hover {
  background-color: rgba(255,255,255,0.7);
  transform: translateX(3px);
}

.recharge-account-item .account-name {
  /* color: #555; */ /* 颜色由各区块定义 */
  font-weight: 500;
}

.recharge-account-item .account-amount {
  /* color: #333; */ /* 颜色由各区块定义 */
  font-weight: bold;
  font-size: 14.5px; /* 金额字体可稍大 */
}

.no-data-placeholder {
  text-align: center;
  color: #999;
  padding: 20px;
  font-style: italic;
}

/* 本月充值区块 - 最高优先级 */
.recharge-section--month {
  order: 3; /* 在 recharge-summary-container 内的顺序 */
  background: linear-gradient(135deg, #f6eafd 0%, #e9dffc 100%); /* 更淡雅的紫色渐变 */
  border-color: #d1bcf3;
  box-shadow: 0 6px 18px rgba(209, 188, 243, 0.35);
}
.recharge-section--month .recharge-section-title {
  background-color: #7e57c2; /* 深紫色标题背景 */
  /* color: #fff; 已在通用设置 */
}
.recharge-section--month .recharge-account-item {
  border-left-color: #7e57c2;
}
.recharge-section--month .account-name {
  color: #673ab7;
}
.recharge-section--month .account-amount {
  color: #4527a0;
  font-size: 15px; /* 强调金额 */
}
.recharge-section--month .recharge-account-item:hover {
  background-color: rgba(126, 87, 194, 0.15);
  border-left-color: #5e35b1; /* hover时边框加深 */
}

/* 昨日充值区块 - 中等优先级 */
.recharge-section--yesterday {
  order: 2;
  background: linear-gradient(135deg, #e0f7fa 0%, #cbeef6 100%); /* 更淡雅的青色渐变 */
  border-color: #a0e1eb;
  box-shadow: 0 4px 15px rgba(160, 225, 235, 0.3);
}
.recharge-section--yesterday .recharge-section-title {
  background-color: #00897b; /* 深青色标题背景 */
}
.recharge-section--yesterday .recharge-account-item {
  border-left-color: #00897b;
}
.recharge-section--yesterday .account-name {
  color: #00897b;
}
.recharge-section--yesterday .account-amount {
  color: #00695c;
}
.recharge-section--yesterday .recharge-account-item:hover {
  background-color: rgba(0, 137, 123, 0.12);
  border-left-color: #00796b;
}

/* 今日充值区块 - 普通优先级 */
.recharge-section--today {
  order: 1;
  background: linear-gradient(135deg, #e6f4e7 0%, #d8ebd9 100%); /* 非常淡的灰绿色 */
  border-color: #b2dfdb;
  box-shadow: 0 3px 12px rgba(178, 223, 219, 0.25);
}
.recharge-section--today .recharge-section-title {
  background-color: #388e3c; /* 绿色标题背景 */
}
.recharge-section--today .recharge-account-item {
  border-left-color: #388e3c;
}
.recharge-section--today .account-name {
  color: #388e3c;
}
.recharge-section--today .account-amount {
  color: #1b5e20;
}
.recharge-section--today .recharge-account-item:hover {
  background-color: rgba(56, 142, 60, 0.1);
  border-left-color: #2e7d32;
}

/* 确保 .dashboard-cards 是 flex 容器以使 order 生效 */
.dashboard-cards {
  display: flex;
  flex-direction: column; /* 保持现有的列布局 */
  gap: 24px;
}

@media (max-width: 900px) {
  .dashboard-card-list {
    gap: 16px;
  }
  .dashboard-card, .dashboard-card--performance {
    min-width: unset;
    width: 100%;
  }
  .dashboard-card--performance .dashboard-card-value {
    font-size: 22px;
  }
  .dashboard-card--today.dashboard-card--performance .dashboard-card-value {
    font-size: 26px;
  }
}
</style>
