'use client';

import { X } from 'lucide-react';
import { KEYBOARD_SHORTCUTS_LIST } from '@/hooks/useKeyboardShortcuts';

interface KeyboardShortcutsHelpProps {
  isOpen: boolean;
  onClose: () => void;
}

export default function KeyboardShortcutsHelp({ isOpen, onClose }: KeyboardShortcutsHelpProps) {
  if (!isOpen) return null;

  return (
    <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50" onClick={onClose}>
      <div
        className="w-full max-w-lg rounded-lg bg-[#1a1a2e] border border-gray-700 shadow-xl"
        onClick={(e) => e.stopPropagation()}
      >
        <div className="flex items-center justify-between border-b border-gray-700 px-5 py-4">
          <h2 className="text-lg font-semibold text-gray-100">Atajos de teclado</h2>
          <button
            onClick={onClose}
            className="rounded p-1 text-gray-400 hover:bg-gray-700 hover:text-gray-200"
          >
            <X className="h-5 w-5" />
          </button>
        </div>

        <div className="max-h-[60vh] overflow-y-auto px-5 py-4">
          <div className="space-y-2">
            {KEYBOARD_SHORTCUTS_LIST.map((shortcut, index) => (
              <div
                key={index}
                className="flex items-center justify-between py-1.5"
              >
                <span className="text-sm text-gray-300">{shortcut.description}</span>
                <kbd className="rounded bg-gray-700 px-2 py-0.5 text-xs text-gray-200 font-mono">
                  {shortcut.keys}
                </kbd>
              </div>
            ))}
          </div>
        </div>

        <div className="border-t border-gray-700 px-5 py-3">
          <p className="text-xs text-gray-500">
            En Mac usa ⌘ (Cmd), en Windows/Linux usa Ctrl
          </p>
        </div>
      </div>
    </div>
  );
}