const { useState, useEffect, useRef } = React;

// ===== 图标组件 =====
const LogoIcon = ({ size = 36 }) => (
  <svg width={size} height={size} viewBox="0 0 48 48" fill="none">
    <defs>
      <linearGradient id="logoGrad" x1="0%" y1="0%" x2="0%" y2="100%">
        <stop offset="0%" stopColor="hsl(32, 70%, 55%)" />
        <stop offset="100%" stopColor="hsl(32, 70%, 45%)" />
      </linearGradient>
    </defs>
    <circle cx="24" cy="24" r="24" fill="url(#logoGrad)" />
    <path d="M14 32 L19 22 L24 28 L29 22 L34 32" stroke="white" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" fill="none" />
    <line x1="14" y1="34" x2="34" y2="34" stroke="white" strokeWidth="2.5" strokeLinecap="round" />
    <circle cx="24" cy="16" r="2.5" fill="white" />
  </svg>
);

const HomeIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
    <polyline points="9 22 9 12 15 12 15 22" />
  </svg>
);

const TeamIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
    <circle cx="9" cy="7" r="4" />
    <path d="M23 21v-2a4 4 0 0 0-3-3.87" />
    <path d="M16 3.13a4 4 0 0 1 0 7.75" />
  </svg>
);

const ChildrenIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <circle cx="12" cy="8" r="4" />
    <path d="M12 12v8" />
    <path d="M8 16h8" />
    <path d="M9 20h6" />
  </svg>
);

const PartnersIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
    <circle cx="9" cy="7" r="4" />
    <path d="M22 11h-6" />
    <path d="M19 8v6" />
  </svg>
);

const EarthIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <circle cx="12" cy="12" r="10" />
    <line x1="2" y1="12" x2="22" y2="12" />
    <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
  </svg>
);

const ToolIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" />
  </svg>
);

const ChevronDownIcon = () => (
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <polyline points="6 9 12 15 18 9" />
  </svg>
);

const CheckIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
    <polyline points="20 6 9 17 4 12" />
  </svg>
);

const ArrowRightIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <line x1="5" y1="12" x2="19" y2="12" />
    <polyline points="12 5 19 12 12 19" />
  </svg>
);

const ArrowUpIcon = () => (
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
    <line x1="12" y1="19" x2="12" y2="5" />
    <polyline points="5 12 12 5 19 12" />
  </svg>
);

const LoginIcon = () => (
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4" />
    <polyline points="10 17 15 12 10 7" />
    <line x1="15" y1="12" x2="3" y2="12" />
  </svg>
);

const CloseIcon = () => (
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <line x1="18" y1="6" x2="6" y2="18" />
    <line x1="6" y1="6" x2="18" y2="18" />
  </svg>
);

const SparkleIcon = () => (
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M12 3l1.9 5.8L20 10.7l-4.7 4.1 1.5 6.2L12 17.9 7.2 21l1.5-6.2L4 10.7l6.1-1.9L12 3z" />
  </svg>
);

const BellIcon = () => (
  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9" />
    <path d="M13.73 21a2 2 0 0 1-3.46 0" />
  </svg>
);

const TaskIcon = () => (
  <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M9 11l3 3L22 4" />
    <path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11" />
  </svg>
);

const LogoutIcon = () => (
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
    <polyline points="16 17 21 12 16 7" />
    <line x1="21" y1="12" x2="9" y2="12" />
  </svg>
);

const UserIcon = () => (
  <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
    <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" />
    <circle cx="12" cy="7" r="4" />
  </svg>
);

const BuildingIcon = () => (
  <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
    <rect x="4" y="2" width="16" height="20" rx="2" ry="2" />
    <path d="M9 22v-4h6v4" />
    <path d="M8 6h.01" />
    <path d="M16 6h.01" />
    <path d="M12 6h.01" />
    <path d="M12 10h.01" />
    <path d="M12 14h.01" />
    <path d="M16 10h.01" />
    <path d="M16 14h.01" />
    <path d="M8 10h.01" />
    <path d="M8 14h.01" />
  </svg>
);

const ClientIcon = () => (
  <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
    <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2" />
    <circle cx="9" cy="7" r="4" />
    <path d="M23 21v-2a4 4 0 0 0-3-3.87" />
    <path d="M16 3.13a4 4 0 0 1 0 7.75" />
  </svg>
);

const GlobeIcon = () => (
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
    <circle cx="12" cy="12" r="10" />
    <line x1="2" y1="12" x2="22" y2="12" />
    <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" />
  </svg>
);

// ===== 数据 =====
const navItems = [
  { key: 'home', label: '首页', icon: HomeIcon },
  { key: 'team', label: '关爱团队', icon: TeamIcon },
  { key: 'children', label: '关爱儿童', icon: ChildrenIcon },
  { key: 'partners', label: '关爱伙伴', icon: PartnersIcon },
  { key: 'earth', label: '关爱地球', icon: EarthIcon },
  { key: 'tools', label: '工具', icon: ToolIcon },
];

const languages = [
  { code: 'zh-CN', label: '简体中文' },
];

const identityTabs = [
  {
    key: 'employee',
    label: '员工',
    desc: '内部员工使用，可访问团队知识库与工作系统',
    icon: UserIcon,
    color: '#FF9F43',
    user: { name: '张晓明', dept: '人事行政部' },
  },
  {
    key: 'supplier',
    label: '供应商',
    desc: '供应商伙伴使用，可查看合作订单与采购信息',
    icon: BuildingIcon,
    color: '#5F27CD',
    user: { name: '李建国', dept: '厦门优品塑胶制品有限公司' },
  },
  {
    key: 'client',
    label: '客户',
    desc: '客户伙伴使用，可查看产品信息与服务进度',
    icon: ClientIcon,
    color: '#54A0FF',
    user: { name: '王美琪', dept: '广州启智玩具有限公司' },
  },
];

