<template>
  <div class="sales-funnel">
    <h2>团队销售漏斗</h2>
    <p class="funnel-description">展示从线索到成交的各个环节转化情况，帮助数据驱动在各阶段的工作重点优化。</p>
    <div class="funnel-chart">
       <div class="funnel-stage" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);">
         <span class="stage-label">线索总数</span>
         <span class="stage-value">{{ funnelData.customers_count?.['线索总数'] || 0 }}</span>
       </div>
       <div class="funnel-stage" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
         <span class="stage-label">有效沟通</span>
         <span class="stage-value">{{ funnelData.customers_count?.['有效沟通'] || 0 }}</span>
       </div>
       <div class="funnel-stage" style="background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);">
         <span class="stage-label">到课数据</span>
         <span class="stage-value">{{ funnelData.customers_count?.['到课数据'] || 0 }}</span>
       </div>
       <div class="funnel-stage" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);">
         <span class="stage-label">预付定金</span>
         <span class="stage-value">{{ funnelData.customers_count?.['预付定金'] || 0 }}</span>
       </div>
       <div class="funnel-stage" style="background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);">
         <span class="stage-label">成功签单</span>
         <span class="stage-value">{{ funnelData.customers_count?.['成功签单'] || 0 }}</span>
       </div>
     </div>
  </div>
</template>

<script setup>
// 团队销售漏斗组件

// 定义props
const props = defineProps({
  funnelData: {
    type: Object,
    default: () => ({
      customers_count: {
        '线索总数': 0,
        '有效沟通': 0,
        '到课数据': 0,
        '预付定金': 0,
        '成功签单': 0
      }
    })
  }
})
</script>

<style lang="scss" scoped>
// Sales Funnel
.sales-funnel {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  
  h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
  }
  
  .funnel-description {
    color: #64748b;
    font-size: 0.85rem;
    margin: 0 0 1.5rem 0;
    line-height: 1.4;
  }
  
  .funnel-chart {
    display: flex;
    align-items: center;
    gap: 0;
    height: 80px;
    overflow: hidden;
  }
  
  .funnel-stage {
    flex: 1;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 50%, calc(100% - 20px) 100%, 0 100%, 20px 50%);
    
    &:first-child {
      clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 50%, calc(100% - 20px) 100%, 0 100%);
    }
    
    &:last-child {
      clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 20px 50%);
    }
    
    .stage-label {
      font-size: 0.85rem;
      margin-bottom: 0.25rem;
    }
    
    .stage-value {
      font-size: 1.1rem;
      font-weight: bold;
    }
  }
}

// 移动端适配
@media (max-width: 768px) {
  .sales-funnel {
    padding: 1rem;
    
    h2 {
      font-size: 1.1rem;
    }
    
    .funnel-description {
      font-size: 0.8rem;
    }
    
    .funnel-chart {
      height: auto;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      grid-template-rows: repeat(2, 1fr);
      gap: 0.5rem;
    }
    
    .funnel-stage {
      height: 50px;
      clip-path: none;
      border-radius: 8px;
      
      &:nth-child(4) {
        grid-column: 1;
        grid-row: 2;
      }
      
      &:nth-child(5) {
        grid-column: 2;
        grid-row: 2;
      }
      
      .stage-label {
        font-size: 0.75rem;
      }
      
      .stage-value {
        font-size: 1rem;
      }
    }
  }
}

@media (max-width: 480px) {
  .sales-funnel {
    padding: 0.75rem;
    border-radius: 8px;
    
    .funnel-chart {
      height: auto;
    }
    
    .funnel-stage {
      height: 40px;
      
      .stage-label {
        font-size: 0.7rem;
      }
      
      .stage-value {
        font-size: 0.9rem;
      }
    }
  }
}
</style>