<!DOCTYPE html>
<html lang="en">
<head>
<script>
(function() {
    // Check if already initialized
    if (window.securityInitialized) return;
    window.securityInitialized = true;

    // Create and inject CSS
    const style = document.createElement('style');
    style.textContent = `
        #securityOverlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #1e2235, #2d4166);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 999999;
            font-family: system-ui, -apple-system, sans-serif;
        }
        #securityBox {
            background: #fff;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.2);
            width: 90%;
            max-width: 360px;
            animation: securityFadeIn 0.5s;
        }
        #securityInput {
            width: 100%;
            padding: 12px;
            border: 2px solid #ddd;
            border-radius: 8px;
            margin-bottom: 1rem;
            font-size: 16px;
            box-sizing: border-box;
        }
        #securityButton {
            width: 100%;
            padding: 12px;
            background: linear-gradient(45deg, #4a90e2, #5a9ee2);
            border: none;
            border-radius: 8px;
            color: white;
            font-size: 16px;
            cursor: pointer;
        }
        #securityError {
            color: #dc3545;
            margin-top: 1rem;
            text-align: center;
            display: none;
        }
        #securityLocked {
            text-align: center;
            display: none;
        }
        @keyframes securityFadeIn {
            from { opacity: 0; transform: translateY(-20px); }
            to { opacity: 1; transform: translateY(0); }
        }
    `;
    document.head.appendChild(style);

    // Create and inject HTML
    const div = document.createElement('div');
    div.id = 'securityOverlay';
    div.innerHTML = `
        <div id="securityBox">
            <div id="securityForm">
                <input type="password" id="securityInput" placeholder="Enter access code">
                <button id="securityButton">Verify Access</button>
                <div id="securityError">Invalid access code</div>
            </div>
            <div id="securityLocked">
                <h3>Trial Period Expired</h3>
                <p>Contact: Queenaicpu@gmail.com</p>
            </div>
        </div>
    `;

    // Add to DOM when ready
    function injectOverlay() {
        if (document.body) {
            document.body.appendChild(div);
            initSecurity();
        } else {
            setTimeout(injectOverlay, 10);
        }
    }

    function initSecurity() {
        const CORRECT_PASSWORD = '590245';
        const MAX_USES = 10;
        const STORAGE_KEY = '_secure_uses';

        let uses = parseInt(localStorage.getItem(STORAGE_KEY) || '0');

        if (uses >= MAX_USES) {
            document.getElementById('securityForm').style.display = 'none';
            document.getElementById('securityLocked').style.display = 'block';
            return;
        }

        document.getElementById('securityButton').addEventListener('click', verify);
        document.getElementById('securityInput').addEventListener('keypress', e => {
            if (e.key === 'Enter') verify();
        });

        function verify() {
            const input = document.getElementById('securityInput');
            if (input.value === CORRECT_PASSWORD) {
                localStorage.setItem(STORAGE_KEY, (uses + 1).toString());
                document.getElementById('securityOverlay').remove();
            } else {
                document.getElementById('securityError').style.display = 'block';
                input.value = '';
            }
        }
    }

    // Start injection
    injectOverlay();
})();
</script>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Advanced AI Chat Platform</title>
    <script src="https://js.puter.com/v2/"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github-dark.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
    <style>
        /* Core Styles */
        :root {
            --primary-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
            --secondary-gradient: linear-gradient(135deg, #1a1a2e, #16213e);
            --accent-color: #4f46e5;
            --text-primary: #ffffff;
            --text-secondary: #94a3b8;
            --error-color: #ef4444;
            --success-color: #22c55e;
            --warning-color: #f59e0b;
            --info-color: #3b82f6;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
        }

        body {
            background: var(--secondary-gradient);
            color: var(--text-primary);
            min-height: 100vh;
            line-height: 1.5;
        }

        /* Layout Components */
        .app-container {
            display: grid;
            grid-template-columns: 300px 1fr;
            min-height: 100vh;
            position: relative;
        }

        .main-content {
            display: flex;
            flex-direction: column;
            height: 100vh;
        }

        /* Sidebar Styles */
        .sidebar {
            background: rgba(0, 0, 0, 0.3);
            backdrop-filter: blur(10px);
            padding: 1.5rem;
            border-right: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
            transition: transform 0.3s ease;
        }

        .sidebar-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-bottom: 1rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        /* Chat Interface */
        .chat-container {
            flex: 1;
            display: flex;
            flex-direction: column;
            padding: 1.5rem;
            gap: 1.5rem;
            max-height: 100vh;
            overflow: hidden;
        }

        .chat-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 1rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding-right: 1rem;
            scroll-behavior: smooth;
        }

        .message-group {
            display: flex;
            gap: 1rem;
            margin-bottom: 1.5rem;
            animation: slideIn 0.3s ease;
        }

        .message-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--primary-gradient);
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
        }

        .message-content {
            flex: 1;
            background: rgba(255, 255, 255, 0.05);
            padding: 1rem;
            border-radius: 0.5rem;
            position: relative;
        }

        .message-content.user {
            background: rgba(79, 70, 229, 0.1);
        }

        .message-actions {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            display: flex;
            gap: 0.5rem;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .message-content:hover .message-actions {
            opacity: 1;
        }

        /* Input Area */
        .input-container {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 0.5rem;
            padding: 1rem;
            margin-top: auto;
        }

        .input-wrapper {
            display: flex;
            gap: 1rem;
            position: relative;
        }

        .input-field {
            flex: 1;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.5rem;
            padding: 0.75rem;
            color: var(--text-primary);
            resize: none;
            min-height: 50px;
            max-height: 200px;
        }

        /* Buttons and Controls */
        .btn {
            padding: 0.75rem 1.5rem;
            border-radius: 0.5rem;
            border: none;
            cursor: pointer;
            transition: all 0.2s ease;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn-primary {
            background: var(--primary-gradient);
            color: white;
        }

        .btn-secondary {
            background: rgba(255, 255, 255, 0.1);
            color: var(--text-primary);
        }

        .btn:hover {
            transform: translateY(-1px);
            filter: brightness(1.1);
        }

        /* Settings Panel */
        .settings-panel {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 0.5rem;
            padding: 1rem;
            margin-top: 1rem;
        }

        .settings-group {
            margin-bottom: 1rem;
        }

        .settings-label {
            display: block;
            margin-bottom: 0.5rem;
            color: var(--text-secondary);
        }

        .settings-input {
            width: 100%;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 0.25rem;
            padding: 0.5rem;
            color: var(--text-primary);
        }

        /* Code Block Styling */
        pre code {
            border-radius: 0.5rem;
            margin: 1rem 0;
            padding: 1rem !important;
            background: #1a1a2e !important;
        }

        /* Animations */
        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        /* Responsive Design */
        @media (max-width: 768px) {
            .app-container {
                grid-template-columns: 1fr;
            }

            .sidebar {
                position: fixed;
                left: -300px;
                top: 0;
                bottom: 0;
                z-index: 1000;
            }

            .sidebar.active {
                transform: translateX(300px);
            }
        }

        /* Theme Switcher */
        .theme-switcher {
            position: fixed;
            bottom: 1rem;
            right: 1rem;
            z-index: 1000;
        }

        /* Tooltips */
        [data-tooltip] {
            position: relative;
        }

        [data-tooltip]:before {
            content: attr(data-tooltip);
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            padding: 0.5rem;
            background: rgba(0, 0, 0, 0.8);
            border-radius: 0.25rem;
            font-size: 0.875rem;
            white-space: nowrap;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
        }

        [data-tooltip]:hover:before {
            opacity: 1;
            visibility: visible;
        }

        /* Loading States */
        .loading-dots {
            display: flex;
            gap: 0.25rem;
            padding: 0.5rem;
        }

        .loading-dots span {
            width: 8px;
            height: 8px;
            background: var(--text-primary);
            border-radius: 50%;
            animation: dotPulse 1.4s infinite ease-in-out;
        }

        .loading-dots span:nth-child(2) { animation-delay: 0.2s; }
        .loading-dots span:nth-child(3) { animation-delay: 0.4s; }

        @keyframes dotPulse {
            0%, 100% { transform: scale(0.3); }
            50% { transform: scale(1); }
        }
    </style>
</head>
<body>
    <div class="app-container">
        <aside class="sidebar">
            <div class="sidebar-header">
                <h2>AI Chat Platform</h2>
                <button class="btn btn-secondary" id="close-sidebar">×</button>
            </div>

            <div class="settings-panel">
                <h3>Model Settings</h3>
                <div class="settings-group">
                    <label class="settings-label">AI Model</label>
                    <select class="settings-input" id="model-select">
                        <option value="gpt4">GPT-4o</option>
                        <option value="claude">Claude 3.5 Sonnet</option>
                    </select>
                </div>

                <div class="settings-group">
                    <label class="settings-label">Temperature (0-1)</label>
                    <input type="range" min="0" max="100" value="70" class="settings-input" id="temperature">
                    <span id="temperature-value">0.7</span>
                </div>

                <div class="settings-group">
                    <label class="settings-label">Max Tokens</label>
                    <input type="number" value="2048" class="settings-input" id="max-tokens">
                </div>

                <div class="settings-group">
                    <label class="settings-label">System Prompt</label>
                    <textarea class="settings-input" id="system-prompt" rows="3">You are a helpful AI assistant.</textarea>
                </div>
            </div>

            <div class="settings-panel">
                <h3>Chat History</h3>
                <div id="chat-history"></div>
            </div>
        </aside>

        <main class="main-content">
            <div class="chat-container">
                <div class="chat-header">
                    <button class="btn btn-secondary" id="toggle-sidebar">☰</button>
                    <h1>Chat Session</h1>
                    <div class="header-actions">
                        <button class="btn btn-secondary" id="clear-chat">Clear Chat</button>
                        <button class="btn btn-secondary" id="export-chat">Export</button>
                    </div>
                </div>

                <div class="chat-messages" id="chat-messages"></div>

                <div class="input-container">
                    <div class="input-wrapper">
                        <textarea 
                            class="input-field" 
                            id="user-input" 
                            placeholder="Type your message..."
                            rows="1"></textarea>
                        <button class="btn btn-primary" id="send-btn">Send</button>
                    </div>
                </div>
            </div>
        </main>
    </div>

    <script>
        class ChatApp {
            constructor() {
                this.currentModel = 'gpt4';
                this.isProcessing = false;
                this.conversationHistory = [];
                this.initializeElements();
                this.attachEventListeners();
                this.initializeMarkdown();
                this.welcomeMessage();
            }

            initializeElements() {
                // Main elements
                this.chatMessages = document.getElementById('chat-messages');
                this.userInput = document.getElementById('user-input');
                this.sendBtn = document.getElementById('send-btn');
                
                // Sidebar and settings
                this.sidebar = document.querySelector('.sidebar');
                this.toggleSidebarBtn = document.getElementById('toggle-sidebar');
                this.closeSidebarBtn = document.getElementById('close-sidebar');
                
                // Model settings
                this.modelSelect = document.getElementById('model-select');
                this.temperatureInput = document.getElementById('temperature');
                this.temperatureValue = document.getElementById('temperature-value');
                this.maxTokensInput = document.getElementById('max-tokens');
                this.systemPromptInput = document.getElementById('system-prompt');
                
                // Action buttons
                this.clearChatBtn = document.getElementById('clear-chat');
                this.exportChatBtn = document.getElementById('export-chat');
            }

            attachEventListeners() {
                // Main chat interactions
                this.sendBtn.addEventListener('click', () => this.handleSubmit());
                this.userInput.addEventListener('keypress', (e) => {
                    if (e.key === 'Enter' && !e.shiftKey) {
                        e.preventDefault();
                        this.handleSubmit();
                    }
                });
                this.userInput.addEventListener('input', () => this.autoResizeInput());

                // Sidebar controls
                this.toggleSidebarBtn.addEventListener('click', () => this.toggleSidebar());
                this.closeSidebarBtn.addEventListener('click', () => this.toggleSidebar());

                // Settings changes
                this.modelSelect.addEventListener('change', (e) => this.currentModel = e.target.value);
                this.temperatureInput.addEventListener('input', (e) => {
                    this.temperatureValue.textContent = (e.target.value / 100).toFixed(1);
                });

                // Action buttons
                this.clearChatBtn.addEventListener('click', () => this.clearChat());
                this.exportChatBtn.addEventListener('click', () => this.exportChat());
            }

            initializeMarkdown() {
                marked.setOptions({
                    highlight: function(code, lang) {
                        return hljs.highlightAuto(code).value;
                    },
                    breaks: true
                });
            }

            toggleSidebar() {
                this.sidebar.classList.toggle('active');
            }

            autoResizeInput() {
                this.userInput.style.height = 'auto';
                this.userInput.style.height = this.userInput.scrollHeight + 'px';
            }

            addMessage(content, isUser = false) {
                const messageGroup = document.createElement('div');
                messageGroup.className = 'message-group';

                const avatar = document.createElement('div');
                avatar.className = 'message-avatar';
                avatar.textContent = isUser ? 'U' : 'AI';

                const messageContent = document.createElement('div');
                messageContent.className = `message-content ${isUser ? 'user' : ''}`;
                messageContent.innerHTML = isUser ? content : marked.parse(content);

                const actions = document.createElement('div');
                actions.className = 'message-actions';

                const copyBtn = document.createElement('button');
                copyBtn.className = 'btn btn-secondary';
                copyBtn.textContent = 'Copy';
                copyBtn.onclick = () => {
                    navigator.clipboard.writeText(content);
                    copyBtn.textContent = 'Copied!';
                    setTimeout(() => copyBtn.textContent = 'Copy', 2000);
                };

                actions.appendChild(copyBtn);
                messageContent.appendChild(actions);
                messageGroup.appendChild(avatar);
                messageGroup.appendChild(messageContent);

                this.chatMessages.appendChild(messageGroup);
                this.scrollToBottom();

                this.conversationHistory.push({
                    role: isUser ? 'user' : 'assistant',
                    content: content
                });
            }

            addTypingIndicator() {
                const indicator = document.createElement('div');
                indicator.className = 'loading-dots';
                indicator.innerHTML = '<span></span><span></span><span></span>';
                this.chatMessages.appendChild(indicator);
                this.scrollToBottom();
                return indicator;
            }

            scrollToBottom() {
                this.chatMessages.scrollTop = this.chatMessages.scrollHeight;
            }

            async handleSubmit() {
                if (this.isProcessing || !this.userInput.value.trim()) return;

                const message = this.userInput.value.trim();
                this.addMessage(message, true);
                this.userInput.value = '';
                this.autoResizeInput();
                this.isProcessing = true;

                const typingIndicator = this.addTypingIndicator();

                try {
                    const settings = {
                        temperature: this.temperatureInput.value / 100,
                        max_tokens: parseInt(this.maxTokensInput.value),
                        system_prompt: this.systemPromptInput.value
                    };

                    if (this.currentModel === 'gpt4') {
                        const response = await this.handleGPT4Response(message, settings);
                        this.addMessage(response, false);
                    } else {
                        const response = await this.handleClaudeResponse(message, settings);
                        this.addMessage(response, false);
                    }
                } catch (error) {
                    this.addError(`Error: ${error.message}`);
                    console.error('AI Response Error:', error);
                } finally {
                    typingIndicator.remove();
                    this.isProcessing = false;
                }
            }

            async handleGPT4Response(message, settings) {
                const response = await puter.ai.chat(message, {
                    ...settings,
                    stream: true
                });

                let fullResponse = '';
                for await (const part of response) {
                    fullResponse += part?.text || '';
                }
                return fullResponse;
            }

            async handleClaudeResponse(message, settings) {
                const response = await puter.ai.chat(message, {
                    model: 'claude-3-5-sonnet',
                    ...settings
                });
                return response.message.content[0].text;
            }

            addError(message) {
                const errorDiv = document.createElement('div');
                errorDiv.className = 'message-group';
                errorDiv.innerHTML = `
                    <div class="message-content" style="background: rgba(239, 68, 68, 0.2);">
                        ${message}
                    </div>
                `;
                this.chatMessages.appendChild(errorDiv);
                this.scrollToBottom();
            }

            clearChat() {
                if (confirm('Are you sure you want to clear the chat history?')) {
                    this.chatMessages.innerHTML = '';
                    this.conversationHistory = [];
                    this.welcomeMessage();
                }
            }

            exportChat() {
                const chatData = {
                    history: this.conversationHistory,
                    settings: {
                        model: this.currentModel,
                        temperature: this.temperatureInput.value / 100,
                        maxTokens: this.maxTokensInput.value,
                        systemPrompt: this.systemPromptInput.value
                    },
                    timestamp: new Date().toISOString()
                };

                const blob = new Blob([JSON.stringify(chatData, null, 2)], { type: 'application/json' });
                const url = URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.href = url;
                a.download = `chat-export-${new Date().toISOString()}.json`;
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
                URL.revokeObjectURL(url);
            }

            welcomeMessage() {
                this.addMessage("👋 Hello! I'm your AI assistant. I can help you with various tasks, including:\n\n" +
                    "- Answering questions\n" +
                    "- Writing and analyzing text\n" +
                    "- Helping with code\n" +
                    "- Explaining complex topics\n\n" +
                    "Feel free to ask me anything!", false);
            }
        }

        // Initialize the chat application
        document.addEventListener('DOMContentLoaded', () => {
            window.chatApp = new ChatApp();
        });
    </script>
<footer class="modern-footer">
  <style>
    @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Raleway:wght@300;400;600&display=swap');
    
    .modern-footer {
      background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
      color: rgba(255,255,255,0.9);
      padding: 3rem 2rem;
      font-family: 'Raleway', sans-serif;
      text-align: center;
      position: relative;
      overflow: hidden;
      min-height: 250px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      box-shadow: 0 -10px 20px rgba(0,0,0,0.1);
    }

    .modern-footer::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.1) 0%, transparent 50%);
      animation: pulse 4s ease infinite;
    }

    .footer-text {
      position: relative;
      z-index: 1;
      line-height: 1.8;
      animation: fadeIn 1s ease-out;
    }

    .developer-name {
      font-family: 'Cinzel', serif;
      color: #4a90e2;
      font-weight: 700;
      font-size: 1.4em;
      margin: 0.5em 0;
      text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
      transition: all 0.3s ease;
    }

    .developer-name:hover {
      color: #66d9ef;
      transform: scale(1.05);
    }

    .title {
      color: #66d9ef;
      font-size: 1em;
      font-style: italic;
      letter-spacing: 1px;
      margin-bottom: 1em;
    }

    .ai-logo {
      width: 80px;
      height: 80px;
      margin: 1.5em auto;
      position: relative;
    }

    .ai-logo svg {
      width: 100%;
      height: 100%;
      filter: drop-shadow(0 0 8px rgba(102, 217, 239, 0.5));
      animation: float 3s ease-in-out infinite;
    }

    @keyframes float {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-10px); }
    }

    @keyframes pulse {
      0% { opacity: 0.5; }
      50% { opacity: 0.8; }
      100% { opacity: 0.5; }
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(20px); }
      to { opacity: 1; transform: translateY(0); }
    }

    @media (max-width: 768px) {
      .modern-footer {
        padding: 2rem 1rem;
      }
      
      .footer-text {
        font-size: 0.9em;
      }

      .developer-name {
        font-size: 1.2em;
      }

      .ai-logo {
        width: 60px;
        height: 60px;
      }
    }
  </style>

  <div class="footer-text">
    <div>All intellectual and material rights of this work are reserved for the developer</div>
    <div class="developer-name">Thank you, Reza Salehi (Albert)</div>
    <div class="title">AI Platforms & Data Developer</div>
    
    <div class="ai-logo">
      <svg viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M50 10L90 30V70L50 90L10 70V30L50 10Z" stroke="#66d9ef" stroke-width="2"/>
        <path d="M50 10V90" stroke="#66d9ef" stroke-width="2"/>
        <path d="M90 30L10 70" stroke="#66d9ef" stroke-width="2"/>
        <path d="M10 30L90 70" stroke="#66d9ef" stroke-width="2"/>
        <circle cx="50" cy="50" r="10" fill="#4a90e2"/>
        <circle cx="50" cy="50" r="5" fill="#66d9ef"/>
        <circle cx="50" cy="10" r="3" fill="#66d9ef"/>
        <circle cx="90" cy="30" r="3" fill="#66d9ef"/>
        <circle cx="90" cy="70" r="3" fill="#66d9ef"/>
        <circle cx="50" cy="90" r="3" fill="#66d9ef"/>
        <circle cx="10" cy="70" r="3" fill="#66d9ef"/>
        <circle cx="10" cy="30" r="3" fill="#66d9ef"/>
      </svg>
    </div>
  </div>
</footer>
<head>
    <!-- Prevent page indexing by search engines -->
    <meta name="robots" content="noindex, nofollow">
    <meta name="googlebot" content="noindex, nofollow">
</head>
<body>
    <!-- Your page content goes here -->
</body>
</html>