const plans = [
  {
    key: 'team',
    title: '我们关爱团队',
    slogan: '我们对事业根基的守护',
    color: '#FF9F43',
    image: 'assets/plan-team.jpg',
  },
  {
    key: 'children',
    title: '我们关爱儿童',
    slogan: '我们对未来世代的投资',
    color: '#54A0FF',
    image: 'assets/plan-children.jpg',
  },
  {
    key: 'partners',
    title: '我们关爱伙伴',
    slogan: '我们对价值共生的承诺',
    color: '#5F27CD',
    image: 'assets/plan-partners.jpg',
  },
  {
    key: 'earth',
    title: '我们关爱地球',
    slogan: '我们对生命家园的契约',
    color: '#10AC84',
    image: 'assets/plan-earth.jpg',
  },
];

// ===== 页头组件 =====
function Header({ scrolled, activeNav, onNavClick, currentLang, onLangChange }) {
  const [langOpen, setLangOpen] = useState(false);
  const langRef = useRef(null);

  useEffect(() => {
    const handleClick = (e) => {
      if (langRef.current && !langRef.current.contains(e.target)) {
        setLangOpen(false);
      }
    };
    document.addEventListener('click', handleClick);
    return () => document.removeEventListener('click', handleClick);
  }, []);

  const headerStyle = {
    position: 'fixed',
    top: 0,
    left: 0,
    right: 0,
    zIndex: 100,
    padding: '0 40px',
    height: '72px',
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'space-between',
    transition: 'all 0.3s ease',
    background: scrolled ? 'rgba(255, 255, 255, 0.85)' : 'transparent',
    backdropFilter: scrolled ? 'blur(12px)' : 'none',
    WebkitBackdropFilter: scrolled ? 'blur(12px)' : 'none',
    borderBottom: scrolled ? '1px solid var(--border-color)' : '1px solid transparent',
    boxShadow: scrolled ? '0 2px 12px rgba(0,0,0,0.06)' : 'none',
  };

  const currentLangObj = languages.find(l => l.code === currentLang);

  return (
    <header style={headerStyle}>
      <div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
        <LogoIcon size={40} />
        <span style={{
          fontSize: '18px',
          fontWeight: 700,
          color: scrolled ? 'var(--text-primary)' : '#FFFFFF',
          letterSpacing: '0.5px',
        }}>
          邦纳生态系统
        </span>
      </div>

      <nav style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
        {navItems.map(item => {
          const Icon = item.icon;
          const isActive = activeNav === item.key;
          return (
            <button
              key={item.key}
              onClick={() => onNavClick(item.key)}
              style={{
                display: 'flex',
                alignItems: 'center',
                gap: '6px',
                padding: '8px 16px',
                borderRadius: '10px',
                fontSize: '14px',
                fontWeight: isActive ? 600 : 400,
                color: isActive ? '#FFFFFF' : (scrolled ? 'var(--text-secondary)' : 'rgba(255,255,255,0.85)'),
                background: isActive ? 'var(--brand-orange)' : 'transparent',
                transition: 'all 0.2s ease',
              }}
              onMouseEnter={e => {
                if (!isActive) {
                  e.currentTarget.style.background = scrolled ? 'rgba(0,0,0,0.05)' : 'rgba(255,255,255,0.1)';
                }
              }}
              onMouseLeave={e => {
                if (!isActive) {
                  e.currentTarget.style.background = 'transparent';
                }
              }}
            >
              <Icon />
              {item.label}
            </button>
          );
        })}
      </nav>

      <div style={{ position: 'relative' }}>
        <div style={{
          display: 'flex',
          alignItems: 'center',
          gap: '6px',
          padding: '8px 14px',
          borderRadius: '10px',
          fontSize: '14px',
          color: scrolled ? 'var(--text-secondary)' : 'rgba(255,255,255,0.9)',
        }}>
          <GlobeIcon />
          {currentLangObj.label}
        </div>
      </div>
    </header>
  );
}

