import React from "react";

const inventoryItems = [
  {
    key: "inStock",
    label: "In Stock",
    bgClass: "bg-green-50 border-green-200",
    textClass: "text-green-600",
    valueClass: "text-green-700",
    iconBg: "bg-green-100",
    iconColor: "text-green-600",
    icon: (
      <svg className="w-6 h-6 text-green-600" fill="currentColor" viewBox="0 0 20 20">
        <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clipRule="evenodd" />
      </svg>
    ),
  },
  {
    key: "lowStock",
    label: "Low Stock",
    bgClass: "bg-yellow-50 border-yellow-200",
    textClass: "text-yellow-600",
    valueClass: "text-yellow-700",
    iconBg: "bg-yellow-100",
    iconColor: "text-yellow-600",
    icon: (
      <svg className="w-6 h-6 text-yellow-600" fill="currentColor" viewBox="0 0 20 20">
        <path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
      </svg>
    ),
  },
  {
    key: "criticalStock",
    label: "Critical",
    bgClass: "bg-orange-50 border-orange-200",
    textClass: "text-orange-600",
    valueClass: "text-orange-700",
    iconBg: "bg-orange-100",
    iconColor: "text-orange-600",
    icon: (
      <svg className="w-6 h-6 text-orange-600" fill="currentColor" viewBox="0 0 20 20">
        <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clipRule="evenodd" />
      </svg>
    ),
  },
  {
    key: "outOfStock",
    label: "Out of Stock",
    bgClass: "bg-red-50 border-red-200",
    textClass: "text-red-600",
    valueClass: "text-red-700",
    iconBg: "bg-red-100",
    iconColor: "text-red-600",
    icon: (
      <svg className="w-6 h-6 text-red-600" fill="currentColor" viewBox="0 0 20 20">
        <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM7 9a1 1 0 000 2h6a1 1 0 100-2H7z" clipRule="evenodd" />
      </svg>
    ),
  },
];

const InventoryStatus = ({ inventory }) => {
  if (!inventory) return null;

  return (
    <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
      {inventoryItems.map((item) => (
        <div key={item.key} className={`${item.bgClass} border rounded-xl p-4`}>
          <div className="flex items-center justify-between">
            <div>
              <p className={`text-xs ${item.textClass} font-semibold uppercase`}>{item.label}</p>
              <p className={`text-2xl font-bold ${item.valueClass} mt-1`}>{inventory[item.key]}</p>
            </div>
            <div className={`${item.iconBg} w-12 h-12 rounded-lg flex items-center justify-center`}>
              {item.icon}
            </div>
          </div>
        </div>
      ))}
    </div>
  );
};

export default InventoryStatus;