<!DOCTYPE html>
<html lang="pl" class="scroll-smooth">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claude Chat - Streaming AI Assistant</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
'claude-blue': '#4F46E5',
'claude-purple': '#7C3AED',
'claude-pink': '#EC4899',
'claude-cyan': '#06B6D4'
},
animation: {
'float': 'float 6s ease-in-out infinite',
'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
'gradient': 'gradient 8s ease infinite',
'typing': 'typing 1s steps(3) infinite'
},
keyframes: {
float: {
'0%, 100%': { transform: 'translateY(0px)' },
'50%': { transform: 'translateY(-20px)' }
},
gradient: {
'0%, 100%': { backgroundPosition: '0% 50%' },
'50%': { backgroundPosition: '100% 50%' }
},
typing: {
'0%': { content: '.' },
'33%': { content: '..' },
'66%': { content: '...' }
}
}
}
}
}
</script>
<style>
.glass {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.gradient-bg {
background: linear-gradient(-45deg, #4F46E5, #7C3AED, #EC4899, #06B6D4);
background-size: 400% 400%;
animation: gradient 8s ease infinite;
}
.message-enter {
animation: slideInUp 0.3s ease-out;
}
@keyframes slideInUp {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
.typing-indicator::after {
content: '';
animation: typing 1.5s infinite;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- Header -->
<header class="glass fixed top-0 w-full z-50 border-b border-white/20">
<div class="max-w-4xl mx-auto px-4 py-3 flex items-center justify-between">
<div class="flex items-center space-x-3">
<div class="w-8 h-8 gradient-bg rounded-lg flex items-center justify-center animate-float">
<span class="text-white font-bold text-sm">C</span>
</div>
<h1 class="text-xl font-bold bg-gradient-to-r from-claude-blue to-claude-purple bg-clip-text text-transparent">
Claude Chat
</h1>
</div>
<div class="flex items-center space-x-2">
<div class="w-2 h-2 bg-green-400 rounded-full animate-pulse"></div>
<span class="text-sm text-gray-600">Online</span>
</div>
</div>
</header>
<!-- Main Container -->
<main class="pt-20 pb-24 max-w-4xl mx-auto px-4">
<!-- Welcome Message -->
<div id="welcome" class="text-center py-12 animate-float">
<div class="w-16 h-16 gradient-bg rounded-2xl mx-auto mb-6 flex items-center justify-center">
<span class="text-white text-2xl font-bold">👋</span>
</div>
<h2 class="text-3xl font-bold text-gray-800 mb-4">Witaj w Claude Chat!</h2>
<p class="text-gray-600 max-w-md mx-auto">Jestem Claude, Twój AI asystent. Zadaj mi pytanie lub rozpocznij rozmowę!</p>
</div>
<!-- Chat Messages -->
<div id="messages" class="space-y-6"></div>
</main>
<!-- Input Area -->
<div class="fixed bottom-0 w-full glass border-t border-white/20">
<div class="max-w-4xl mx-auto p-4">
<div class="relative">
<textarea
id="messageInput"
placeholder="Napisz wiadomość..."
class="w-full p-4 pr-16 rounded-2xl border border-gray-200 focus:border-claude-blue focus:ring-2 focus:ring-claude-blue/20 outline-none resize-none transition-all duration-300 bg-white/80 backdrop-blur-sm"
rows="1"
></textarea>
<button
id="sendButton"
class="absolute right-2 top-1/2 transform -translate-y-1/2 w-10 h-10 gradient-bg rounded-xl flex items-center justify-center text-white hover:scale-105 transition-transform duration-200 disabled:opacity-50"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 19l9 2-9-18-9 18 9-2zm0 0v-8"></path>
</svg>
</button>
</div>
</div>
</div>
<script>
class ChatApp {
constructor() {
this.messages = [];
this.isTyping = false;
this.messageInput = document.getElementById('messageInput');
this.sendButton = document.getElementById('sendButton');
this.messagesContainer = document.getElementById('messages');
this.welcome = document.getElementById('welcome');
this.init();
}
init() {
this.messageInput.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
this.sendMessage();
}
});
this.sendButton.addEventListener('click', () => this.sendMessage());
this.messageInput.addEventListener('input', () => {
this.autoResize();
});
}
autoResize() {
this.messageInput.style.height = 'auto';
this.messageInput.style.height = Math.min(this.messageInput.scrollHeight, 120) + 'px';
}
async sendMessage() {
const text = this.messageInput.value.trim();
if (!text || this.isTyping) return;
this.hideWelcome();
this.addMessage(text, 'user');
this.messageInput.value = '';
this.autoResize();
await this.simulateTyping();
await this.getAIResponse(text);
}
hideWelcome() {
if (this.welcome) {
this.welcome.style.opacity = '0';
this.welcome.style.transform = 'translateY(-20px)';
setTimeout(() => this.welcome.remove(), 300);
this.welcome = null;
}
}
addMessage(text, sender) {
const messageDiv = document.createElement('div');
messageDiv.className = `flex ${sender === 'user' ? 'justify-end' : 'justify-start'} message-enter`;
const isUser = sender === 'user';
const bgClass = isUser ? 'gradient-bg text-white' : 'bg-white border border-gray-200';
const avatar = isUser ? '👤' : '🤖';
messageDiv.innerHTML = `
<div class="flex items-start space-x-3 max-w-3xl">
${!isUser ? `<div class="w-8 h-8 gradient-bg rounded-lg flex items-center justify-center flex-shrink-0 mt-1">
<span class="text-white text-sm">${avatar}</span>
</div>` : ''}
<div class="${bgClass} rounded-2xl px-4 py-3 shadow-sm hover:shadow-md transition-shadow duration-200">
<div class="text-sm ${isUser ? 'text-white' : 'text-gray-800'}">${this.formatMessage(text)}</div>
</div>
${isUser ? `<div class="w-8 h-8 bg-gray-300 rounded-lg flex items-center justify-center flex-shrink-0 mt-1">
<span class="text-gray-600 text-sm">${avatar}</span>
</div>` : ''}
</div>
`;
this.messagesContainer.appendChild(messageDiv);
this.scrollToBottom();
}
formatMessage(text) {
return text
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
.replace(/\*(.*?)\*/g, '<em>$1</em>')
.replace(/`(.*?)`/g, '<code class="bg-gray-100 px-1 rounded">$1</code>')
.replace(/\n/g, '<br>');
}
async simulateTyping() {
this.isTyping = true;
this.sendButton.disabled = true;
const typingDiv = document.createElement('div');
typingDiv.className = 'flex justify-start message-enter';
typingDiv.id = 'typing-indicator';
typingDiv.innerHTML = `
<div class="flex items-start space-x-3 max-w-3xl">
<div class="w-8 h-8 gradient-bg rounded-lg flex items-center justify-center flex-shrink-0 mt-1">
<span class="text-white text-sm">🤖</span>
</div>
<div class="bg-white border border-gray-200 rounded-2xl px-4 py-3 shadow-sm">
<div class="flex space-x-1">
<div class="w-2 h-2 bg-gray-400 rounded-full animate-bounce"></div>
<div class="w-2 h-2 bg-gray-400 rounded-full animate-bounce" style="animation-delay: 0.1s"></div>
<div class="w-2 h-2 bg-gray-400 rounded-full animate-bounce" style="animation-delay: 0.2s"></div>
</div>
</div>
</div>
`;
this.messagesContainer.appendChild(typingDiv);
this.scrollToBottom();
}
async getAIResponse(userMessage) {
// Symulacja streaming response
const responses = [
"Dziękuję za pytanie! To bardzo interesujący temat.",
"Rozumiem Twoje zapytanie. Pozwól, że wyjaśnię to krok po kroku.",
"To świetne pytanie! Oto co mogę Ci powiedzieć na ten temat.",
"Bardzo chętnie pomogę Ci z tym zagadnieniem.",
"Interesujące podejście do tego problemu. Oto moja odpowiedź:"
];
const baseResponse = responses[Math.floor(Math.random() * responses.length)];
const fullResponse = `${baseResponse}\n\nW kontekście Twojego pytania "${userMessage}", mogę powiedzieć, że jest to złożone zagadnienie wymagające przemyślanej analizy. Każdy aspekt ma swoje znaczenie i warto rozważyć różne perspektywy.\n\n**Kluczowe punkty:**\n- Analiza kontekstu\n- Rozważenie alternatyw\n- Praktyczne zastosowanie\n\nCzy chciałbyś, żebym rozwinął któryś z tych aspektów?`;
// Usuń wskaźnik pisania
const typingIndicator = document.getElementById('typing-indicator');
if (typingIndicator) {
typingIndicator.remove();
}
// Dodaj pustą wiadomość do streamingu
const messageDiv = document.createElement('div');
messageDiv.className = 'flex justify-start message-enter';
messageDiv.innerHTML = `
<div class="flex items-start space-x-3 max-w-3xl">
<div class="w-8 h-8 gradient-bg rounded-lg flex items-center justify-center flex-shrink-0 mt-1">
<span class="text-white text-sm">🤖</span>
</div>
<div class="bg-white border border-gray-200 rounded-2xl px-4 py-3 shadow-sm hover:shadow-md transition-shadow duration-200">
<div class="text-sm text-gray-800" id="streaming-text"></div>
</div>
</div>
`;
this.messagesContainer.appendChild(messageDiv);
// Streaming effect
const streamingElement = document.getElementById('streaming-text');
let currentText = '';
for (let i = 0; i < fullResponse.length; i++) {
currentText += fullResponse[i];
streamingElement.innerHTML = this.formatMessage(currentText) + '<span class="animate-pulse">|</span>';
this.scrollToBottom();
await new Promise(resolve => setTimeout(resolve, 20));
}
// Usuń kursor
streamingElement.innerHTML = this.formatMessage(fullResponse);
this.isTyping = false;
this.sendButton.disabled = false;
this.messageInput.focus();
}
scrollToBottom() {
setTimeout(() => {
window.scrollTo({
top: document.body.scrollHeight,
behavior: 'smooth'
});
}, 100);
}
}
// Initialize app
document.addEventListener('DOMContentLoaded', () => {
new ChatApp();
});
// Add some interactive effects
document.addEventListener('mousemove', (e) => {
const cursor = document.querySelector('.cursor-glow');
if (!cursor) {
const glowDiv = document.createElement('div');
glowDiv.className = 'cursor-glow fixed pointer-events-none w-4 h-4 rounded-full bg-gradient-to-r from-claude-blue to-claude-purple opacity-20 blur-sm transition-all duration-300 z-50';
document.body.appendChild(glowDiv);
}
const glow = document.querySelector('.cursor-glow');
glow.style.left = e.clientX - 8 + 'px';
glow.style.top = e.clientY - 8 + 'px';
});