// ===== 登录弹窗 =====
function LoginModal({ isOpen, onClose, onLogin }) {
  const [activeTab, setActiveTab] = useState('employee');
  const [phone, setPhone] = useState('');
  const [error, setError] = useState('');
  const [loading, setLoading] = useState(false);

  useEffect(() => {
    if (isOpen) {
      setPhone('');
      setError('');
      setLoading(false);
    }
  }, [isOpen]);

  if (!isOpen) return null;

  const handleLogin = () => {
    const phoneRegex = /^1[3-9]\d{9}$/;
    if (!phoneRegex.test(phone)) {
      setError('请输入正确的中国大陆11位手机号码');
      return;
    }
    setError('');
    setLoading(true);
    setTimeout(() => {
      setLoading(false);
      const identity = identityTabs.find(t => t.key === activeTab);
      onLogin(identity);
    }, 1000);
  };

  return (
    <div style={{
      position: 'fixed',
      inset: 0,
      zIndex: 200,
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      background: 'rgba(0,0,0,0.5)',
      backdropFilter: 'blur(4px)',
      animation: 'fadeIn 0.2s ease',
    }} onClick={onClose}>
      <div
        style={{
          width: '100%',
          maxWidth: '480px',
          background: '#FFFFFF',
          borderRadius: '20px',
          boxShadow: '0 24px 60px rgba(0,0,0,0.2)',
          padding: '36px 32px 32px',
          position: 'relative',
          animation: 'slideUp 0.3s ease',
        }}
        onClick={e => e.stopPropagation()}
      >
        <button
          onClick={onClose}
          style={{
            position: 'absolute',
            top: '20px',
            right: '20px',
            width: '36px',
            height: '36px',
            borderRadius: '50%',
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'center',
            color: 'var(--text-tertiary)',
            transition: 'all 0.2s ease',
          }}
          onMouseEnter={e => {
            e.currentTarget.style.background = '#F5F5F5';
            e.currentTarget.style.color = 'var(--text-primary)';
          }}
          onMouseLeave={e => {
            e.currentTarget.style.background = 'transparent';
            e.currentTarget.style.color = 'var(--text-tertiary)';
          }}
        >
          <CloseIcon />
        </button>

        <div style={{ textAlign: 'center', marginBottom: '28px' }}>
          <h2 style={{
            fontSize: '24px',
            fontWeight: 700,
            color: 'var(--text-primary)',
            marginBottom: '8px',
          }}>登录邦纳生态系统</h2>
          <p style={{
            fontSize: '14px',
            color: 'var(--text-secondary)',
            lineHeight: 1.6,
          }}>请选择身份类型并输入手机号，首次登录由管理员审核后开通。</p>
        </div>

        {/* 身份标签 */}
        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(3, 1fr)',
          gap: '10px',
          marginBottom: '28px',
        }}>
          {identityTabs.map(tab => {
            const Icon = tab.icon;
            const isActive = activeTab === tab.key;
            return (
              <button
                key={tab.key}
                onClick={() => setActiveTab(tab.key)}
                style={{
                  padding: '16px 10px',
                  borderRadius: '12px',
                  border: isActive ? `2px solid ${tab.color}` : '2px solid var(--border-color)',
                  background: isActive ? `${tab.color}08` : '#FFFFFF',
                  transition: 'all 0.2s ease',
                  display: 'flex',
                  flexDirection: 'column',
                  alignItems: 'center',
                  gap: '8px',
                }}
                onMouseEnter={e => {
                  if (!isActive) {
                    e.currentTarget.style.borderColor = tab.color + '60';
                  }
                }}
                onMouseLeave={e => {
                  if (!isActive) {
                    e.currentTarget.style.borderColor = 'var(--border-color)';
                  }
                }}
              >
                <div style={{
                  color: isActive ? tab.color : 'var(--text-tertiary)',
                  transition: 'color 0.2s ease',
                }}>
                  <Icon />
                </div>
                <span style={{
                  fontSize: '14px',
                  fontWeight: isActive ? 600 : 500,
                  color: isActive ? tab.color : 'var(--text-primary)',
                }}>{tab.label}</span>
              </button>
            );
          })}
        </div>

        {/* 身份说明 */}
        <div style={{
          padding: '14px 16px',
          background: '#F9F9F9',
          borderRadius: '10px',
          marginBottom: '24px',
          fontSize: '13px',
          color: 'var(--text-secondary)',
          lineHeight: 1.5,
        }}>
          {identityTabs.find(t => t.key === activeTab)?.desc}
        </div>

        {/* 手机号输入 */}
        <div style={{ marginBottom: '24px' }}>
          <label style={{
            display: 'block',
            fontSize: '14px',
            fontWeight: 500,
            color: 'var(--text-primary)',
            marginBottom: '8px',
          }}>
            手机号码<span style={{ color: '#FF4D4F' }}>*</span>
          </label>
          <input
            type="tel"
            value={phone}
            onChange={e => {
              const val = e.target.value.replace(/\D/g, '').slice(0, 11);
              setPhone(val);
              if (error) setError('');
            }}
            placeholder="请输入手机号码"
            style={{
              width: '100%',
              height: '48px',
              padding: '0 16px',
              borderRadius: '10px',
              border: `1px solid ${error ? '#FF4D4F' : 'var(--border-color)'}`,
              fontSize: '15px',
              color: 'var(--text-primary)',
              outline: 'none',
              transition: 'border-color 0.2s ease',
            }}
            onFocus={e => {
              if (!error) e.target.style.borderColor = 'var(--brand-orange)';
            }}
            onBlur={e => {
              if (!error) e.target.style.borderColor = 'var(--border-color)';
            }}
          />
          {error && (
            <p style={{
              marginTop: '6px',
              fontSize: '12px',
              color: '#FF4D4F',
            }}>{error}</p>
          )}
        </div>

        {/* 登录按钮 */}
        <button
          onClick={handleLogin}
          disabled={loading}
          style={{
            width: '100%',
            height: '52px',
            borderRadius: '26px',
            background: 'var(--brand-orange)',
            color: '#FFFFFF',
            fontSize: '16px',
            fontWeight: 600,
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'center',
            gap: '8px',
            transition: 'all 0.2s ease',
            opacity: loading ? 0.8 : 1,
            cursor: loading ? 'not-allowed' : 'pointer',
          }}
          onMouseEnter={e => {
            if (!loading) e.currentTarget.style.background = 'var(--brand-orange-dark)';
          }}
          onMouseLeave={e => {
            e.currentTarget.style.background = 'var(--brand-orange)';
          }}
        >
          {loading ? (
            <>
              <div style={{
                width: '18px',
                height: '18px',
                border: '2px solid rgba(255,255,255,0.3)',
                borderTopColor: '#FFFFFF',
                borderRadius: '50%',
                animation: 'spin 0.8s linear infinite',
              }} />
              登录中...
            </>
          ) : (
            '登录'
          )}
        </button>
      </div>
    </div>
  );
}

