import { useState } from 'react';
import { Card } from '../ui/card';
import { Button } from '../ui/button';
import { Badge } from '../ui/badge';
import {
  LayoutDashboard,
  RefreshCw,
  CheckCircle,
  AlertCircle,
  TrendingUp,
  Droplets,
  Bug,
  Sprout,
  Package,
  CloudRain,
  Layers,
  Activity,
  Clock,
  Info,
  Sparkles,
  Calendar,
  MapPin,
  Zap,
  CircleDot,
  Map as MapIcon,
} from 'lucide-react';
import { toast } from 'sonner@2.0.3';
import {
  LineChart,
  Line,
  XAxis,
  YAxis,
  CartesianGrid,
  Tooltip as RechartsTooltip,
  Legend,
  ResponsiveContainer,
} from 'recharts';

interface AIDecisionDashboardProps {
  activePath?: string;
}

// 决策类型
type DecisionType = 'irrigation' | 'fertilizer' | 'pesticide' | 'harvest' | 'soil' | 'weather';

// 决策状态（纯统计状态，无审核状态）
type DecisionStatus = 'generated' | 'executing' | 'completed' | 'expired';

// 决策优先级
type DecisionPriority = 'urgent' | 'high' | 'medium' | 'low';

// 决策记录
interface DecisionRecord {
  id: string;
  type: DecisionType;
  title: string;
  description: string;
  status: DecisionStatus;
  priority: DecisionPriority;
  fieldId: string;
  fieldName: string;
  fieldArea: number;
  cropType: string;
  confidence: number;
  createdAt: string;
  updatedAt: string;
  dueDate: string;
  location: {
    lat: number;
    lng: number;
  };
  modelVersion?: string;
  ruleCount?: number;
  executedAt?: string;
  executedBy?: string;
  completedAt?: string;
}

// 地块决策信息
interface FieldDecisionInfo {
  fieldId: string;
  fieldName: string;
  location: {
    lat: number;
    lng: number;
  };
  area: number;
  cropType: string;
  decisions: DecisionRecord[];
  urgentCount: number;
  generatedCount: number;
  executingCount: number;
  completedCount: number;
}

