<!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>Wise Owl AI - Advanced Interactive Chat</title>
    <script src="https://js.puter.com/v2/"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #4a90e2;
            --secondary-color: #2c3e50;
            --accent-color: #00c853;
            --background: #ffffff;
            --text: #333333;
            --shadow: rgba(0,0,0,0.1);
            --menu-hover: #f5f5f5;
        }

        [data-theme="dark"] {
            --primary-color: #64b5f6;
            --secondary-color: #34495e;
            --accent-color: #00e676;
            --background: #1a1a1a;
            --text: #ffffff;
            --shadow: rgba(255,255,255,0.1);
            --menu-hover: #2c2c2c;
        }

        [data-theme="vintage"] {
            --primary-color: #8b4513;
            --secondary-color: #a0522d;
            --accent-color: #6b8e23;
            --background: #f5e6d3;
            --text: #4a3728;
            --shadow: rgba(139,69,19,0.1);
            --menu-hover: #e6d5c3;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            transition: all 0.3s ease;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: var(--background);
            color: var(--text);
            min-height: 100vh;
        }

        .app-container {
            display: flex;
            height: 100vh;
        }

        /* Enhanced Sidebar Styles */
        .sidebar {
            width: 300px;
            background: var(--background);
            border-right: 1px solid var(--shadow);
            padding: 20px;
            display: flex;
            flex-direction: column;
            transition: transform 0.3s ease;
            position: fixed;
            height: 100%;
            left: -300px;
            z-index: 1000;
        }

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

        .sidebar-header {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 20px 0;
            border-bottom: 1px solid var(--shadow);
        }

        .sidebar-content {
            flex: 1;
            overflow-y: auto;
        }

        .menu-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px;
            cursor: pointer;
            border-radius: 8px;
            margin: 5px 0;
            color: var(--text);
            text-decoration: none;
        }

        .menu-item:hover {
            background: var(--menu-hover);
        }

        /* Main Chat Area */
        .main-content {
            flex: 1;
            margin-left: 0;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .chat-header {
            padding: 15px 20px;
            background: var(--background);
            border-bottom: 1px solid var(--shadow);
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .hamburger {
            font-size: 24px;
            cursor: pointer;
            padding: 10px;
            border-radius: 50%;
        }

        .chat-container {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            background: var(--background);
        }

        .message {
            display: flex;
            margin-bottom: 20px;
            animation: slideIn 0.3s ease;
        }

        .message.user {
            flex-direction: row-reverse;
        }

        .message-content {
            max-width: 70%;
            padding: 15px;
            border-radius: 15px;
            position: relative;
        }

        .user .message-content {
            background: var(--primary-color);
            color: white;
            margin-left: auto;
        }

        .assistant .message-content {
            background: var(--secondary-color);
            color: white;
        }

        .message-actions {
            display: flex;
            gap: 10px;
            margin-top: 5px;
            opacity: 0;
            transition: opacity 0.3s;
        }

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

        .input-area {
            padding: 20px;
            background: var(--background);
            border-top: 1px solid var(--shadow);
            display: flex;
            gap: 10px;
            position: sticky;
            bottom: 0;
        }

        .input-area textarea {
            flex: 1;
            padding: 15px;
            border: 1px solid var(--shadow);
            border-radius: 25px;
            resize: none;
            background: var(--background);
            color: var(--text);
            font-size: 16px;
            min-height: 50px;
            max-height: 150px;
        }

        .action-buttons {
            display: flex;
            gap: 10px;
        }

        .action-button {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            border: none;
            background: var(--accent-color);
            color: white;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            transition: transform 0.2s;
        }

        .action-button:hover {
            transform: scale(1.1);
        }

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

        @media (max-width: 768px) {
            .sidebar {
                width: 100%;
                left: -100%;
            }
            .sidebar.active {
                transform: translateX(100%);
            }
        }
    </style>
</head>
<body>
    <div class="app-container">
        <!-- Sidebar -->
        <div class="sidebar" id="sidebar">
            <div class="sidebar-header">
                <i class="fas fa-owl fa-2x"></i>
                <h2>Wise Owl AI</h2>
            </div>
            <div class="sidebar-content">
                <div class="menu-item" onclick="startNewChat()">
                    <i class="fas fa-plus"></i>
                    <span>New Chat</span>
                </div>
                <div class="menu-item" onclick="toggleTheme('light')">
                    <i class="fas fa-sun"></i>
                    <span>Light Theme</span>
                </div>
                <div class="menu-item" onclick="toggleTheme('dark')">
                    <i class="fas fa-moon"></i>
                    <span>Dark Theme</span>
                </div>
                <div class="menu-item" onclick="toggleTheme('vintage')">
                    <i class="fas fa-scroll"></i>
                    <span>Vintage Theme</span>
                </div>
                <div class="menu-item" onclick="clearHistory()">
                    <i class="fas fa-trash"></i>
                    <span>Clear History</span>
                </div>
                <a href="mailto:queenaicpu@gmail.com" class="menu-item">
                    <i class="fas fa-envelope"></i>
                    <span>Contact Developer</span>
                </a>
            </div>
        </div>

        <!-- Main Content -->
        <div class="main-content">
            <div class="chat-header">
                <div class="hamburger" onclick="toggleSidebar()">
                    <i class="fas fa-bars"></i>
                </div>
                <h1>Wise Owl Chat</h1>
                <div class="header-actions">
                    <i class="fas fa-microphone" onclick="toggleVoiceInput()"></i>
                </div>
            </div>

            <div class="chat-container" id="chatContainer"></div>

            <div class="input-area">
                <textarea 
                    id="userInput" 
                    placeholder="Ask me anything... Press Enter to send"
                    rows="1"
                    onkeydown="handleKeyPress(event)"
                ></textarea>
                <div class="action-buttons">
                    <button class="action-button" onclick="handleSend()">
                        <i class="fas fa-paper-plane"></i>
                    </button>
                    <button class="action-button" onclick="handleFileUpload()">
                        <i class="fas fa-paperclip"></i>
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        let chatHistory = [];
        let currentTheme = 'light';

        // Initialize from localStorage
        function initializeChat() {
            const savedHistory = localStorage.getItem('chatHistory');
            if (savedHistory) {
                chatHistory = JSON.parse(savedHistory);
                chatHistory.forEach(msg => addMessage(msg.content, msg.role));
            }

            const savedTheme = localStorage.getItem('theme');
            if (savedTheme) {
                toggleTheme(savedTheme);
            }
        }

        // Toggle Sidebar
        function toggleSidebar() {
            document.getElementById('sidebar').classList.toggle('active');
        }

        // Handle Send Message
        async function handleSend() {
            const input = document.getElementById('userInput');
            const message = input.value.trim();
            if (!message) return;

            addMessage(message, 'user');
            input.value = '';

            // Save to history
            chatHistory.push({ role: 'user', content: message });
            saveToLocalStorage();

            // Get AI response
            try {
                const resp = await puter.ai.chat(message, {
                    model: 'grok-beta',
                    stream: true
                });

                let fullResponse = '';
                addMessage('', 'assistant'); // Placeholder for streaming response

                for await (const part of resp) {
                    if (part?.text) {
                        fullResponse += part.text;
                        updateLastMessage(fullResponse);
                    }
                }

                chatHistory.push({ role: 'assistant', content: fullResponse });
                saveToLocalStorage();
            } catch (error) {
                addMessage('Sorry, there was an error processing your request.', 'assistant');
            }
        }

        // Add Message to Chat
        function addMessage(content, role) {
            const chatContainer = document.getElementById('chatContainer');
            const messageDiv = document.createElement('div');
            messageDiv.className = `message ${role}`;
            messageDiv.innerHTML = `
                <div class="message-content">
                    ${content}
                    <div class="message-actions">
                        <i class="fas fa-copy" onclick="copyMessage(this)"></i>
                        <i class="fas fa-share" onclick="shareMessage(this)"></i>
                        <i class="fas fa-download" onclick="downloadMessage(this)"></i>
                    </div>
                </div>
            `;
            chatContainer.appendChild(messageDiv);
            chatContainer.scrollTop = chatContainer.scrollHeight;
        }

        // Update Last Message (for streaming)
        function updateLastMessage(content) {
            const messages = document.querySelectorAll('.message');
            const lastMessage = messages[messages.length - 1];
            if (lastMessage) {
                lastMessage.querySelector('.message-content').innerHTML = content;
            }
        }

        // Theme Toggle
        function toggleTheme(theme) {
            document.documentElement.setAttribute('data-theme', theme);
            currentTheme = theme;
            localStorage.setItem('theme', theme);
        }

        // Clear History
        function clearHistory() {
            chatHistory = [];
            localStorage.removeItem('chatHistory');
            document.getElementById('chatContainer').innerHTML = '';
        }

        // Save to LocalStorage
        function saveToLocalStorage() {
            localStorage.setItem('chatHistory', JSON.stringify(chatHistory));
        }

        // Handle Key Press
        function handleKeyPress(event) {
            if (event.key === 'Enter' && !event.shiftKey) {
                event.preventDefault();
                handleSend();
            }
        }

        // File Upload Handler
        function handleFileUpload() {
            const input = document.createElement('input');
            input.type = 'file';
            input.multiple = true;
            input.onchange = (e) => {
                const files = Array.from(e.target.files);
                files.forEach(file => {
                    const reader = new FileReader();
                    reader.onload = () => {
                        const message = `Uploaded file: ${file.name}`;
                        addMessage(message, 'user');
                        chatHistory.push({ role: 'user', content: message });
                        saveToLocalStorage();
                    };
                    reader.readAsDataURL(file);
                });
            };
            input.click();
        }

        // Copy Message
        function copyMessage(element) {
            const message = element.closest('.message-content').textContent.trim();
            navigator.clipboard.writeText(message);
        }

        // Share Message
        function shareMessage(element) {
            const message = element.closest('.message-content').textContent.trim();
            if (navigator.share) {
                navigator.share({
                    title: 'Wise Owl AI Chat',
                    text: message
                });
            }
        }

        // Download Message
        function downloadMessage(element) {
            const message = element.closest('.message-content').textContent.trim();
            const blob = new Blob([message], { type: 'text/plain' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = 'wise-owl-chat.txt';
            a.click();
            URL.revokeObjectURL(url);
        }

        // Start New Chat
        function startNewChat() {
            document.getElementById('chatContainer').innerHTML = '';
            toggleSidebar();
        }

        // Initialize
        document.addEventListener('DOMContentLoaded', initializeChat);
    </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>