// ===== 欢迎弹窗 =====
function WelcomeModal({ isOpen, onClose, onExplore }) {
  if (!isOpen) return null;

  return (
    <div style={{
      position: 'fixed',
      inset: 0,
      zIndex: 200,
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      background: 'rgba(0,0,0,0.5)',
      backdropFilter: 'blur(4px)',
      animation: 'fadeIn 0.3s ease',
    }} onClick={onClose}>
      <div
        style={{
          width: '100%',
          maxWidth: '440px',
          background: '#FFFFFF',
          borderRadius: '20px',
          boxShadow: '0 24px 60px rgba(0,0,0,0.2)',
          overflow: 'hidden',
          animation: 'slideUp 0.4s ease',
        }}
        onClick={e => e.stopPropagation()}
      >
        {/* 顶部渐变横幅 */}
        <div style={{
          padding: '40px 32px',
          background: 'linear-gradient(135deg, var(--brand-orange) 0%, #FFC107 50%, #FFE0B2 100%)',
          position: 'relative',
          overflow: 'hidden',
        }}>
          <div style={{
            position: 'absolute',
            top: '20px',
            right: '24px',
            color: 'rgba(255,255,255,0.6)',
            animation: 'sparkle 2s ease-in-out infinite',
          }}>
            <SparkleIcon />
          </div>
          <div style={{
            position: 'absolute',
            bottom: '30px',
            left: '30px',
            color: 'rgba(255,255,255,0.4)',
            transform: 'scale(0.7)',
            animation: 'sparkle 2.5s ease-in-out infinite 0.5s',
          }}>
            <SparkleIcon />
          </div>
          <div style={{
            fontSize: '13px',
            fontWeight: 600,
            color: 'rgba(255,255,255,0.9)',
            letterSpacing: '2px',
            textTransform: 'uppercase',
          }}>
            BANATOYS ECOSYSTEM
          </div>
        </div>

        <div style={{ padding: '32px' }}>
          <h3 style={{
            fontSize: '22px',
            fontWeight: 700,
            color: 'var(--text-primary)',
            marginBottom: '12px',
          }}>欢迎来到邦纳生态系统</h3>
          <p style={{
            fontSize: '14px',
            color: 'var(--text-secondary)',
            lineHeight: 1.7,
            marginBottom: '28px',
          }}>
            感谢您加入邦纳生态系统。在这里，您可以参与四大关爱计划，与我们一起用爱守护，共创未来。探索更多精彩内容，开启您的生态之旅。
          </p>

          <div style={{
            display: 'flex',
            gap: '12px',
          }}>
            <button
              onClick={onClose}
              style={{
                flex: 1,
                height: '48px',
                borderRadius: '24px',
                border: '1px solid var(--border-color)',
                background: '#FFFFFF',
                color: 'var(--text-secondary)',
                fontSize: '14px',
                fontWeight: 500,
                transition: 'all 0.2s ease',
              }}
              onMouseEnter={e => {
                e.currentTarget.style.borderColor = '#DDD';
                e.currentTarget.style.color = 'var(--text-primary)';
              }}
              onMouseLeave={e => {
                e.currentTarget.style.borderColor = 'var(--border-color)';
                e.currentTarget.style.color = 'var(--text-secondary)';
              }}
            >
              稍后再看
            </button>
            <button
              onClick={onExplore}
              style={{
                flex: 1,
                height: '48px',
                borderRadius: '24px',
                background: 'var(--brand-orange)',
                color: '#FFFFFF',
                fontSize: '14px',
                fontWeight: 600,
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                gap: '6px',
                transition: 'all 0.2s ease',
              }}
              onMouseEnter={e => {
                e.currentTarget.style.background = 'var(--brand-orange-dark)';
              }}
              onMouseLeave={e => {
                e.currentTarget.style.background = 'var(--brand-orange)';
              }}
            >
              开始探索
              <ArrowRightIcon />
            </button>
          </div>
        </div>
      </div>
    </div>
  );
}

