<template>
  <div class="center-overview">
    <h2>中心整体概览</h2>
    <div class="overview-grid">
      <div class="overview-card primary">
        <div class="card-header">
          <span class="card-title">中心总业绩</span>
          <span class="card-trend positive">{{ props.overallData.CenterPerformance?.center_monthly_vs_previous_deals }} vs 上期</span>
        </div>
        <div class="card-value">{{ props.overallData.CenterPerformance.center_monthly_deal_count || '552,000' }} 元</div>
        <div class="card-subtitle">月目标完成率: {{ props.overallData.CenterPerformance?.center_monthly_target_completion_rate || '56%' }}</div>
      </div>
      
      <div class="overview-card">
        <div class="card-header">
          <span class="card-title">活跃组数</span>
          <span class="card-trend stable">{{ props.overallData.TotalGroupCount?.center_total_team_count}}/{{ props.overallData.TotalGroupCount?.center_total_team_count }} 组</span>
        </div>
        <div class="card-value">{{ props.overallData.TotalGroupCount?.center_total_team_count || '5' }} 组</div>
        <div class="card-subtitle">总人数: {{ props.overallData.TotalGroupCount?.center_total_user_count || '40' }}人</div>
      </div>
      
      <div class="overview-card">
        <div class="card-header">
          <span class="card-title">中心转化率</span>
          <span class="card-trend positive">{{ props.overallData.CenterConversionRate?.center_monthly_vs_previous_deals }}vs 上期</span>
        </div>
        <div class="card-value">{{ props.overallData.CenterConversionRate?.center_conversion_rate || '5.2' }}</div>
        <div class="card-subtitle">行业平均: {{ props.overallData.CenterConversionRate?.current_user_center_conversion_rate || '4.8' }}</div>
      </div>
      
      <div class="overview-card">
        <div class="card-header">
          <span class="card-title">总通话次数</span>
          <span class="card-trend positive">{{ props.overallData.TotalCallCount?.total_call_count_vs_yesterday}} vs 上期</span>
        </div>
        <div class="card-value">{{ props.overallData.TotalCallCount?.total_call_count || '1,247' }} 次</div>
        <div class="card-subtitle">有效通话: {{ props.overallData.TotalCallCount?.center_effective_call_count || '892' }}次</div>
      </div>
      
      <div class="overview-card">
        <div class="card-header">
          <span class="card-title">新增客户</span>
          <span class="card-trend positive">{{ props.overallData.NewCustomer?.center_new_leads_vs_previous_period }} vs 上期</span>
        </div>
        <div class="card-value">{{ props.overallData.NewCustomer?.center_new_leads_count || '117' }} 人</div>
        <div class="card-subtitle">意向客户: {{ props.overallData.NewCustomer?.center_new_v_customer_count || '89' }}人</div>
      </div>
      
      <div class="overview-card">
        <div class="card-header">
          <span class="card-title">定金转化</span>
          <span class="card-trend positive">{{ props.overallData.DepositConversionRate?.center_deposit_conversion_vs_previous }} vs 上期</span>
        </div>
        <div class="card-value">{{ props.overallData.DepositConversionRate?.center_current_deposit_conversion_rate || '0' }} </div>
        <div class="card-subtitle">平均定金转化率: {{ props.overallData.DepositConversionRate?.center_monthly_deposit_conversion_rate || '0' }}</div>
      </div>
    </div>
  
  </div>
</template>

<script setup>
// 中心整体概览组件
const props = defineProps({
  overallData: {
    type: Object,
    default: () => ({
      CenterPerformance: {},
      TotalGroupCount: {},
      CenterConversionRate: {},
      TotalCallCount: {},
      NewCustomer: {},
      DepositConversionRate: {}
    })
  }
})
</script>

<style lang="scss" scoped>
.center-overview {
  background: white;
  border-radius: 12px;
  padding: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  
  h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 1.5rem 0;
  }
  
  .overview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 0;
  }
  
  .overview-card {
    padding: 1.2rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.3s ease;
    
    &:hover {
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      transform: translateY(-2px);
    }
    
    &.primary {
      background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
      color: white;
      border: none;
      
      .card-title, .card-subtitle {
        color: rgba(255, 255, 255, 0.9);
      }
      
      .card-trend {
        color: rgba(255, 255, 255, 0.8);
      }
      
      .card-value {
        color: white;
      }
    }
    
    .card-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      // padding: 1rem;
      margin-bottom: 0.5rem;
    }
    
    .card-title {
      color: #64748b;
      font-size: 0.9rem;
      font-weight: 500;
    }
    
    .card-trend {
      font-size: 0.75rem;
      font-weight: 600;
      
      &.positive {
        color: #059669;
      }
      
      &.negative {
        color: #dc2626;
      }
      
      &.stable {
        color: #7c3aed;
      }
    }
    
    .card-value {
      font-size: 1.8rem;
      font-weight: bold;
      color: #1e293b;
      margin-bottom: 0.25rem;
    }
    
    .card-subtitle {
      color: #94a3b8;
      font-size: 0.8rem;
    }
  }
  
  .trend-section {
    h3 {
      font-size: 1.1rem;
      font-weight: 600;
      color: #1e293b;
      margin: 0 0 1rem 0;
    }
    
    .trend-charts {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 1rem;
    }
    
    .trend-item {
      display: flex;
      align-items: center;
      gap: 1rem;
      padding: 0.75rem;
      background: #f8fafc;
      border-radius: 8px;
      
      .trend-label {
        font-size: 0.85rem;
        color: #64748b;
        min-width: 80px;
      }
      
      .trend-bar {
        flex: 1;
        height: 6px;
        background: #e2e8f0;
        border-radius: 3px;
        overflow: hidden;
        
        .trend-fill {
          height: 100%;
          background: linear-gradient(90deg, #10b981, #059669);
          border-radius: 3px;
          transition: width 0.3s ease;
        }
      }
      
      .trend-value {
        font-size: 0.8rem;
        font-weight: 600;
        color: #059669;
        min-width: 40px;
        text-align: right;
      }
    }
  }
}

// 移动端适配
@media (max-width: 768px) {
  .center-overview {
    padding: 1rem;
    
    .overview-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 0.75rem;
    }
    
    .overview-card {
      padding: 1rem;
      
      .card-value {
        font-size: 1.5rem;
      }
    }
    
    .trend-charts {
      grid-template-columns: 1fr;
    }
  }
}

@media (max-width: 480px) {
  .center-overview {
    .overview-grid {
      grid-template-columns: 1fr;
    }
  }
}
</style>