<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Data Life Eyes Pro - Secure Access</title>
    <style>
        #auth-system {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        }

        #auth-system * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        .auth-container {
            width: 90%;
            max-width: 380px;
            background: rgba(255, 255, 255, 0.95);
            padding: 2.5rem;
            border-radius: 20px;
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
            backdrop-filter: blur(10px);
            animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
            position: relative;
            overflow: hidden;
        }

        .auth-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 4px;
            background: linear-gradient(90deg, #ff4757, #5352ed, #20bf6b);
            animation: shimmer 2s linear infinite;
        }

        .auth-header {
            text-align: center;
            margin-bottom: 2.5rem;
        }

        .auth-logo-container {
            position: relative;
            height: 80px;
            margin-bottom: 1.5rem;
        }

        .auth-logo {
            font-size: 3.5rem;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            animation: logoFloat 3s ease-in-out infinite;
        }

        .auth-logo-shadow {
            width: 50px;
            height: 10px;
            background: rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            animation: shadowPulse 3s ease-in-out infinite;
        }

        .auth-title {
            color: #1a1a1a;
            font-size: 1.8rem;
            font-weight: 700;
            margin-bottom: 0.5rem;
            background: linear-gradient(45deg, #1a2a6c, #b21f1f);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .auth-subtitle {
            color: #666;
            font-size: 1rem;
            font-weight: 500;
            opacity: 0.8;
        }

        .auth-form {
            position: relative;
        }

        .input-container {
            position: relative;
            margin-bottom: 1.5rem;
        }

        .auth-input {
            width: 100%;
            padding: 1.2rem;
            border: 2px solid #e0e0e0;
            border-radius: 12px;
            font-size: 1.1rem;
            font-weight: 500;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            background: rgba(255, 255, 255, 0.9);
            letter-spacing: 0.2em;
            text-align: center;
        }

        .auth-input:focus {
            border-color: #1a2a6c;
            outline: none;
            box-shadow: 0 0 0 4px rgba(26, 42, 108, 0.15);
        }

        .auth-input::placeholder {
            color: #999;
            letter-spacing: normal;
        }

        .auth-hint {
            font-size: 0.9rem;
            color: #666;
            margin: 0.5rem 0;
            text-align: center;
            font-weight: 500;
        }

        .auth-error {
            color: #ff4757;
            font-size: 0.9rem;
            margin: 0.5rem 0;
            min-height: 1.2rem;
            text-align: center;
            font-weight: 500;
            transform: translateY(0);
            transition: all 0.3s ease;
        }

        .auth-error.shake {
            animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
        }

        .auth-button {
            width: 100%;
            padding: 1.2rem;
            border: none;
            border-radius: 12px;
            background: linear-gradient(45deg, #1a2a6c, #b21f1f);
            background-size: 200% 200%;
            color: white;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .auth-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(26, 42, 108, 0.2);
            animation: gradientMove 3s ease infinite;
        }

        .auth-button:active {
            transform: translateY(0);
        }

        .auth-button:disabled {
            opacity: 0.7;
            cursor: not-allowed;
        }

        .loader {
            display: none;
            width: 24px;
            height: 24px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-radius: 50%;
            border-top-color: white;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            animation: spin 0.8s linear infinite;
        }

        .digit-display {
            display: flex;
            justify-content: center;
            gap: 8px;
            margin-bottom: 1rem;
        }

        .digit {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #e0e0e0;
            transition: all 0.3s ease;
        }

        .digit.filled {
            background: #1a2a6c;
            transform: scale(1.2);
        }

        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        @keyframes slideUp {
            0% {
                opacity: 0;
                transform: translateY(30px);
            }
            100% {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes logoFloat {
            0%, 100% { transform: translateY(0) translateX(-50%); }
            50% { transform: translateY(-15px) translateX(-50%); }
        }

        @keyframes shadowPulse {
            0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.3; }
            50% { transform: translateX(-50%) scale(0.7); opacity: 0.1; }
        }

        @keyframes shake {
            10%, 90% { transform: translateX(-1px); }
            20%, 80% { transform: translateX(2px); }
            30%, 50%, 70% { transform: translateX(-4px); }
            40%, 60% { transform: translateX(4px); }
        }

        @keyframes shimmer {
            0% { background-position: -200% 0; }
            100% { background-position: 200% 0; }
        }

        @keyframes gradientMove {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        @media (max-width: 480px) {
            .auth-container {
                padding: 2rem;
                width: 95%;
            }

            .auth-title {
                font-size: 1.5rem;
            }

            .auth-input {
                font-size: 1rem;
                padding: 1rem;
            }
        }
    </style>
</head>
<body>
    <div id="auth-system">
        <div class="auth-container">
            <div class="auth-header">
                <div class="auth-logo-container">
                    <div class="auth-logo">👁️🔐</div>
                    <div class="auth-logo-shadow"></div>
                </div>
                <h1 class="auth-title">chat Pro</h1>
                <p class="auth-subtitle">Secure Authentication Required</p>
            </div>
            <form class="auth-form" onsubmit="return authenticateUser(event)">
                <div class="digit-display">
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                    <div class="digit"></div>
                </div>
                <div class="input-container">
                    <input 
                        type="password" 
                        class="auth-input" 
                        id="authCode"
                        placeholder="Enter Security Code"
                        maxlength="6"
                        pattern="[0-9]*"
                        inputmode="numeric"
                        autocomplete="off"
                        required
                    >
                </div>
                <div class="auth-hint">Please enter your 6-digit security code</div>
                <div class="auth-error" id="authError"></div>
                <button type="submit" class="auth-button" id="authButton">
                    <span class="button-text">Verify Access</span>
                    <span class="loader"></span>
                </button>
            </form>
        </div>
    </div>

    <script>
        function authenticateUser(event) {
            event.preventDefault();
            
            const input = document.getElementById('authCode');
            const error = document.getElementById('authError');
            const button = document.getElementById('authButton');
            const buttonText = button.querySelector('.button-text');
            const loader = button.querySelector('.loader');
            
            // Reset error
            error.textContent = '';
            
            // Validate input
            if (!/^\d{6}$/.test(input.value)) {
                showError('Please enter a valid 6-digit code');
                return false;
            }
            
            // Show loading state
            button.disabled = true;
            buttonText.style.opacity = '0';
            loader.style.display = 'block';
            
            // Authenticate with delay for UX
            setTimeout(() => {
                if (input.value === '590245') {
                    localStorage.setItem('authenticated', 'true');
                    
                    // Success animation
                    document.getElementById('auth-system').style.transition = 'opacity 0.5s ease';
                    document.getElementById('auth-system').style.opacity = '0';
                    
                    setTimeout(() => {
                        document.getElementById('auth-system').style.display = 'none';
                    }, 500);
                } else {
                    showError('Invalid security code');
                    button.disabled = false;
                    buttonText.style.opacity = '1';
                    loader.style.display = 'none';
                    input.value = '';
                    input.focus();
                    updateDigitDisplay('');
                }
            }, 1500);
            
            return false;
        }

        function showError(message) {
            const error = document.getElementById('authError');
            error.textContent = message;
            error.classList.add('shake');
            setTimeout(() => error.classList.remove('shake'), 500);
        }

        function updateDigitDisplay(value) {
            const digits = document.querySelectorAll('.digit');
            digits.forEach((digit, index) => {
                digit.classList.toggle('filled', index < value.length);
            });
        }

        // Input validation and digit display update
        document.getElementById('authCode').addEventListener('input', (e) => {
            const input = e.target;
            const error = document.getElementById('authError');
            
            if (input.value.length > 0 && !/^\d+$/.test(input.value)) {
                error.textContent = 'Numbers only';
                input.value = input.value.replace(/\D/g, '');
            } else {
                error.textContent = '';
            }
            
            updateDigitDisplay(input.value);
        });

        // Check if already authenticated
        if (localStorage.getItem('authenticated') === 'true') {
            document.getElementById('auth-system').style.display = 'none';
        }
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wise Owl AI - Advanced Chat Interface</title>
    <script src="https://js.puter.com/v2/"></script>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/prismjs@1.24.1/themes/prism.css" rel="stylesheet" />
    <script src="https://cdn.jsdelivr.net/npm/prismjs@1.24.1/prism.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>

    <style>
        /* Core Styles */
        :root {
            --primary-color: #84fab0;
            --secondary-color: #8fd3f4;
            --accent-color: #4f46e5;
            --text-primary: #1f2937;
            --text-secondary: #6b7280;
        }

        .gradient-bg {
            background: linear-gradient(120deg, var(--primary-color) 0%, var(--secondary-color) 100%);
        }

        /* Enhanced Animation Effects */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

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

        .animate-fade-in {
            animation: fadeIn 0.5s ease-out forwards;
        }

        /* Chat Interface */
        .chat-container {
            height: calc(100vh - 180px);
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
        }

        .message-box {
            transition: all 0.3s ease;
            opacity: 0;
            animation: fadeIn 0.5s ease-out forwards;
        }

        .message-box:hover {
            transform: scale(1.01);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        /* Advanced UI Components */
        .glass-morphism {
            background: rgba(255, 255, 255, 0.7);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .floating-input {
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }

        .floating-input:focus {
            transform: translateY(-2px);
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        }

        /* File Upload Zone */
        .file-drop-zone {
            border: 2px dashed #ccc;
            transition: all 0.3s ease;
            background: rgba(255, 255, 255, 0.5);
        }

        .file-drop-zone.drag-over {
            border-color: var(--primary-color);
            background: rgba(132, 250, 176, 0.1);
            transform: scale(1.02);
        }

        /* Voice/Video Chat Controls */
        .media-controls {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 10px;
            padding: 10px;
            background: rgba(0, 0, 0, 0.8);
            border-radius: 50px;
            z-index: 1000;
        }

        .media-button {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.2);
            color: white;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .media-button:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
        }

        /* Code Block Styling */
        .code-block {
            background: #1e1e1e;
            border-radius: 8px;
            padding: 1rem;
            margin: 1rem 0;
            position: relative;
        }

        .code-block pre {
            margin: 0;
            padding: 0;
            overflow-x: auto;
        }

        .code-block .copy-button {
            position: absolute;
            top: 8px;
            right: 8px;
            padding: 4px 8px;
            background: rgba(255, 255, 255, 0.1);
            border: none;
            border-radius: 4px;
            color: #fff;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        /* Loading Indicators */
        .typing-indicator {
            display: flex;
            gap: 4px;
            padding: 8px;
            background: rgba(0, 0, 0, 0.05);
            border-radius: 20px;
            width: fit-content;
        }

        .typing-dot {
            width: 8px;
            height: 8px;
            background: var(--text-secondary);
            border-radius: 50%;
            animation: typing 1s infinite ease-in-out;
        }

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

        /* Responsive Design */
        @media (max-width: 768px) {
            .chat-container {
                height: calc(100vh - 140px);
            }

            .media-controls {
                bottom: 10px;
                padding: 5px;
            }

            .media-button {
                width: 32px;
                height: 32px;
            }
        }

        /* Theme Toggle */
        .theme-switch {
            position: relative;
            width: 60px;
            height: 30px;
            background: #ddd;
            border-radius: 15px;
            cursor: pointer;
        }

        .theme-switch::after {
            content: '';
            position: absolute;
            width: 26px;
            height: 26px;
            background: white;
            border-radius: 50%;
            top: 2px;
            left: 2px;
            transition: all 0.3s ease;
        }

        .theme-switch.dark::after {
            transform: translateX(30px);
        }

        /* Dark Mode Styles */
        .dark-mode {
            --text-primary: #f3f4f6;
            --text-secondary: #d1d5db;
            background: #1a1a1a;
            color: var(--text-primary);
        }

        .dark-mode .chat-container {
            background: rgba(0, 0, 0, 0.95);
        }

        .dark-mode .message-box {
            background: rgba(255, 255, 255, 0.1);
        }
    </style>
</head>
<body class="bg-gray-100">
    <!-- App Container -->
    <div id="app" class="min-h-screen flex flex-col">
        <!-- Header -->
        <header class="gradient-bg p-4 shadow-lg">
            <div class="container mx-auto flex justify-between items-center">
                <div class="flex items-center space-x-3">
                    <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='32' height='32'%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z'%3E%3C/path%3E%3Ccircle cx='17' cy='4' r='2' fill='currentColor'/%3E%3C/svg%3E" alt="Wise Owl Logo" class="w-8 h-8">
                    <h1 class="text-2xl font-bold text-white">Wise Owl AI</h1>
                </div>
                <div class="flex items-center space-x-4">
                    <div class="theme-switch" id="themeToggle"></div>
                    <button id="menuButton" class="text-white">
                        <i class="fas fa-bars text-2xl"></i>
                    </button>
                </div>
            </div>
        </header>

        <!-- Main Chat Interface -->
        <main class="flex-1 container mx-auto p-4">
            <div class="chat-container rounded-lg shadow-lg p-4 flex flex-col">
                <!-- Chat Messages -->
                <div id="chatMessages" class="flex-1 overflow-y-auto space-y-4 mb-4"></div>

                <!-- Input Area -->
                <div class="border-t pt-4">
                    <div class="file-drop-zone p-4 mb-4 rounded-lg">
                        <div class="text-center text-gray-500">
                            <i class="fas fa-cloud-upload-alt text-2xl mb-2"></i>
                            <p>Drop files here or click to upload</p>
                            <input type="file" id="fileInput" class="hidden" multiple>
                        </div>
                    </div>
                    <div class="flex space-x-2">
                        <button id="voiceButton" class="media-button">
                            <i class="fas fa-microphone"></i>
                        </button>
                        <button id="videoButton" class="media-button">
                            <i class="fas fa-video"></i>
                        </button>
                        <input type="text" id="messageInput" class="floating-input flex-1 border rounded-lg px-4 py-2 focus:outline-none focus:ring-2 focus:ring-green-400" placeholder="Type your message...">
                        <button id="sendButton" class="bg-green-500 text-white px-6 py-2 rounded-lg hover:bg-green-600">
                            <i class="fas fa-paper-plane"></i>
                        </button>
                    </div>
                </div>
            </div>
        </main>

        <!-- Media Stream Container -->
        <div id="mediaContainer" class="hidden fixed bottom-20 right-4 w-64 h-48 bg-black rounded-lg overflow-hidden">
            <video id="localVideo" autoplay muted class="w-full h-full object-cover"></video>
            <video id="remoteVideo" autoplay class="hidden w-full h-full object-cover"></video>
        </div>

        <!-- Side Menu -->
        <div id="sideMenu" class="fixed top-0 right-0 h-full w-72 bg-white shadow-lg transform translate-x-full transition-transform duration-300 ease-in-out z-50">
            <!-- Menu Content -->
            <div class="p-4">
                <div class="flex justify-between items-center mb-6">
                    <h2 class="text-xl font-bold">Settings</h2>
                    <button id="closeMenu" class="text-gray-600 hover:text-gray-800">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
                
                <!-- Menu Items -->
                <nav class="space-y-4">
                    <a href="#" class="block p-2 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-plus-circle mr-2"></i> New Chat
                    </a>
                    <a href="mailto:queenaicpu@gmail.com" class="block p-2 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-envelope mr-2"></i> Contact Developer
                    </a>
                    <a href="#" id="clearHistory" class="block p-2 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-trash mr-2"></i> Clear History
                    </a>
                    
                    <!-- AI Model Selection -->
                    <div class="mt-4">
                        <label class="block text-sm font-medium mb-2">AI Model</label>
                        <select id="modelSelect" class="w-full p-2 border rounded-lg">
                            <option value="gpt-4">GPT-4</option>
                            <option value="claude-3-5-sonnet">Claude 3.5 Sonnet</option>
                        </select>
                    </div>

                    <!-- Language Selection -->
                    <div class="mt-4">
                        <label class="block text-sm font-medium mb-2">Language</label>
                        <select id="languageSelect" class="w-full p-2 border rounded-lg">
                            <option value="en">English</option>
                            <option value="es">Español</option>
                            <option value="fr">Français</option>
                            <option value="de">Deutsch</option>
                            <option value="fa">فارسی</option>
                        </select>
                    </div>

                    <!-- Voice Settings -->
                    <div class="mt-4">
                        <label class="block text-sm font-medium mb-2">Voice Settings</label>
                        <div class="space-y-2">
                            <div class="flex items-center">
                                <input type="checkbox" id="voiceEnabled" class="mr-2">
                                <label>Enable Voice Input</label>
                            </div>
                            <div class="flex items-center">
                                <input type="checkbox" id="ttsEnabled" class="mr-2">
                                <label>Enable Text-to-Speech</label>
                            </div>
                        </div>
                    </div>

                    <!-- Theme Settings -->
                    <div class="mt-4">
                        <label class="block text-sm font-medium mb-2">Theme</label>
                        <div class="flex items-center justify-between">
                            <span>Dark Mode</span>
                            <div class="theme-switch" id="themeSwitchInMenu"></div>
                        </div>
                    </div>
                </nav>
            </div>
        </div>
    </div>

    <!-- Templates -->
    <template id="messageTemplate">
        <div class="message-box p-4 rounded-lg">
            <div class="flex items-center space-x-2 mb-2">
                <img src="" alt="" class="w-6 h-6">
                <span class="font-semibold"></span>
                <span class="text-xs text-gray-500"></span>
            </div>
            <div class="message-content"></div>
            <div class="message-actions mt-2 flex space-x-2">
                <button class="text-sm text-gray-500 hover:text-gray-700">
                    <i class="fas fa-copy"></i>
                </button>
                <button class="text-sm text-gray-500 hover:text-gray-700">
                    <i class="fas fa-share"></i>
                </button>
            </div>
        </div>
    </template>

    <script>
        // Main Application Logic
        class WiseOwlAI {
            constructor() {
                this.initializeElements();
                this.attachEventListeners();
                this.loadChatHistory();
                this.initializeWebRTC();
                this.setupTheme();
            }

            initializeElements() {
                // Chat elements
                this.messageInput = document.getElementById('messageInput');
                this.sendButton = document.getElementById('sendButton');
                this.chatMessages = document.getElementById('chatMessages');
                this.modelSelect = document.getElementById('modelSelect');
                this.fileInput = document.getElementById('fileInput');
                this.dropZone = document.querySelector('.file-drop-zone');

                // Media elements
                this.voiceButton = document.getElementById('voiceButton');
                this.videoButton = document.getElementById('videoButton');
                this.mediaContainer = document.getElementById('mediaContainer');
                this.localVideo = document.getElementById('localVideo');
                this.remoteVideo = document.getElementById('remoteVideo');

                // Menu elements
                this.menuButton = document.getElementById('menuButton');
                this.closeMenu = document.getElementById('closeMenu');
                this.sideMenu = document.getElementById('sideMenu');
                this.clearHistory = document.getElementById('clearHistory');
                
                // Theme elements
                this.themeToggle = document.getElementById('themeToggle');
                this.themeSwitchInMenu = document.getElementById('themeSwitchInMenu');
            }

            attachEventListeners() {
                // Chat events
                this.sendButton.addEventListener('click', () => this.sendMessage());
                this.messageInput.addEventListener('keypress', (e) => {
                    if (e.key === 'Enter' && !e.shiftKey) {
                        e.preventDefault();
                        this.sendMessage();
                    }
                });

                // File handling events
                this.dropZone.addEventListener('dragover', (e) => {
                    e.preventDefault();
                    this.dropZone.classList.add('drag-over');
                });

                this.dropZone.addEventListener('dragleave', () => {
                    this.dropZone.classList.remove('drag-over');
                });

                this.dropZone.addEventListener('drop', (e) => {
                    e.preventDefault();
                    this.dropZone.classList.remove('drag-over');
                    this.handleFiles(Array.from(e.dataTransfer.files));
                });

                // Menu events
                this.menuButton.addEventListener('click', () => {
                    this.sideMenu.classList.remove('translate-x-full');
                });

                this.closeMenu.addEventListener('click', () => {
                    this.sideMenu.classList.add('translate-x-full');
                });

                this.clearHistory.addEventListener('click', () => {
                    this.clearChatHistory();
                });

                // Media events
                this.voiceButton.addEventListener('click', () => this.toggleVoiceChat());
                this.videoButton.addEventListener('click', () => this.toggleVideoChat());

                // Theme events
                this.themeToggle.addEventListener('click', () => this.toggleTheme());
                this.themeSwitchInMenu.addEventListener('click', () => this.toggleTheme());
            }

            async sendMessage() {
                const message = this.messageInput.value.trim();
                if (!message) return;

                this.addMessage('User', message, 'user');
                this.messageInput.value = '';
                this.showTypingIndicator();

                try {
                    const response = await puter.ai.chat(message, {
                        model: this.modelSelect.value,
                        stream: true
                    });

                    this.removeTypingIndicator();
                    let responseText = '';
                    
                    for await (const part of response) {
                        if (part?.text) {
                            responseText += part.text;
                            this.updateLastMessage('Wise Owl', responseText);
                        }
                    }
                } catch (error) {
                    console.error('Error:', error);
                    this.removeTypingIndicator();
                    this.addMessage('System', 'An error occurred. Please try again.', 'error');
                }
            }

            addMessage(sender, text, type = 'assistant') {
                const template = document.getElementById('messageTemplate');
                const messageElement = template.content.cloneNode(true);

                const messageBox = messageElement.querySelector('.message-box');
                messageBox.classList.add(type === 'user' ? 'bg-green-50' : 'bg-gray-100');

                const avatar = messageElement.querySelector('img');
                avatar.src = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 3c.132 0 0 .263 0 .393a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z'%3E%3C/path%3E%3Ccircle cx='17' cy='4' r='2' fill='currentColor'/%3E%3C/svg%3E`;
                avatar.alt = sender;

                messageElement.querySelector('.font-semibold').textContent = sender;
                messageElement.querySelector('.text-xs').textContent = new Date().toLocaleTimeString();
                messageElement.querySelector('.message-content').innerHTML = this.formatMessage(text);

                // Add copy and share functionality
                const copyButton = messageElement.querySelector('.fa-copy').parentElement;
                copyButton.addEventListener('click', () => this.copyToClipboard(text));

                const shareButton = messageElement.querySelector('.fa-share').parentElement;
                shareButton.addEventListener('click', () => this.shareMessage(text));

                this.chatMessages.appendChild(messageElement);
                this.chatMessages.scrollTop = this.chatMessages.scrollHeight;
                this.saveChatHistory();
            }

            formatMessage(text) {
                // Convert markdown to HTML
                return marked.parse(text);
            }

            updateLastMessage(sender, text) {
                const lastMessage = this.chatMessages.lastElementChild;
                if (lastMessage) {
                    const content = lastMessage.querySelector('.message-content');
                    if (content) {
                        content.innerHTML = this.formatMessage(text);
                    }
                } else {
                    this.addMessage(sender, text);
                }
                this.saveChatHistory();
            }

            showTypingIndicator() {
                const indicator = document.createElement('div');
                indicator.id = 'typingIndicator';
                indicator.className = 'message-box bg-gray-100 p-4 rounded-lg';
                indicator.innerHTML = `
                    <div class="flex items-center space-x-2">
                        <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 3c.132 0 0 .263 0 .393a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z'%3E%3C/path%3E%3Ccircle cx='17' cy='4' r='2' fill='currentColor'/%3E%3C/svg%3E" alt="Wise Owl" class="w-6 h-6">
                        <div class="typing-indicator">
                            <span class="typing-dot"></span>
                            <span class="typing-dot"></span>
                            <span class="typing-dot"></span>
                        </div>
                    </div>
                `;
                this.chatMessages.appendChild(indicator);
                this.chatMessages.scrollTop = this.chatMessages.scrollHeight;
            }

            removeTypingIndicator() {
                const indicator = document.getElementById('typingIndicator');
                if (indicator) indicator.remove();
            }

            async handleFiles(files) {
                for (const file of files) {
                    if (file.type.startsWith('image/')) {
                        const reader = new FileReader();
                        reader.onload = async (e) => {
                            const imageData = e.target.result;
                            this.addMessage('User', `Uploaded image: ${file.name}`, 'user');
                            
                            try {
                                const response = await puter.ai.chat(
                                    "What do you see in this image?",
                                    imageData
                                );
                                this.addMessage('Wise Owl', response);
                            } catch (error) {
                                console.error('Error analyzing image:', error);
                                this.addMessage('System', 'Error analyzing image', 'error');
                            }
                        };
                        reader.readAsDataURL(file);
                    } else {
                        this.addMessage('User', `Uploaded file: ${file.name}`, 'user');
                    }
                }
            }

            async toggleVoiceChat() {
                try {
                    if (!this.isVoiceChatActive) {
                        const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
                        this.localStream = stream;
                        this.isVoiceChatActive = true;
                        this.voiceButton.classList.add('bg-red-500');
                        // Initialize voice recognition here
                    } else {
                        this.stopMediaStream();
                    }
                } catch (error) {
                    console.error('Error accessing microphone:', error);
                    this.addMessage('System', 'Error accessing microphone', 'error');
                }
            }

            async toggleVideoChat() {
                try {
                    if (!this.isVideoChatActive) {
                        const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
                        this.localVideo.srcObject = stream;
                        this.localStream = stream;
                        this.isVideoChatActive = true;
                        this.mediaContainer.classList.remove('hidden');
                        this.videoButton.classList.add('bg-red-500');
                    } else {
                        this.stopMediaStream();
                    }
                } catch (error) {
                    console.error('Error accessing camera:', error);
                    this.addMessage('System', 'Error accessing camera', 'error');
                }
            }

            stopMediaStream() {
                if (this.localStream) {
                    this.localStream.getTracks().forEach(track => track.stop());
                    this.localStream = null;
                }
                this.isVoiceChatActive = false;
                this.isVideoChatActive = false;
                this.voiceButton.classList.remove('bg-red-500');
                this.videoButton.classList.remove('bg-red-500');
                this.mediaContainer.classList.add('hidden');
            }

            initializeWebRTC() {
                this.peerConnection = new RTCPeerConnection({
                    iceServers: [
                        { urls: 'stun:stun.l.google.com:19302' },
                        { urls: 'stun:stun1.l.google.com:19302' }
                    ]
                });

                this.peerConnection.ontrack = (event) => {
                    this.remoteVideo.srcObject = event.streams[0];
                    this.remoteVideo.classList.remove('hidden');
                };
            }

            async copyToClipboard(text) {
                try {
                    await navigator.clipboard.writeText(text);
                    this.showNotification('Copied to clipboard!');
                } catch (error) {
                    console.error('Error copying to clipboard:', error);
                }
            }

            shareMessage(text) {
                if (navigator.share) {
                    navigator.share({
                        title: 'Shared from Wise Owl AI',
                        text: text
                    }).catch(console.error);
                } else {
                    this.copyToClipboard(text);
                }
            }

            showNotification(message) {
                const notification = document.createElement('div');
                notification.className = 'fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-black text-white px-4 py-2 rounded-lg opacity-0 transition-opacity duration-300';
                notification.textContent = message;
                document.body.appendChild(notification);

                setTimeout(() => notification.classList.add('opacity-100'), 100);
                setTimeout(() => {
                    notification.classList.remove('opacity-100');
                    setTimeout(() => notification.remove(), 300);
                }, 2000);
            }

            saveChatHistory() {
                const history = Array.from(this.chatMessages.children).map(message => ({
                    sender: message.querySelector('.font-semibold').textContent,
                    text: message.querySelector('.message-content').innerHTML,
                    type: message.classList.contains('bg-green-50') ? 'user' : 'assistant',
                    timestamp: message.querySelector('.text-xs').textContent
                }));
                localStorage.setItem('chatHistory', JSON.stringify(history));
            }

            loadChatHistory() {
                const history = JSON.parse(localStorage.getItem('chatHistory') || '[]');
                history.forEach(message => {
                    this.addMessage(message.sender, message.text, message.type);
                });
            }

            clearChatHistory() {
                localStorage.removeItem('chatHistory');
                this.chatMessages.innerHTML = '';
                this.showNotification('Chat history cleared');
            }

            setupTheme() {
                const darkMode = localStorage.getItem('darkMode') === 'true';
                if (darkMode) {
                    document.body.classList.add('dark-mode');
                    this.themeToggle.classList.add('dark');
                    this.themeSwitchInMenu.classList.add('dark');
                }
            }

            toggleTheme() {
                const isDark = document.body.classList.toggle('dark-mode');
                this.themeToggle.classList.toggle('dark');
                this.themeSwitchInMenu.classList.toggle('dark');
                localStorage.setItem('darkMode', isDark);
            }
        }

        // Initialize the application
        document.addEventListener('DOMContentLoaded', () => {
            window.wiseOwl = new WiseOwlAI();
        });
    </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>