import React from 'react';
import { useNavigate } from 'react-router-dom';
import styled from 'styled-components';
import { FiUser } from 'react-icons/fi';

const Wrapper = styled.div`
  background: white;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 60px 40px;
`;

const Icon = styled.div`
  font-size: 64px;
  margin-bottom: 24px;
`;

const Title = styled.h2`
  font-size: 24px;
  font-weight: bold;
  color: #2e7d32;
  margin-bottom: 16px;
`;

const Text = styled.p`
  color: #666;
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 24px;
`;

const Button = styled.button`
  background: linear-gradient(135deg, #81c784 0%, #a5d6a7 100%);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(129, 199, 132, 0.3);

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(129, 199, 132, 0.4);
  }
`;

const LoginRequired = ({
  title = '需要登录访问',
  description = '该功能需要登录后才能使用，请先登录您的账户。',
  icon = '🔒',
}) => {
  const navigate = useNavigate();

  return (
    <Wrapper>
      <div>
        <Icon>{icon}</Icon>
        <Title>{title}</Title>
        <Text>{description}</Text>
        <Button onClick={() => navigate('/login')}>
          <FiUser />
          立即登录
        </Button>
      </div>
    </Wrapper>
  );
};

export default LoginRequired;