// ===== Hero区 =====
function Hero({ user, onLoginClick, onLogout }) {
  const heroRef = useRef(null);

  const scrollToPlans = () => {
    const el = document.getElementById('plans-section');
    if (el) el.scrollIntoView({ behavior: 'smooth' });
  };

  return (
    <section
      ref={heroRef}
      id="hero-section"
      style={{
        position: 'relative',
        minHeight: '100vh',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
        overflow: 'hidden',
      }}
    >
      {/* 背景图 */}
      <div style={{
        position: 'absolute',
        inset: 0,
        backgroundImage: 'url(assets/hero-bg.jpg)',
        backgroundSize: 'cover',
        backgroundPosition: 'center',
        zIndex: 0,
        filter: 'brightness(1.35) saturate(0.9) contrast(0.95)',
      }} />

      {/* 静止轨道 + 光点装饰 */}
      <svg
        style={{
          position: 'absolute',
          top: '50%',
          left: '50%',
          width: '820px',
          height: '820px',
          transform: 'translate(-50%, -50%)',
          zIndex: 0,
        }}
        viewBox="0 0 820 820"
      >
        <defs>
          <radialGradient id="orbitGrad" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="rgba(255, 220, 180, 0)" />
            <stop offset="90%" stopColor="rgba(255, 220, 180, 0.1)" />
            <stop offset="100%" stopColor="rgba(255, 200, 120, 0.3)" />
          </radialGradient>
        </defs>
        {/* 外层淡色轨道圆 */}
        <circle cx="410" cy="410" r="380" fill="none" stroke="rgba(255, 220, 180, 0.12)" strokeWidth="1" strokeDasharray="4 8" />
        {/* 内层轨道圆 */}
        <circle cx="410" cy="410" r="280" fill="none" stroke="rgba(180, 200, 255, 0.1)" strokeWidth="1" strokeDasharray="2 6" />
        {/* 轨道上的固定光点 */}
        <circle cx="410" cy="30" r="3" fill="rgba(255, 220, 150, 0.6)">
          <animate attributeName="opacity" values="0.4;1;0.4" dur="4s" repeatCount="indefinite" />
        </circle>
        <circle cx="790" cy="410" r="2.5" fill="rgba(180, 200, 255, 0.5)">
          <animate attributeName="opacity" values="0.3;0.9;0.3" dur="5s" repeatCount="indefinite" begin="1s" />
        </circle>
        <circle cx="410" cy="790" r="2" fill="rgba(255, 200, 120, 0.5)">
          <animate attributeName="opacity" values="0.4;0.8;0.4" dur="6s" repeatCount="indefinite" begin="2s" />
        </circle>
        <circle cx="30" cy="410" r="2.5" fill="rgba(200, 220, 255, 0.4)">
          <animate attributeName="opacity" values="0.3;0.7;0.3" dur="4.5s" repeatCount="indefinite" begin="0.5s" />
        </circle>
        {/* 内层固定光点 */}
        <circle cx="410" cy="130" r="2" fill="rgba(255, 240, 200, 0.6)">
          <animate attributeName="opacity" values="0.5;1;0.5" dur="3.5s" repeatCount="indefinite" begin="1.5s" />
        </circle>
        <circle cx="690" cy="410" r="1.5" fill="rgba(180, 200, 255, 0.5)">
          <animate attributeName="opacity" values="0.3;0.8;0.3" dur="5.5s" repeatCount="indefinite" begin="3s" />
        </circle>
      </svg>

      {/* 渐变遮罩 - 更浅更暖的色调，减少深蓝压迫感 */}
      <div style={{
        position: 'absolute',
        inset: 0,
        background: 'linear-gradient(180deg, rgba(255, 240, 220, 0.2) 0%, rgba(255, 220, 180, 0.1) 30%, rgba(180, 190, 220, 0.15) 55%, rgba(200, 190, 210, 0.1) 75%, rgba(250, 250, 249, 0) 100%)',
        zIndex: 1,
      }} />

      {/* 底部融合层 - 平滑过渡到下方板块背景色 */}
      <div style={{
        position: 'absolute',
        bottom: 0,
        left: 0,
        right: 0,
        height: '200px',
        background: 'linear-gradient(180deg, transparent 0%, rgba(250, 250, 249, 0.3) 40%, rgba(250, 250, 249, 0.7) 70%, var(--bg-primary) 100%)',
        zIndex: 1,
        pointerEvents: 'none',
      }} />

      {/* 顶部柔光层 - 增加通透感 */}
      <div style={{
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        height: '50%',
        background: 'radial-gradient(ellipse at 50% 0%, rgba(255, 220, 160, 0.25) 0%, transparent 60%)',
        zIndex: 1,
      }} />

      {/* 内容 */}
      <div style={{
        position: 'relative',
        zIndex: 2,
        textAlign: 'center',
        padding: '0 24px',
        maxWidth: '800px',
      }}>
        {/* 徽章 */}
        <div style={{
          display: 'inline-flex',
          alignItems: 'center',
          padding: '8px 20px',
          borderRadius: '999px',
          background: 'rgba(255, 255, 255, 0.9)',
          border: '1px solid rgba(255, 255, 255, 0.6)',
          marginBottom: '28px',
          animation: 'fadeInDown 0.8s ease',
        }}>
          <span style={{
            fontSize: '12px',
            fontWeight: 700,
            color: '#000000',
            letterSpacing: '3px',
            textTransform: 'uppercase',
          }}>
            BANA SUNSHARE ECOSYSTEM
          </span>
        </div>

        {/* 大标题 */}
        <h1 style={{
          fontSize: 'clamp(40px, 7vw, 72px)',
          fontWeight: 900,
          color: '#FFFFFF',
          marginBottom: '20px',
          lineHeight: 1.2,
          letterSpacing: '2px',
          animation: 'fadeInUp 0.8s ease 0.1s both',
          textShadow: '0 2px 20px rgba(0,0,0,0.3)',
        }}>
          邦纳生态系统
        </h1>

        {/* 副标题 */}
        <p style={{
          fontSize: 'clamp(16px, 2vw, 20px)',
          color: 'rgba(255,255,255,0.85)',
          marginBottom: '40px',
          lineHeight: 1.8,
          animation: 'fadeInUp 0.8s ease 0.2s both',
        }}>
          以爱为纽带，共建美好世界. 四大关爱计划，共筑美好未来。
        </p>

        {/* 登录按钮 / 用户信息卡 */}
        {!user ? (
          <button
            onClick={onLoginClick}
            style={{
              display: 'inline-flex',
              alignItems: 'center',
              gap: '10px',
              padding: '16px 36px',
              borderRadius: '999px',
              background: 'var(--brand-orange)',
              color: '#FFFFFF',
              fontSize: '16px',
              fontWeight: 600,
              boxShadow: '0 8px 24px rgba(255, 159, 67, 0.4)',
              transition: 'all 0.3s ease',
              animation: 'fadeInUp 0.8s ease 0.3s both',
            }}
            onMouseEnter={e => {
              e.currentTarget.style.background = 'var(--brand-orange-dark)';
              e.currentTarget.style.transform = 'translateY(-2px)';
              e.currentTarget.style.boxShadow = '0 12px 32px rgba(255, 159, 67, 0.5)';
            }}
            onMouseLeave={e => {
              e.currentTarget.style.background = 'var(--brand-orange)';
              e.currentTarget.style.transform = 'translateY(0)';
              e.currentTarget.style.boxShadow = '0 8px 24px rgba(255, 159, 67, 0.4)';
            }}
          >
            <LoginIcon />
            登录
          </button>
        ) : (
          <div style={{
            display: 'flex',
            flexDirection: 'column',
            alignItems: 'center',
            gap: '24px',
            animation: 'fadeInUp 0.6s ease both',
          }}>
            {/* 用户信息卡 */}
            <div style={{
              display: 'flex',
              alignItems: 'center',
              gap: '16px',
              padding: '16px 24px 16px 16px',
              background: 'rgba(255,255,255,0.15)',
              backdropFilter: 'blur(12px)',
              WebkitBackdropFilter: 'blur(12px)',
              borderRadius: '999px',
              border: '1px solid rgba(255,255,255,0.2)',
            }}>
              <div style={{
                width: '52px',
                height: '52px',
                borderRadius: '50%',
                background: 'linear-gradient(135deg, var(--brand-orange), #FFC107)',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                color: '#FFFFFF',
                fontSize: '22px',
                fontWeight: 700,
              }}>
                {user.name.charAt(0)}
              </div>
              <div style={{ textAlign: 'left' }}>
                <div style={{
                  display: 'flex',
                  alignItems: 'center',
                  gap: '8px',
                  marginBottom: '2px',
                }}>
                  <span style={{
                    fontSize: '16px',
                    fontWeight: 600,
                    color: '#FFFFFF',
                  }}>{user.name}</span>
                  <span style={{
                    fontSize: '11px',
                    fontWeight: 500,
                    padding: '2px 8px',
                    borderRadius: '999px',
                    background: user.color + '30',
                    color: user.color === '#5F27CD' ? '#B39DDB' : user.color + 'CC',
                    border: `1px solid ${user.color}50`,
                  }}>
                    {user.identityLabel}
                  </span>
                </div>
                <div style={{
                  fontSize: '13px',
                  color: 'rgba(255,255,255,0.7)',
                }}>{user.dept}</div>
              </div>
              <div style={{ width: '1px', height: '36px', background: 'rgba(255,255,255,0.2)' }} />
              <button
                onClick={onLogout}
                style={{
                  display: 'flex',
                  alignItems: 'center',
                  gap: '6px',
                  padding: '8px 14px',
                  borderRadius: '999px',
                  fontSize: '13px',
                  color: 'rgba(255,255,255,0.8)',
                  transition: 'all 0.2s ease',
                }}
                onMouseEnter={e => {
                  e.currentTarget.style.background = 'rgba(255,255,255,0.1)';
                  e.currentTarget.style.color = '#FFFFFF';
                }}
                onMouseLeave={e => {
                  e.currentTarget.style.background = 'transparent';
                  e.currentTarget.style.color = 'rgba(255,255,255,0.8)';
                }}
              >
                <LogoutIcon />
                退出
              </button>
            </div>

            {/* 快捷按钮 */}
            <div style={{
              display: 'flex',
              gap: '12px',
            }}>
              <button
                style={{
                  display: 'flex',
                  alignItems: 'center',
                  gap: '8px',
                  padding: '12px 24px',
                  borderRadius: '999px',
                  background: 'rgba(255,255,255,0.12)',
                  backdropFilter: 'blur(8px)',
                  border: '1px solid rgba(255,255,255,0.2)',
                  color: '#FFFFFF',
                  fontSize: '14px',
                  fontWeight: 500,
                  transition: 'all 0.2s ease',
                }}
                onMouseEnter={e => {
                  e.currentTarget.style.background = 'rgba(255,255,255,0.2)';
                }}
                onMouseLeave={e => {
                  e.currentTarget.style.background = 'rgba(255,255,255,0.12)';
                }}
              >
                <BellIcon />
                消息中心
              </button>
              <button
                style={{
                  display: 'flex',
                  alignItems: 'center',
                  gap: '8px',
                  padding: '12px 24px',
                  borderRadius: '999px',
                  background: 'rgba(255,255,255,0.12)',
                  backdropFilter: 'blur(8px)',
                  border: '1px solid rgba(255,255,255,0.2)',
                  color: '#FFFFFF',
                  fontSize: '14px',
                  fontWeight: 500,
                  transition: 'all 0.2s ease',
                }}
                onMouseEnter={e => {
                  e.currentTarget.style.background = 'rgba(255,255,255,0.2)';
                }}
                onMouseLeave={e => {
                  e.currentTarget.style.background = 'rgba(255,255,255,0.12)';
                }}
              >
                <TaskIcon />
                我的任务
              </button>
            </div>
          </div>
        )}
      </div>

      {/* 底部滚动指示 */}
      <div style={{
        position: 'absolute',
        bottom: '32px',
        left: '50%',
        transform: 'translateX(-50%)',
        zIndex: 2,
        color: 'rgba(255,255,255,0.6)',
        animation: 'bounce 2s ease-in-out infinite',
      }}>
        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
          <polyline points="6 9 12 15 18 9" />
        </svg>
      </div>
    </section>
  );
}