export function AIDecisionDashboard({ activePath }: AIDecisionDashboardProps) {
  // 模拟决策数据
  const [decisions] = useState<DecisionRecord[]>([
    {
      id: 'dec_001',
      type: 'irrigation',
      title: '1号大棚番茄开花期灌溉',
      description: '土壤湿度35%，低于最佳湿度，建议立即灌溉120升',
      status: 'generated',
      priority: 'urgent',
      fieldId: 'field_001',
      fieldName: '1号大棚',
      fieldArea: 2.5,
      cropType: '番茄',
      confidence: 0.89,
      createdAt: '2024-10-23 14:30',
      updatedAt: '2024-10-23 14:30',
      dueDate: '2024-10-23 18:00',
      location: { lat: 39.9042, lng: 116.4074 },
      modelVersion: 'v2.1.3',
      ruleCount: 2,
    },
    {
      id: 'dec_002',
      type: 'pesticide',
      title: '2号大棚早疫病防治',
      description: '检测到早疫病轻度感染，建议使用生物防治剂',
      status: 'executing',
      priority: 'high',
      fieldId: 'field_002',
      fieldName: '2号大棚',
      fieldArea: 3.0,
      cropType: '番茄',
      confidence: 0.87,
      createdAt: '2024-10-23 10:15',
      updatedAt: '2024-10-23 11:00',
      dueDate: '2024-10-23 17:00',
      executedAt: '2024-10-23 11:00',
      executedBy: '王五',
      location: { lat: 39.9142, lng: 116.4174 },
      modelVersion: 'v3.2.1',
      ruleCount: 1,
    },
    {
      id: 'dec_003',
      type: 'fertilizer',
      title: '3号地块小麦追肥',
      description: '结果期营养需求增加，建议施用复合肥',
      status: 'executing',
      priority: 'medium',
      fieldId: 'field_003',
      fieldName: '3号地块',
      fieldArea: 5.0,
      cropType: '小麦',
      confidence: 0.92,
      createdAt: '2024-10-23 09:30',
      updatedAt: '2024-10-23 10:00',
      dueDate: '2024-10-24 12:00',
      executedAt: '2024-10-23 10:00',
      executedBy: '李四',
      location: { lat: 39.8942, lng: 116.3974 },
      modelVersion: 'v2.0.5',
      ruleCount: 3,
    },
    {
      id: 'dec_004',
      type: 'soil',
      title: '4号地块土壤改良',
      description: 'pH值偏低，建议施用石灰调节土壤酸碱度',
      status: 'completed',
      priority: 'low',
      fieldId: 'field_004',
      fieldName: '4号地块',
      fieldArea: 4.2,
      cropType: '玉米',
      confidence: 0.85,
      createdAt: '2024-10-22 15:00',
      updatedAt: '2024-10-22 16:30',
      dueDate: '2024-10-25 12:00',
      executedAt: '2024-10-22 15:30',
      executedBy: '张三',
      completedAt: '2024-10-22 16:30',
      location: { lat: 39.8842, lng: 116.3874 },
      modelVersion: 'v1.8.2',
      ruleCount: 1,
    },
    {
      id: 'dec_005',
      type: 'weather',
      title: '5号大棚温度调控',
      description: '预计晚间温度降至12℃，建议提前加温',
      status: 'generated',
      priority: 'high',
      fieldId: 'field_005',
      fieldName: '5号大棚',
      fieldArea: 2.8,
      cropType: '黄瓜',
      confidence: 0.91,
      createdAt: '2024-10-23 16:00',
      updatedAt: '2024-10-23 16:00',
      dueDate: '2024-10-23 20:00',
      location: { lat: 39.9242, lng: 116.4274 },
      modelVersion: 'v2.3.1',
      ruleCount: 2,
    },
    {
      id: 'dec_006',
      type: 'harvest',
      title: '6号地块水稻收获',
      description: '水稻已达成熟期，建议3天内完成收获',
      status: 'generated',
      priority: 'urgent',
      fieldId: 'field_006',
      fieldName: '6号地块',
      fieldArea: 8.0,
      cropType: '水稻',
      confidence: 0.94,
      createdAt: '2024-10-23 08:00',
      updatedAt: '2024-10-23 08:00',
      dueDate: '2024-10-26 18:00',
      location: { lat: 39.9342, lng: 116.3874 },
      modelVersion: 'v2.5.0',
      ruleCount: 3,
    },
    {
      id: 'dec_007',
      type: 'irrigation',
      title: '7号大棚茄子补水',
      description: '连续3天无降雨，土壤湿度偏低',
      status: 'completed',
      priority: 'medium',
      fieldId: 'field_007',
      fieldName: '7号大棚',
      fieldArea: 2.2,
      cropType: '茄子',
      confidence: 0.86,
      createdAt: '2024-10-22 18:00',
      updatedAt: '2024-10-23 09:00',
      dueDate: '2024-10-23 12:00',
      executedAt: '2024-10-22 19:00',
      executedBy: '赵六',
      completedAt: '2024-10-23 09:00',
      location: { lat: 39.8742, lng: 116.4174 },
      modelVersion: 'v2.1.3',
      ruleCount: 2,
    },
  ]);

  // 统计数据
  const stats = {
    total: decisions.length,
    generated: decisions.filter(d => d.status === 'generated').length,
    executing: decisions.filter(d => d.status === 'executing').length,
    completed: decisions.filter(d => d.status === 'completed').length,
    urgent: decisions.filter(d => d.priority === 'urgent').length,
    avgConfidence: decisions.reduce((sum, d) => sum + d.confidence, 0) / decisions.length,
  };

  // 最新5条决策建议
  const latestDecisions = [...decisions]
    .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
    .slice(0, 5);

  // 趋势数据（近7天）
  const trendData = [
    { date: '10-17', generated: 8, completed: 5 },
    { date: '10-18', generated: 12, completed: 8 },
    { date: '10-19', generated: 10, completed: 9 },
    { date: '10-20', generated: 15, completed: 11 },
    { date: '10-21', generated: 13, completed: 10 },
    { date: '10-22', generated: 11, completed: 9 },
    { date: '10-23', generated: 14, completed: 7 },
  ];

  // 按地块聚合决策信息
  const fieldDecisionMap = new Map<string, FieldDecisionInfo>();
  decisions.forEach(decision => {
    if (!fieldDecisionMap.has(decision.fieldId)) {
      fieldDecisionMap.set(decision.fieldId, {
        fieldId: decision.fieldId,
        fieldName: decision.fieldName,
        location: decision.location,
        area: decision.fieldArea,
        cropType: decision.cropType,
        decisions: [],
        urgentCount: 0,
        generatedCount: 0,
        executingCount: 0,
        completedCount: 0,
      });
    }
    const fieldInfo = fieldDecisionMap.get(decision.fieldId)!;
    fieldInfo.decisions.push(decision);
    if (decision.priority === 'urgent') fieldInfo.urgentCount++;
    if (decision.status === 'generated') fieldInfo.generatedCount++;
    if (decision.status === 'executing') fieldInfo.executingCount++;
    if (decision.status === 'completed') fieldInfo.completedCount++;
  });

  const fieldDecisions = Array.from(fieldDecisionMap.values());

  const handleRefresh = () => {
    toast.success('数据已刷新');
  };

  const getTypeBadge = (type: DecisionType) => {
    const config = {
      irrigation: { label: '灌溉', icon: Droplets, className: 'bg-info-muted text-info-muted-foreground' },
      fertilizer: { label: '施肥', icon: Sprout, className: 'bg-success-muted text-success-muted-foreground' },
      pesticide: { label: '打药', icon: Bug, className: 'bg-warning-muted text-warning-muted-foreground' },
      harvest: { label: '收获', icon: Package, className: 'bg-accent-muted text-accent-foreground' },
      soil: { label: '土壤', icon: Layers, className: 'bg-warning-muted text-warning-muted-foreground' },
      weather: { label: '气象', icon: CloudRain, className: 'bg-info-muted text-info-muted-foreground' },
    };
    const { label, icon: Icon, className } = config[type];
    return (
      <Badge variant="outline" className={className}>
        <Icon className="w-3 h-3 mr-1" />
        {label}
      </Badge>
    );
  };

  const getPriorityBadge = (priority: DecisionPriority) => {
    const config = {
      urgent: { label: '紧急', className: 'bg-error-muted text-error-muted-foreground border-error' },
      high: { label: '高', className: 'bg-warning-muted text-warning-muted-foreground border-warning' },
      medium: { label: '中', className: 'bg-warning-muted text-warning-muted-foreground border-warning' },
      low: { label: '低', className: 'bg-muted text-muted-foreground border-border' },
    };
    const { label, className } = config[priority];
    return <Badge variant="outline" className={className}>{label}</Badge>;
  };

  const getStatusBadge = (status: DecisionStatus) => {
    const config = {
      generated: { label: '已生成', icon: Sparkles, className: 'bg-info-muted text-info-foreground border-info' },
      executing: { label: '执行中', icon: Activity, className: 'bg-accent-muted text-accent-foreground border-accent' },
      completed: { label: '已完成', icon: CheckCircle, className: 'bg-success-muted text-success-foreground border-success' },
      expired: { label: '已过期', icon: Clock, className: 'bg-muted text-muted-foreground border-border' },
    };
    const { label, icon: Icon, className } = config[status];
    return (
      <Badge variant="outline" className={className}>
        <Icon className="w-3 h-3 mr-1" />
        {label}
      </Badge>
    );
  };

  return (
    <div className="space-y-6">
      {/* 页面标题 */}
      <Card className="p-6 bg-gradient-to-r from-green-50 to-emerald-50 border-green-200">
        <div className="flex items-start justify-between">
          <div className="flex items-start gap-3">
            <LayoutDashboard className="w-6 h-6 text-success flex-shrink-0 mt-1" />
            <div className="flex-1">
              <h2 className="mb-2">AI决策看板</h2>
              <p className="text-sm text-muted-foreground mb-3">
                实时展示AI决策生成与执行统计，监控决策效果和趋势
              </p>
              <div className="flex flex-wrap gap-2">
                <Badge variant="outline" className="bg-white">
                  <Sparkles className="w-3 h-3 mr-1" />
                  智能生成
                </Badge>
                <Badge variant="outline" className="bg-white">
                  <Activity className="w-3 h-3 mr-1" />
                  实时监控
                </Badge>
                <Badge variant="outline" className="bg-white">
                  <TrendingUp className="w-3 h-3 mr-1" />
                  趋势分析
                </Badge>
                <Badge variant="outline" className="bg-white">
                  <MapIcon className="w-3 h-3 mr-1" />
                  地图可视化
                </Badge>
              </div>
            </div>
          </div>
          <div className="flex items-center gap-2">
            <Button variant="outline" size="sm" onClick={handleRefresh}>
              <RefreshCw className="w-4 h-4 mr-1" />
              刷新
            </Button>
          </div>
        </div>
      </Card>

      {/* 核心统计卡片 */}
      <div className="grid grid-cols-6 gap-4">
        <Card className="p-4">
          <div className="flex items-center justify-between mb-2">
            <div className="text-sm text-muted-foreground">总决策数</div>
            <LayoutDashboard className="w-4 h-4 text-muted-foreground" />
          </div>
          <div className="text-2xl font-bold">{stats.total}</div>
          <div className="text-xs text-muted-foreground mt-1">
            全部决策
          </div>
        </Card>

        <Card className="p-4">
          <div className="flex items-center justify-between mb-2">
            <div className="text-sm text-muted-foreground">已生成</div>
            <Sparkles className="w-4 h-4 text-blue-500" />
          </div>
          <div className="text-2xl font-bold text-info">{stats.generated}</div>
          <div className="text-xs text-muted-foreground mt-1">
            待执行
          </div>
        </Card>

        <Card className="p-4">
          <div className="flex items-center justify-between mb-2">
            <div className="text-sm text-muted-foreground">执行中</div>
            <Activity className="w-4 h-4 text-purple-500" />
          </div>
          <div className="text-2xl font-bold text-accent">{stats.executing}</div>
          <div className="text-xs text-muted-foreground mt-1">
            正在执行
          </div>
        </Card>

        <Card className="p-4">
          <div className="flex items-center justify-between mb-2">
            <div className="text-sm text-muted-foreground">已完成</div>
            <CheckCircle className="w-4 h-4 text-green-500" />
          </div>
          <div className="text-2xl font-bold text-success">{stats.completed}</div>
          <div className="text-xs text-muted-foreground mt-1">
            执行完成
          </div>
        </Card>

        <Card className="p-4">
          <div className="flex items-center justify-between mb-2">
            <div className="text-sm text-muted-foreground">紧急决策</div>
            <AlertCircle className="w-4 h-4 text-red-500" />
          </div>
          <div className="text-2xl font-bold text-destructive">{stats.urgent}</div>
          <div className="text-xs text-muted-foreground mt-1">
            需优先处理
          </div>
        </Card>

        <Card className="p-4">
          <div className="flex items-center justify-between mb-2">
            <div className="text-sm text-muted-foreground">平均置信度</div>
            <Zap className="w-4 h-4 text-yellow-500" />
          </div>
          <div className="text-2xl font-bold text-warning">
            {(stats.avgConfidence * 100).toFixed(0)}%
          </div>
          <div className="text-xs text-muted-foreground mt-1">
            决策准确性
          </div>
        </Card>
      </div>

      {/* 地图可视化 + 决策趋势图 */}
      <div className="grid grid-cols-2 gap-6">
        {/* 地块决策分布地图 */}
        <Card className="p-6">
          <div className="flex items-center justify-between mb-4">
            <h3>地块决策分布地图</h3>
            <Badge variant="outline">
              <MapIcon className="w-3 h-3 mr-1" />
              {fieldDecisions.length}个地块
            </Badge>
          </div>
          
          {/* 模拟地图区域 */}
          <div className="relative h-96 bg-gradient-to-br from-green-50 to-blue-50 rounded-lg border-2 border-green-200 overflow-hidden">
            {/* 地图背景 */}
            <div className="absolute inset-0 opacity-20">
              <div className="w-full h-full" style={{
                backgroundImage: 'repeating-linear-gradient(0deg, #10b981 0px, #10b981 1px, transparent 1px, transparent 20px), repeating-linear-gradient(90deg, #10b981 0px, #10b981 1px, transparent 1px, transparent 20px)',
              }}></div>
            </div>

            {/* 地块标记点 */}
            {fieldDecisions.map((field, index) => {
              // 计算标记点位置（模拟分布）
              const positions = [
                { top: '15%', left: '20%' },
                { top: '25%', left: '65%' },
                { top: '45%', left: '30%' },
                { top: '55%', left: '75%' },
                { top: '70%', left: '45%' },
                { top: '35%', left: '85%' },
                { top: '80%', left: '25%' },
              ];
              const position = positions[index] || { top: '50%', left: '50%' };

              return (
                <div
                  key={field.fieldId}
                  className="absolute transform -translate-x-1/2 -translate-y-1/2 group cursor-pointer"
                  style={position}
                >
                  {/* 标记点 */}
                  <div className={`w-10 h-10 rounded-full flex items-center justify-center shadow-lg transition-transform hover:scale-125 ${
                    field.urgentCount > 0 ? 'bg-destructive' :
                    field.generatedCount > 0 ? 'bg-info' :
                    field.executingCount > 0 ? 'bg-accent' :
                    'bg-success'
                  }`}>
                    <MapPin className="w-5 h-5 text-white" />
                  </div>

                  {/* 决策数量标记 */}
                  {field.decisions.length > 0 && (
                    <div className="absolute -top-2 -right-2 w-6 h-6 bg-warning text-white rounded-full flex items-center justify-center text-xs font-bold shadow-lg">
                      {field.decisions.length}
                    </div>
                  )}

                  {/* 悬浮信息卡片 */}
                  <div className="absolute top-full left-1/2 transform -translate-x-1/2 mt-2 w-64 bg-white rounded-lg shadow-xl p-4 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10 border-2 border-green-200">
                    <div className="mb-2">
                      <div className="flex items-center gap-2 mb-1">
                        <MapPin className="w-4 h-4 text-success" />
                        <strong>{field.fieldName}</strong>
                      </div>
                      <div className="text-xs text-muted-foreground">
                        {field.cropType} · {field.area}亩
                      </div>
                    </div>

                    <div className="space-y-1 text-xs">
                      <div className="flex justify-between">
                        <span className="text-muted-foreground">总决策:</span>
                        <strong>{field.decisions.length}条</strong>
                      </div>
                      {field.urgentCount > 0 && (
                        <div className="flex justify-between text-destructive">
                          <span>紧急:</span>
                          <strong>{field.urgentCount}条</strong>
                        </div>
                      )}
                      {field.generatedCount > 0 && (
                        <div className="flex justify-between text-info">
                          <span>已生成:</span>
                          <strong>{field.generatedCount}条</strong>
                        </div>
                      )}
                      {field.executingCount > 0 && (
                        <div className="flex justify-between text-accent">
                          <span>执行中:</span>
                          <strong>{field.executingCount}条</strong>
                        </div>
                      )}
                      {field.completedCount > 0 && (
                        <div className="flex justify-between text-success">
                          <span>已完成:</span>
                          <strong>{field.completedCount}条</strong>
                        </div>
                      )}
                    </div>

                    {/* 最新决策 */}
                    {field.decisions.length > 0 && (
                      <div className="mt-2 pt-2 border-t">
                        <div className="text-xs text-muted-foreground mb-1">最新决策:</div>
                        <div className="text-xs font-medium line-clamp-2">
                          {field.decisions[0].title}
                        </div>
                      </div>
                    )}
                  </div>
                </div>
              );
            })}

            {/* 图例 */}
            <div className="absolute bottom-4 right-4 bg-white/95 rounded-lg shadow-lg p-3 border border-gray-200">
              <div className="text-xs font-medium mb-2">状态图例</div>
              <div className="space-y-1.5 text-xs">
                <div className="flex items-center gap-2">
                  <div className="w-3 h-3 rounded-full bg-destructive"></div>
                  <span>有紧急决策</span>
                </div>
                <div className="flex items-center gap-2">
                  <div className="w-3 h-3 rounded-full bg-info"></div>
                  <span>有待执行决策</span>
                </div>
                <div className="flex items-center gap-2">
                  <div className="w-3 h-3 rounded-full bg-accent"></div>
                  <span>有执行中决策</span>
                </div>
                <div className="flex items-center gap-2">
                  <div className="w-3 h-3 rounded-full bg-success"></div>
                  <span>全部完成</span>
                </div>
              </div>
            </div>
          </div>

          {/* 地块列表 */}
          <div className="mt-4 space-y-2 max-h-48 overflow-y-auto">
            {fieldDecisions.map((field) => (
              <div key={field.fieldId} className="flex items-center justify-between p-2 bg-muted rounded hover:bg-accent transition-colors">
                <div className="flex items-center gap-2">
                  <MapPin className={`w-4 h-4 ${
                    field.urgentCount > 0 ? 'text-red-500' :
                    field.generatedCount > 0 ? 'text-blue-500' :
                    field.executingCount > 0 ? 'text-purple-500' :
                    'text-green-500'
                  }`} />
                  <div>
                    <div className="text-sm font-medium">{field.fieldName}</div>
                    <div className="text-xs text-muted-foreground">
                      {field.cropType} · {field.area}亩
                    </div>
                  </div>
                </div>
                <div className="flex items-center gap-2">
                  <Badge variant="outline" className="text-xs">
                    {field.decisions.length}条决策
                  </Badge>
                  {field.urgentCount > 0 && (
                    <Badge variant="outline" className="text-xs bg-error-muted text-error-foreground border-error">
                      {field.urgentCount}紧急
                    </Badge>
                  )}
                </div>
              </div>
            ))}
          </div>
        </Card>

        {/* 决策趋势图 */}
        <Card className="p-6">
          <div className="flex items-center justify-between mb-4">
            <h3>决策生成与完成趋势</h3>
            <Badge variant="outline">
              <Calendar className="w-3 h-3 mr-1" />
              近7天
            </Badge>
          </div>
          <div className="h-96">
            <ResponsiveContainer width="100%" height="100%">
              <LineChart data={trendData}>
                <CartesianGrid strokeDasharray="3 3" />
                <XAxis dataKey="date" />
                <YAxis />
                <RechartsTooltip />
                <Legend />
                <Line 
                  type="monotone" 
                  dataKey="generated" 
                  stroke="#3b82f6" 
                  name="生成决策" 
                  strokeWidth={2}
                  dot={{ r: 4 }}
                />
                <Line 
                  type="monotone" 
                  dataKey="completed" 
                  stroke="#10b981" 
                  name="完成决策" 
                  strokeWidth={2}
                  dot={{ r: 4 }}
                />
              </LineChart>
            </ResponsiveContainer>
          </div>
        </Card>
      </div>

      {/* 最新5条决策建议 */}
      <Card className="p-6">
        <div className="flex items-center justify-between mb-4">
          <h3>最新决策建议</h3>
          <Badge variant="outline" className="bg-success/10 text-success border-success/30">
            <Sparkles className="w-3 h-3 mr-1" />
            最新5条
          </Badge>
        </div>

        {latestDecisions.length === 0 ? (
          <div className="text-center py-12 text-muted-foreground">
            <Info className="w-12 h-12 mx-auto mb-3 opacity-50" />
            <div>暂无决策建议</div>
          </div>
        ) : (
          <div className="space-y-4">
            {latestDecisions.map((decision, index) => (
              <Card key={decision.id} className="p-5 hover:shadow-md transition-shadow border-l-4" 
                style={{
                  borderLeftColor: decision.priority === 'urgent' ? '#ef4444' : 
                                  decision.priority === 'high' ? '#f59e0b' : 
                                  decision.priority === 'medium' ? '#eab308' : '#9ca3af'
                }}>
                <div className="flex items-start">
                  <div className="flex-1">
                    <div className="flex items-center gap-2 mb-2">
                      <Badge variant="outline" className="bg-info-muted text-info-foreground border-info">
                        <CircleDot className="w-3 h-3 mr-1" />
                        #{index + 1}
                      </Badge>
                      {getTypeBadge(decision.type)}
                      {getPriorityBadge(decision.priority)}
                      {getStatusBadge(decision.status)}
                    </div>
                    
                    <h4 className="mb-2">{decision.title}</h4>
                    
                    <p className="text-sm text-muted-foreground mb-3">
                      {decision.description}
                    </p>

                    <div className="grid grid-cols-4 gap-4 text-sm">
                      <div>
                        <div className="text-muted-foreground mb-1">地块信息</div>
                        <div className="flex items-center gap-1">
                          <MapPin className="w-4 h-4 text-success" />
                          <span className="font-medium">{decision.fieldName}</span>
                        </div>
                      </div>
                      <div>
                        <div className="text-muted-foreground mb-1">作物类型</div>
                        <div className="flex items-center gap-1">
                          <Sprout className="w-4 h-4 text-success" />
                          <span className="font-medium">{decision.cropType}</span>
                        </div>
                      </div>
                      <div>
                        <div className="text-muted-foreground mb-1">置信度</div>
                        <div className="flex items-center gap-1">
                          <Zap className="w-4 h-4 text-warning" />
                          <span className="font-medium">{(decision.confidence * 100).toFixed(0)}%</span>
                        </div>
                      </div>
                      <div>
                        <div className="text-muted-foreground mb-1">生成时间</div>
                        <div className="flex items-center gap-1">
                          <Clock className="w-4 h-4 text-muted-foreground" />
                          <span className="font-medium">{decision.createdAt}</span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </Card>
            ))}
          </div>
        )}
      </Card>
    </div>
  );
}
