import React from 'react';
import { TouchableOpacity, Text, View } from 'react-native';
import { Link } from 'expo-router';
import { useTheme } from '@/constants/ThemeContext';
import { ArrowRight, ChevronRight } from 'lucide-react-native';

interface NavLinkProps {
  href: any;
  label: string;
  description?: string;
  variant?: 'primary' | 'secondary' | 'outline';
  icon?: React.ReactNode;
}

export const NavLink: React.FC<NavLinkProps> = ({
  href,
  label,
  description,
  variant = 'primary',
  icon,
}) => {
  const { isDark } = useTheme();

  const isOutline = variant === 'outline';
  const isSecondary = variant === 'secondary';

  let containerStyle = 'bg-sky-500 shadow-md shadow-sky-500/20';
  let labelStyle = 'text-white font-black';
  let descStyle = 'text-sky-100';
  let iconColor = '#FFFFFF';

  if (isSecondary) {
    containerStyle = isDark ? 'bg-slate-900 border border-slate-800' : 'bg-slate-100 border border-slate-200';
    labelStyle = isDark ? 'text-white font-bold' : 'text-slate-900 font-bold';
    descStyle = isDark ? 'text-slate-400' : 'text-slate-600';
    iconColor = isDark ? '#38BDF8' : '#0EA5E9';
  } else if (isOutline) {
    containerStyle = isDark ? 'bg-transparent border-2 border-sky-500/50' : 'bg-transparent border-2 border-sky-500';
    labelStyle = isDark ? 'text-sky-400 font-bold' : 'text-sky-600 font-bold';
    descStyle = isDark ? 'text-slate-400' : 'text-slate-600';
    iconColor = isDark ? '#38BDF8' : '#0EA5E9';
  }

  return (
    <Link href={href} asChild>
      <TouchableOpacity
        className={`flex-row items-center justify-between p-4 rounded-2xl my-1.5 ${containerStyle}`}
      >
        <View className="flex-row items-center flex-1 pr-3 space-x-3">
          {icon && <View className="mr-2">{icon}</View>}
          <View className="flex-1">
            <Text className={`text-base ${labelStyle}`}>{label}</Text>
            {description && (
              <Text className={`text-xs mt-0.5 ${descStyle}`}>{description}</Text>
            )}
          </View>
        </View>
        <ChevronRight size={20} color={iconColor} />
      </TouchableOpacity>
    </Link>
  );
};