// ===== 计划卡片 =====
function PlanCard({ plan }) {
  return (
    <div style={{
      background: '#FFFFFF',
      borderRadius: 'var(--radius-lg)',
      border: '1px solid var(--border-color)',
      boxShadow: 'var(--shadow-sm)',
      overflow: 'hidden',
      transition: 'all 0.3s ease',
      position: 'relative',
    }}
      onMouseEnter={e => {
        e.currentTarget.style.transform = 'translateY(-6px)';
        e.currentTarget.style.boxShadow = 'var(--shadow-lg)';
      }}
      onMouseLeave={e => {
        e.currentTarget.style.transform = 'translateY(0)';
        e.currentTarget.style.boxShadow = 'var(--shadow-sm)';
      }}
    >
      {/* 主题色小圆点 */}
      <div style={{
        position: 'absolute',
        top: '16px',
        right: '16px',
        width: '10px',
        height: '10px',
        borderRadius: '50%',
        background: plan.color,
        zIndex: 2,
        boxShadow: `0 0 12px ${plan.color}80`,
      }} />

      {/* 图片区 */}
      <div style={{
        position: 'relative',
        width: '100%',
        paddingBottom: '100%',
        overflow: 'hidden',
        background: '#FFFFFF',
      }}>
        <img
          src={plan.image}
          alt={plan.title}
          style={{
            position: 'absolute',
            inset: 0,
            width: '100%',
            height: '100%',
            objectFit: 'contain',
            transition: 'transform 0.4s ease',
          }}
          onMouseEnter={e => {
            e.currentTarget.style.transform = 'scale(1.06)';
          }}
          onMouseLeave={e => {
            e.currentTarget.style.transform = 'scale(1)';
          }}
        />
      </div>

      {/* 内容区 */}
      <div style={{ padding: '20px 22px 22px' }}>
        <h3 style={{
          fontSize: '17px',
          fontWeight: 700,
          color: 'var(--text-primary)',
          marginBottom: '8px',
        }}>{plan.title}</h3>

        <div style={{
          height: '1px',
          background: 'var(--border-color)',
          marginBottom: '14px',
        }} />

        <div style={{
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'space-between',
        }}>
          <p style={{
            fontSize: '13px',
            color: 'var(--text-secondary)',
            lineHeight: 1.5,
            flex: 1,
          }}>{plan.slogan}</p>
          <button
            className="plan-detail-btn"
            style={{
              display: 'flex',
              alignItems: 'center',
              gap: '4px',
              fontSize: '13px',
              fontWeight: 500,
              color: plan.color,
              whiteSpace: 'nowrap',
              transition: 'gap 0.2s ease',
              marginLeft: '12px',
            }}
            onMouseEnter={e => {
              e.currentTarget.style.gap = '8px';
            }}
            onMouseLeave={e => {
              e.currentTarget.style.gap = '4px';
            }}
          >
            查看详情
            <ArrowRightIcon />
          </button>
        </div>
      </div>
    </div>
  );
}

