File size: 3,258 Bytes
09801ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import React from 'react';
import { motion } from 'framer-motion';
import { TrendingUp, TrendingDown, Minus } from 'lucide-react';
import { useUserStore } from '@/store/userStore';

interface SimulatorKPICardProps {
  label: string;
  value: string;
  change?: number;
  trend?: 'up' | 'down' | 'stable';
  description?: string;
  icon?: React.ReactNode;
  accent?: string;
}

const SimulatorKPICard: React.FC<SimulatorKPICardProps> = ({
  label,
  value,
  change,
  trend = 'stable',
  description,
  icon,
  accent = '#6366f1',
}) => {
  const { isDark } = useUserStore();

  return (
    <motion.div
      initial={{ opacity: 0, y: 12 }}
      animate={{ opacity: 1, y: 0 }}
      transition={{ duration: 0.35 }}
      className="relative overflow-hidden rounded-2xl border p-5"
      style={{
        background: isDark ? 'rgba(255,255,255,0.03)' : '#ffffff',
        borderColor: isDark ? 'rgba(255,255,255,0.06)' : 'rgba(0,0,0,0.06)',
        boxShadow: isDark ? 'none' : '0 1px 3px rgba(0,0,0,0.04)',
      }}
    >
      {/* Accent glow */}
      <div
        className="absolute top-0 right-0 w-20 h-20 rounded-full blur-3xl opacity-10"
        style={{ background: accent }}
      />

      <div className="flex items-start justify-between">
        <div className="flex-1 min-w-0">
          <p
            className="text-xs font-medium truncate mb-1.5"
            style={{ color: isDark ? '#94a3b8' : '#64748b' }}
          >
            {label}
          </p>
          <p
            className="text-2xl font-bold tracking-tight"
            style={{ color: isDark ? '#f8fafc' : '#0f172a' }}
          >
            {value}
          </p>
          {change !== undefined && (
            <div className="flex items-center gap-1 mt-2">
              <span
                className={`flex items-center gap-0.5 text-xs font-semibold ${
                  trend === 'up'
                    ? 'text-emerald-500'
                    : trend === 'down'
                    ? 'text-red-500'
                    : isDark
                    ? 'text-gray-400'
                    : 'text-gray-500'
                }`}
              >
                {trend === 'up' && <TrendingUp className="w-3.5 h-3.5" />}
                {trend === 'down' && <TrendingDown className="w-3.5 h-3.5" />}
                {trend === 'stable' && <Minus className="w-3.5 h-3.5" />}
                {change > 0 ? '+' : ''}{change}%
              </span>
              <span
                className="text-xs"
                style={{ color: isDark ? '#64748b' : '#94a3b8' }}
              >
                vs Baseline
              </span>
            </div>
          )}
          {description && (
            <p
              className="text-xs mt-1"
              style={{ color: isDark ? '#64748b' : '#94a3b8' }}
            >
              {description}
            </p>
          )}
        </div>
        {icon && (
          <div
            className="flex-shrink-0 w-10 h-10 rounded-xl flex items-center justify-center"
            style={{
              background: `${accent}15`,
              color: accent,
            }}
          >
            {icon}
          </div>
        )}
      </div>
    </motion.div>
  );
};

export default SimulatorKPICard;