import React, { useState } from 'react';
import { SideBar } from './components/Sidebar';
import { ChatInterface } from './components/ChatInterface';
import { useChatStore } from './store/chatStore';
import './styles/index.scss';

/**
 * Universal Chat Page - 智能问答
 *
 * Design reference: 建科小智.chat
 * - Light theme with purple/pink gradients
 * - Sidebar with chat history and app selection
 * - Clean chat interface with markdown support
 */
const UniversalChat: React.FC = () => {
    const { sidebarOpen } = useChatStore();
    const [key, setKey] = useState(0); // Force re-render on new chat

    // Handle new chat
    const handleNewChat = () => {
        setKey(prev => prev + 1);
    };

    return (
        <div className="universal-chat-container" key={key}>
            <SideBar onNewChat={handleNewChat} />
            <ChatInterface />
        </div>
    );
};

export default UniversalChat;