// ===== 四大关爱计划区 =====
function PlansSection() {
  return (
    <section
      id="plans-section"
      style={{
        padding: '100px 40px',
        background: 'var(--bg-primary)',
      }}
    >
      <div style={{ maxWidth: '1200px', margin: '0 auto' }}>
        {/* 标题区 */}
        <div style={{
          textAlign: 'center',
          marginBottom: '56px',
        }}>
          <div style={{
            display: 'inline-flex',
            alignItems: 'center',
            padding: '6px 16px',
            borderRadius: '999px',
            background: 'var(--brand-orange-light)',
            marginBottom: '16px',
          }}>
            <span style={{
              fontSize: '13px',
              fontWeight: 600,
              color: 'var(--brand-orange)',
            }}>四大关爱计划</span>
          </div>
          <h2 style={{
            fontSize: 'clamp(28px, 4vw, 42px)',
            fontWeight: 800,
            color: 'var(--text-primary)',
            marginBottom: '16px',
            lineHeight: 1.3,
          }}>
            一个品牌，四种温度
          </h2>
          <p style={{
            fontSize: '16px',
            color: 'var(--text-secondary)',
            maxWidth: '520px',
            margin: '0 auto',
            lineHeight: 1.7,
          }}>
            四大关爱计划，构建温暖而有力量的品牌生态
          </p>
        </div>

        {/* 卡片网格 */}
        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(4, 1fr)',
          gap: '24px',
        }}>
          {plans.map(plan => (
            <PlanCard key={plan.key} plan={plan} />
          ))}
        </div>
      </div>
    </section>
  );
}

// ===== 品牌口号区 =====
function SloganSection() {
  return (
    <section style={{
      padding: '120px 40px',
      background: 'var(--bg-primary)',
      position: 'relative',
      overflow: 'hidden',
    }}>
      {/* 顶部融合渐变 - 与计划区白色自然过渡 */}
      <div style={{
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        height: '180px',
        background: 'linear-gradient(180deg, var(--bg-primary) 0%, rgba(255, 248, 230, 0.5) 50%, rgba(255, 248, 230, 0) 100%)',
        pointerEvents: 'none',
      }} />

      {/* 中心柔光氛围 */}
      <div style={{
        position: 'absolute',
        top: '50%',
        left: '50%',
        transform: 'translate(-50%, -50%)',
        width: '800px',
        height: '400px',
        background: 'radial-gradient(ellipse at center, rgba(255, 240, 210, 0.4) 0%, rgba(255, 230, 200, 0.15) 40%, transparent 70%)',
        pointerEvents: 'none',
      }} />

      {/* 底部融合渐变 - 与页脚白色自然衔接 */}
      <div style={{
        position: 'absolute',
        bottom: 0,
        left: 0,
        right: 0,
        height: '180px',
        background: 'linear-gradient(0deg, var(--bg-primary) 0%, rgba(255, 248, 230, 0.4) 50%, rgba(255, 248, 230, 0) 100%)',
        pointerEvents: 'none',
      }} />
      <div style={{
        maxWidth: '900px',
        margin: '0 auto',
        textAlign: 'center',
        position: 'relative',
        zIndex: 1,
      }}>
        <div style={{
          fontSize: '48px',
          color: 'var(--brand-orange)',
          opacity: 0.3,
          fontFamily: 'serif',
          marginBottom: '16px',
          lineHeight: 1,
        }}>"</div>
        <blockquote style={{
          fontSize: 'clamp(22px, 3vw, 32px)',
          fontWeight: 600,
          color: 'var(--text-primary)',
          lineHeight: 1.7,
          marginBottom: '28px',
          letterSpacing: '1px',
        }}>
          用心守护每一份热爱，用爱共建一个更美好的世界。
        </blockquote>
        <div style={{
          fontSize: '16px',
          color: 'var(--text-secondary)',
          fontWeight: 500,
        }}>
          — 邦纳生态系统
        </div>
      </div>
    </section>
  );
}

// ===== 页脚 =====
function Footer() {
  return (
    <footer style={{
      padding: '48px 40px 32px',
      background: 'var(--bg-primary)',
      borderTop: '1px solid var(--border-color)',
    }}>
      <div style={{
        maxWidth: '1200px',
        margin: '0 auto',
        textAlign: 'center',
      }}>
        <div style={{
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'center',
          gap: '12px',
          marginBottom: '16px',
        }}>
          <LogoIcon size={32} />
          <span style={{
            fontSize: '16px',
            fontWeight: 600,
            color: 'var(--text-primary)',
          }}>邦纳生态系统 · 用爱守护，共创未来</span>
        </div>
        <p style={{
          fontSize: '13px',
          color: 'var(--text-tertiary)',
        }}>
          邦纳玩具 版权所有 Copyright ©2026{' '}
          <a
            href="https://beian.miit.gov.cn/"
            target="_blank"
            rel="noopener noreferrer"
            style={{
              color: 'var(--text-tertiary)',
              textDecoration: 'none',
              transition: 'color 0.2s ease',
            }}
            onMouseEnter={e => {
              e.currentTarget.style.color = 'var(--text-secondary)';
              e.currentTarget.style.textDecoration = 'underline';
            }}
            onMouseLeave={e => {
              e.currentTarget.style.color = 'var(--text-tertiary)';
              e.currentTarget.style.textDecoration = 'none';
            }}
          >
            粤ICP备2026148648号-1
          </a>
        </p>
      </div>
    </footer>
  );
}

