| <!DOCTYPE html>
|
| <html lang="en">
|
| <head>
|
| <meta charset="UTF-8">
|
| <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| <title>AI Mission Assistant </title>
|
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
| <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
|
|
| <style>
|
|
|
| :root {
|
| --primary: #a855f7;
|
| --secondary: #6366f1;
|
|
|
| --glass-bg: rgba(15, 23, 42, 0.6);
|
| --glass-border: rgba(255, 255, 255, 0.1);
|
| --text-main: #ffffff;
|
| --text-muted: #cbd5e1;
|
| --user-msg-bg: linear-gradient(135deg, #a855f7, #7c3aed);
|
| --bot-msg-bg: rgba(0, 0, 0, 0.4);
|
| }
|
|
|
| * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }
|
|
|
| body {
|
| background-color: #02040a;
|
| color: var(--text-main);
|
| height: 100vh;
|
| display: flex;
|
| flex-direction: column;
|
|
|
|
|
| background: url('/static/chatbot_bg.png') no-repeat center center fixed;
|
| background-size: cover;
|
| overflow: hidden;
|
| position: relative;
|
| }
|
|
|
|
|
| body::before {
|
| content: '';
|
| position: absolute;
|
| top: 0; left: 0; width: 100%; height: 100%;
|
| background: rgba(0, 0, 0, 0.5);
|
| z-index: -1;
|
| pointer-events: none;
|
| }
|
|
|
|
|
| .navbar {
|
| display: flex;
|
| justify-content: space-between;
|
| align-items: center;
|
| padding: 1.2rem 3rem;
|
| background: rgba(2, 4, 10, 0.85);
|
| backdrop-filter: blur(10px);
|
| border-bottom: 1px solid var(--glass-border);
|
| z-index: 10;
|
| }
|
| .logo { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.5px; display: flex; align-items: center; gap: 10px;}
|
| .logo i { color: var(--primary); }
|
| .nav-links a { text-decoration: none; color: var(--text-muted); font-size: 0.9rem; transition: 0.3s; margin-left: 20px;}
|
| .nav-links a:hover { color: white; text-shadow: 0 0 10px white; }
|
|
|
|
|
| .chat-container {
|
| flex: 1;
|
| display: flex;
|
| justify-content: center;
|
| align-items: center;
|
| padding: 2rem;
|
| position: relative;
|
| }
|
|
|
| .chat-interface {
|
| width: 100%;
|
| max-width: 800px;
|
| height: 85vh;
|
| background: var(--glass-bg);
|
| border: 1px solid var(--glass-border);
|
| border-radius: 24px;
|
| backdrop-filter: blur(10px);
|
| box-shadow: 0 20px 50px rgba(0,0,0,0.5);
|
| display: flex;
|
| flex-direction: column;
|
| overflow: hidden;
|
| }
|
|
|
|
|
| .chat-header {
|
| padding: 1.5rem;
|
| border-bottom: 1px solid var(--glass-border);
|
| display: flex;
|
| align-items: center;
|
| gap: 15px;
|
| background: rgba(255,255,255,0.05);
|
| }
|
|
|
|
|
| .ai-avatar {
|
| width: 55px; height: 55px;
|
| border-radius: 50%;
|
| overflow: hidden;
|
| border: 2px solid var(--primary);
|
| box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
|
| background: #000;
|
| }
|
|
|
| .ai-avatar img {
|
| width: 100%; height: 100%; object-fit: cover;
|
| }
|
|
|
| .header-info h2 { font-size: 1.1rem; font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
|
| .header-info p { font-size: 0.8rem; color: #4ade80; display: flex; align-items: center; gap: 5px; }
|
| .dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; animation: pulse 2s infinite; }
|
|
|
|
|
| .chat-box {
|
| flex: 1;
|
| overflow-y: auto;
|
| padding: 2rem;
|
| display: flex;
|
| flex-direction: column;
|
| gap: 1.5rem;
|
| scroll-behavior: smooth;
|
| }
|
|
|
| .chat-box::-webkit-scrollbar { width: 6px; }
|
| .chat-box::-webkit-scrollbar-track { background: transparent; }
|
| .chat-box::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
|
|
|
|
|
| .message {
|
| max-width: 80%;
|
| padding: 1rem 1.5rem;
|
| border-radius: 18px;
|
| font-size: 0.95rem;
|
| line-height: 1.5;
|
| position: relative;
|
| animation: fadeIn 0.3s ease;
|
| backdrop-filter: blur(5px);
|
| }
|
|
|
| .bot-message {
|
| align-self: flex-start;
|
| background: var(--bot-msg-bg);
|
| border: 1px solid var(--glass-border);
|
| border-top-left-radius: 4px;
|
| color: #e2e8f0;
|
| }
|
|
|
| .user-message {
|
| align-self: flex-end;
|
| background: var(--user-msg-bg);
|
| border-top-right-radius: 4px;
|
| color: white;
|
| box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
|
| }
|
|
|
|
|
| .typing-indicator {
|
| display: none;
|
| align-self: flex-start;
|
| background: var(--bot-msg-bg);
|
| padding: 0.8rem 1.2rem;
|
| border-radius: 18px;
|
| border-top-left-radius: 4px;
|
| border: 1px solid var(--glass-border);
|
| gap: 5px;
|
| }
|
| .typing-dot {
|
| width: 6px; height: 6px; background: #94a3b8; border-radius: 50%;
|
| animation: bounce 1.4s infinite ease-in-out both;
|
| }
|
| .typing-dot:nth-child(1) { animation-delay: -0.32s; }
|
| .typing-dot:nth-child(2) { animation-delay: -0.16s; }
|
|
|
|
|
| .chat-input-area {
|
| padding: 1.5rem;
|
| background: rgba(0,0,0,0.3);
|
| border-top: 1px solid var(--glass-border);
|
| display: flex;
|
| gap: 15px;
|
| }
|
|
|
| #user-input {
|
| flex: 1;
|
| background: rgba(255,255,255,0.1);
|
| border: 1px solid var(--glass-border);
|
| padding: 1rem 1.5rem;
|
| border-radius: 50px;
|
| color: white;
|
| font-size: 1rem;
|
| outline: none;
|
| transition: 0.3s;
|
| }
|
| #user-input::placeholder { color: rgba(255,255,255,0.5); }
|
| #user-input:focus {
|
| border-color: var(--primary);
|
| background: rgba(255,255,255,0.15);
|
| }
|
|
|
| .send-btn {
|
| background: var(--primary);
|
| border: none;
|
| width: 50px; height: 50px;
|
| border-radius: 50%;
|
| color: white;
|
| font-size: 1.2rem;
|
| cursor: pointer;
|
| transition: 0.3s;
|
| display: flex; align-items: center; justify-content: center;
|
| }
|
| .send-btn:hover { transform: scale(1.1); box-shadow: 0 0 15px var(--primary); }
|
|
|
|
|
| @keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
|
| @keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }
|
| @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
|
|
|
|
|
| @media (max-width: 768px) {
|
| .navbar { padding: 1rem; }
|
| .chat-container { padding: 1rem; }
|
| .chat-interface { height: 80vh; }
|
| }
|
| </style>
|
| </head>
|
| <body>
|
|
|
| <nav class="navbar">
|
| <div class="logo"><i class="fa-solid fa-earth-americas"></i> SAR-Project</div>
|
| <div class="nav-links">
|
| <a href="/">Home</a>
|
| <a href="/greenery">Greenery</a>
|
| </div>
|
| </nav>
|
|
|
| <div class="chat-container">
|
| <div class="chat-interface">
|
|
|
| <div class="chat-header">
|
| <div class="ai-avatar">
|
| <img src="/static/chatbot_bg.png" alt="AI Robot">
|
| </div>
|
| <div class="header-info">
|
| <h2>Mission Control AI</h2>
|
| <p><span class="dot"></span> Online & Ready</p>
|
| </div>
|
| </div>
|
|
|
| <div class="chat-box" id="chat-box">
|
| <div class="message bot-message">
|
| <strong>System:</strong> Greetings, Commander. I am ready to analyze SAR data or answer mission queries. How can I assist?
|
| </div>
|
|
|
| <div class="typing-indicator" id="typing-indicator">
|
| <div class="typing-dot"></div>
|
| <div class="typing-dot"></div>
|
| <div class="typing-dot"></div>
|
| </div>
|
| </div>
|
|
|
| <div class="chat-input-area">
|
| <input type="text" id="user-input" placeholder="Type your command here..." autocomplete="off">
|
| <button class="send-btn" onclick="sendMessage()"><i class="fa-solid fa-paper-plane"></i></button>
|
| </div>
|
|
|
| </div>
|
| </div>
|
|
|
| <script>
|
| const chatBox = document.getElementById("chat-box");
|
| const userInput = document.getElementById("user-input");
|
| const typingIndicator = document.getElementById("typing-indicator");
|
|
|
|
|
| userInput.addEventListener("keypress", function(event) {
|
| if (event.key === "Enter") {
|
| sendMessage();
|
| }
|
| });
|
|
|
| function showTyping() {
|
| typingIndicator.style.display = "flex";
|
| chatBox.scrollTop = chatBox.scrollHeight;
|
| }
|
|
|
| function hideTyping() {
|
| typingIndicator.style.display = "none";
|
| }
|
|
|
| function sendMessage() {
|
| const userMessage = userInput.value.trim();
|
| if (userMessage === "") return;
|
|
|
| const userMsgDiv = document.createElement('div');
|
| userMsgDiv.className = 'message user-message';
|
| userMsgDiv.innerHTML = `<strong>You:</strong> ${userMessage}`;
|
| chatBox.insertBefore(userMsgDiv, typingIndicator);
|
|
|
| userInput.value = "";
|
| chatBox.scrollTop = chatBox.scrollHeight;
|
|
|
| showTyping();
|
|
|
| fetch("/chatbot/ask", {
|
| method: "POST",
|
| headers: { "Content-Type": "application/json" },
|
| body: JSON.stringify({ question: userMessage })
|
| })
|
| .then(response => response.json())
|
| .then(data => {
|
| hideTyping();
|
|
|
| const botMsgDiv = document.createElement('div');
|
| botMsgDiv.className = 'message bot-message';
|
| botMsgDiv.innerHTML = `<strong>AI:</strong> ${data.response}`;
|
| chatBox.insertBefore(botMsgDiv, typingIndicator);
|
|
|
| chatBox.scrollTop = chatBox.scrollHeight;
|
| })
|
| .catch(error => {
|
| hideTyping();
|
| const errorDiv = document.createElement('div');
|
| errorDiv.className = 'message bot-message';
|
| errorDiv.innerHTML = `<strong>System:</strong> Connection error. Please retry.`;
|
| chatBox.insertBefore(errorDiv, typingIndicator);
|
| });
|
| }
|
| </script>
|
| </body>
|
| </html> |