'use client';

import React from 'react';

const Breadcrumb = ({ items = [], className = '' }) => {
  return (
    <nav
      aria-label="Breadcrumb"
      className={`inline-flex self-start bg-white dark:bg-[#0B0B0B] border border-neutral-200 dark:border-[#1B1B1B] rounded-xl overflow-hidden ${className}`}
    >
      <ol className="flex items-center">
        {items.map((item, index) => (
          <React.Fragment key={item.key ?? index}>
            {index !== 0 && (
              <span className="text-neutral-300 dark:text-neutral-600 text-xs select-none px-0.5">
                /
              </span>
            )}
            <li className="flex items-center">
              <button
                onClick={item.onClick}
                disabled={!item.onClick || item.active}
                className={[
                  'px-3 py-1.5 text-xs font-medium transition-colors',
                  item.active
                    ? 'text-black dark:text-white cursor-default'
                    : item.onClick
                      ? 'text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-900 cursor-pointer'
                      : 'text-neutral-400 cursor-default',
                ].filter(Boolean).join(' ')}
              >
                {item.label}
              </button>
            </li>
          </React.Fragment>
        ))}
      </ol>
    </nav>
  );
};

export default Breadcrumb;