// ===== 回到顶部按钮 =====
function BackToTop({ visible }) {
  const scrollToTop = () => {
    window.scrollTo({ top: 0, behavior: 'smooth' });
  };

  return (
    <button
      onClick={scrollToTop}
      style={{
        position: 'fixed',
        bottom: '32px',
        right: '32px',
        width: '48px',
        height: '48px',
        borderRadius: '50%',
        background: '#FFFFFF',
        color: 'var(--brand-orange)',
        boxShadow: 'var(--shadow-md)',
        border: '1px solid var(--border-color)',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center',
        zIndex: 50,
        opacity: visible ? 1 : 0,
        transform: visible ? 'translateY(0)' : 'translateY(12px)',
        pointerEvents: visible ? 'auto' : 'none',
        transition: 'all 0.3s ease',
      }}
      onMouseEnter={e => {
        e.currentTarget.style.background = 'var(--brand-orange)';
        e.currentTarget.style.color = '#FFFFFF';
        e.currentTarget.style.transform = 'translateY(-2px)';
        e.currentTarget.style.boxShadow = 'var(--shadow-lg)';
      }}
      onMouseLeave={e => {
        e.currentTarget.style.background = '#FFFFFF';
        e.currentTarget.style.color = 'var(--brand-orange)';
        e.currentTarget.style.transform = visible ? 'translateY(0)' : 'translateY(12px)';
        e.currentTarget.style.boxShadow = 'var(--shadow-md)';
      }}
    >
      <ArrowUpIcon />
    </button>
  );
}

// ===== 主应用 =====
function App() {
  const [scrolled, setScrolled] = useState(false);
  const [activeNav, setActiveNav] = useState('home');
  const [currentLang, setCurrentLang] = useState('zh-CN');
  const [loginOpen, setLoginOpen] = useState(false);
  const [welcomeOpen, setWelcomeOpen] = useState(false);
  const [user, setUser] = useState(null);
  const [showBackTop, setShowBackTop] = useState(false);

  useEffect(() => {
    const handleScroll = () => {
      const scrollY = window.scrollY;
      setScrolled(scrollY > 20);
      setShowBackTop(scrollY > 400);
    };
    window.addEventListener('scroll', handleScroll, { passive: true });
    return () => window.removeEventListener('scroll', handleScroll);
  }, []);

  const handleNavClick = (key) => {
    setActiveNav(key);
    if (key === 'home') {
      window.scrollTo({ top: 0, behavior: 'smooth' });
    }
  };

  const handleLogin = (identity) => {
    setUser({
      name: identity.user.name,
      dept: identity.user.dept,
      identityLabel: identity.label,
      color: identity.color,
    });
    setLoginOpen(false);
    setTimeout(() => setWelcomeOpen(true), 300);
  };

  const handleLogout = () => {
    setUser(null);
    setActiveNav('home');
  };

  const handleExplore = () => {
    setWelcomeOpen(false);
    const el = document.getElementById('plans-section');
    if (el) el.scrollIntoView({ behavior: 'smooth' });
  };

  return (
    <>
      <style>{`
        @keyframes fadeIn {
          from { opacity: 0; }
          to { opacity: 1; }
        }
        @keyframes fadeInUp {
          from { opacity: 0; transform: translateY(20px); }
          to { opacity: 1; transform: translateY(0); }
        }
        @keyframes fadeInDown {
          from { opacity: 0; transform: translateY(-12px); }
          to { opacity: 1; transform: translateY(0); }
        }
        @keyframes slideUp {
          from { opacity: 0; transform: translateY(24px) scale(0.98); }
          to { opacity: 1; transform: translateY(0) scale(1); }
        }
        @keyframes bounce {
          0%, 100% { transform: translateX(-50%) translateY(0); }
          50% { transform: translateX(-50%) translateY(8px); }
        }
        @keyframes spin {
          to { transform: rotate(360deg); }
        }
        @keyframes sparkle {
          0%, 100% { opacity: 0.6; transform: scale(1) rotate(0deg); }
          50% { opacity: 1; transform: scale(1.2) rotate(15deg); }
        }
        @keyframes earthRotate {
          from { background-position: 0% center; }
          to { background-position: 200% center; }
        }
        @keyframes orbitRotate {
          from { transform: translate(-50%, -50%) rotate(0deg); }
          to { transform: translate(-50%, -50%) rotate(360deg); }
        }
        @keyframes orbitRotateReverse {
          from { transform: translate(-50%, -50%) rotate(360deg); }
          to { transform: translate(-50%, -50%) rotate(0deg); }
        }
        @keyframes glowPulse {
          0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
          50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
        }
        @media (max-width: 1024px) {
          #plans-section > div > div:last-child {
            grid-template-columns: repeat(2, 1fr) !important;
          }
        }
        @media (max-width: 640px) {
          #plans-section > div > div:last-child {
            grid-template-columns: 1fr !important;
          }
          header {
            padding: 0 16px !important;
          }
          header nav {
            display: none !important;
          }
          #plans-section, #slogan-section {
            padding: 60px 20px !important;
          }
        }
      `}</style>

      <Header
        scrolled={scrolled}
        activeNav={activeNav}
        onNavClick={handleNavClick}
        currentLang={currentLang}
        onLangChange={setCurrentLang}
      />

      <main>
        <Hero
          user={user}
          onLoginClick={() => setLoginOpen(true)}
          onLogout={handleLogout}
        />
        <PlansSection />
        <SloganSection />
      </main>

      <Footer />

      <BackToTop visible={showBackTop} />

      <LoginModal
        isOpen={loginOpen}
        onClose={() => setLoginOpen(false)}
        onLogin={handleLogin}
      />

      <WelcomeModal
        isOpen={welcomeOpen}
        onClose={() => setWelcomeOpen(false)}
        onExplore={handleExplore}
      />
    </>
  );
}

ReactDOM.createRoot(document.getElementById('root')).render(<App />);
