"use client";

import { useApp } from "@/contexts/AppContext";

interface StatCardProps {
  label: string;
  value: string;
  change?: string;
  changeColor?: string;
  valueColor?: string;
}

function StatCard({
  label,
  value,
  change,
  changeColor = "text-green-500",
  valueColor
}: StatCardProps) {
  const getValueColor = () => {
    if (valueColor) return valueColor;
    if (label.includes("APY") || label.includes("年化")) return "#ff6900";
    return "#111827";
  };

  return (
    <div className="bg-bg-subtle dark:bg-gray-700 rounded-2xl border border-border-gray dark:border-gray-600 p-4 flex flex-col gap-2">
      <p className="text-caption-tiny font-bold text-text-tertiary dark:text-gray-400 uppercase tracking-wider">
        {label}
      </p>
      <p className="text-heading-h3 font-bold dark:text-white" style={{ color: getValueColor() }}>
        {value}
      </p>
      {change && (
        <p className={`text-caption-tiny font-medium ${changeColor} dark:text-gray-400`}>
          {change}
        </p>
      )}
    </div>
  );
}

export default function StatsCards() {
  const { t } = useApp();

  return (
    <div className="grid grid-cols-5 gap-4 w-full">
      <StatCard label={t("stats.currentAPY")} value="22%" change="+2.5% WoW" changeColor="text-green-500" />
      <StatCard label={t("stats.totalValueLocked")} value="$240.5M" change="+$2.3M Today" changeColor="text-green-500" />
      <StatCard label="24h Volume" value="$12.8M" change="↑ 23% vs Avg" changeColor="text-green-500" />
      <StatCard label={t("stats.yourBalance")} value="0.00" change="$0.00 USD" changeColor="text-text-tertiary" />
      <StatCard
        label={t("stats.yourEarnings")}
        value="$0.00"
        change="All Time"
        changeColor="text-text-tertiary"
        valueColor="#10b981"
      />
    </div>
  );
}
