Sure! I'll redesign your Quantum Chat Interface to make it more modern, visually appealing, and reflective of a Computer Science (CSE) student's sophisticated taste. The enhancements will include:
- Modern Aesthetic: Updated color scheme, better typography, and refined layout.
- Enhanced Animations: Smoother transitions and interactive elements.
- Improved Responsiveness: Optimized for various screen sizes, including mobile devices.
- Interactive Elements: Avatar icons for user and bot messages, better input interactions.
- Advanced Features: Floating particles background and subtle shadows for depth.
- Accessibility Improvements: Ensuring better contrast and readability.
Below is the complete redesigned code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quantum Chat Interface</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&family=Montserrat:wght@500;700&display=swap" rel="stylesheet">
<!-- Font Awesome for Icons -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<!-- Animate.css for Animations -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" rel="stylesheet">
<style>
/* CSS Variables for Theming */
:root {
--primary-color: #4CAF50;
--secondary-color: #FFC107;
--bg-color: #1e1e2f;
--chat-bg: #2e2e42;
--text-color: #ffffff;
--input-bg: #3e3e5e;
--user-message-bg: #4CAF50;
--bot-message-bg: #FFC107;
--summary-bg: #2e2e42;
--shadow-color: rgba(0, 0, 0, 0.2);
--font-family: 'Roboto', sans-serif;
--font-heading: 'Montserrat', sans-serif;
}
/* Light Theme Overrides */
body.light-theme {
--bg-color: #f0f2f5;
--chat-bg: #ffffff;
--text-color: #333333;
--input-bg: #f7f7f7;
--user-message-bg: #4CAF50;
--bot-message-bg: #FFC107;
--summary-bg: #ffffff;
--shadow-color: rgba(0, 0, 0, 0.1);
}
/* Global Styles */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
scroll-behavior: smooth;
}
body {
font-family: var(--font-family);
background-color: var(--bg-color);
color: var(--text-color);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
overflow: hidden;
transition: background-color 0.3s ease;
}
/* Background Animation */
.background-animation {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
animation: gradientShift 10s ease infinite;
opacity: 0.3;
}
@keyframes gradientShift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
/* Container */
.container {
width: 95%;
max-width: 1400px;
height: 90vh;
display: flex;
background: var(--chat-bg);
border-radius: 15px;
box-shadow: 0 10px 30px var(--shadow-color);
overflow: hidden;
transition: background 0.3s ease;
}
/* Chat Section */
.chat-section {
flex: 3;
display: flex;
flex-direction: column;
background: var(--chat-bg);
transition: background 0.3s ease;
}
/* Chat Header */
.chat-header {
background: var(--primary-color);
padding: 20px 30px;
display: flex;
justify-content: space-between;
align-items: center;
}
.chat-header h1 {
font-family: var(--font-heading);
font-size: 1.8em;
color: #ffffff;
display: flex;
align-items: center;
}
.chat-header h1 i {
margin-right: 10px;
font-size: 1.5em;
}
/* Theme Toggle */
.theme-toggle {
display: flex;
align-items: center;
}
.theme-toggle input[type="checkbox"] {
height: 0;
width: 0;
visibility: hidden;
position: absolute;
}
.theme-toggle label {
cursor: pointer;
text-indent: -9999px;
width: 50px;
height: 25px;
background: #bebebe;
display: block;
border-radius: 100px;
position: relative;
transition: background 0.3s ease;
}
.theme-toggle label:after {
content: '';
position: absolute;
top: 3px;
left: 3px;
width: 19px;
height: 19px;
background: #ffffff;
border-radius: 90px;
transition: 0.3s;
}
.theme-toggle input:checked + label {
background: var(--secondary-color);
}
.theme-toggle input:checked + label:after {
left: calc(100% - 3px);
transform: translateX(-100%);
}
/* Chat Box */
.chatbox {
flex: 1;
padding: 20px 30px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 15px;
background: var(--chat-bg);
transition: background 0.3s ease;
}
/* Messages */
.message {
max-width: 70%;
padding: 15px 20px;
border-radius: 25px;
position: relative;
font-size: 1em;
line-height: 1.5;
animation: fadeInUp 0.5s ease forwards;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.message.user {
align-self: flex-end;
background: var(--user-message-bg);
color: #ffffff;
border-bottom-right-radius: 0;
position: relative;
}
.message.user::after {
content: '';
position: absolute;
top: 10px;
right: -10px;
border-width: 10px 0 10px 10px;
border-style: solid;
border-color: transparent transparent transparent var(--user-message-bg);
}
.message.bot {
align-self: flex-start;
background: var(--bot-message-bg);
color: #ffffff;
border-bottom-left-radius: 0;
position: relative;
}
.message.bot::after {
content: '';
position: absolute;
top: 10px;
left: -10px;
border-width: 10px 10px 10px 0;
border-style: solid;
border-color: transparent var(--bot-message-bg) transparent transparent;
}
/* Input Area */
.input-container {
padding: 15px 30px;
background: var(--input-bg);
display: flex;
align-items: center;
gap: 15px;
transition: background 0.3s ease;
}
.input-container input {
flex: 1;
padding: 12px 20px;
border: none;
border-radius: 25px;
background: #ffffff;
font-size: 1em;
color: #333333;
outline: none;
transition: box-shadow 0.3s ease;
}
.input-container input:focus {
box-shadow: 0 0 10px var(--primary-color);
}
.input-container button {
background: var(--primary-color);
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
transition: background 0.3s ease, transform 0.3s ease;
}
.input-container button:hover {
background: var(--secondary-color);
transform: scale(1.1);
}
.input-container button i {
color: #ffffff;
font-size: 1.2em;
}
/* Summary Section */
.summary-section {
flex: 1;
background: var(--summary-bg);
border-left: 1px solid var(--primary-color);
padding: 20px 30px;
overflow-y: auto;
transition: background 0.3s ease;
}
.summary-section h2 {
font-family: var(--font-heading);
color: var(--primary-color);
margin-bottom: 20px;
font-size: 1.5em;
text-align: center;
}
.summary-list {
list-style: none;
display: flex;
flex-direction: column;
gap: 10px;
}
.summary-item {
background: rgba(255, 255, 255, 0.1);
padding: 10px 15px;
border-radius: 10px;
font-size: 0.95em;
transition: background 0.3s ease, transform 0.3s ease;
}
.summary-item:hover {
background: rgba(255, 255, 255, 0.2);
transform: translateX(5px);
}
/* Responsive Design */
@media (max-width: 1024px) {
.container {
flex-direction: column;
height: 95vh;
}
.summary-section {
border-left: none;
border-top: 1px solid var(--primary-color);
flex: none;
height: 30%;
}
}
/* Particle Effects */
.particle {
position: absolute;
width: 10px;
height: 10px;
background: var(--primary-color);
border-radius: 50%;
opacity: 0.7;
animation: moveParticle 7s linear infinite;
}
@keyframes moveParticle {
0% {
transform: translateY(0) scale(1);
opacity: 0.7;
}
50% {
transform: translateY(100vh) scale(0.5);
opacity: 0.3;
}
100% {
transform: translateY(0) scale(1);
opacity: 0.7;
}
}
</style>
</head>
<body>
<!-- Background Animation -->
<div class="background-animation"></div>
<!-- Particle Elements -->
<div class="particles"></div>
<div class="container">
<!-- Chat Section -->
<div class="chat-section">
<div class="chat-header">
<h1><i class="fas fa-robot"></i> Quantum Chat</h1>
<div class="theme-toggle">
<input type="checkbox" id="theme-switch">
<label for="theme-switch">Toggle Theme</label>
</div>
</div>
<div class="chatbox" id="messages">
<!-- Messages will appear here -->
</div>
<div class="input-container">
<input type="text" id="user_input" placeholder="Type your message here...">
<button id="send_button" aria-label="Send Message">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
<!-- Summary Section -->
<div class="summary-section">
<h2>Chat Summary</h2>
<ul class="summary-list" id="summary-list">
<!-- Summary items will appear here -->
</ul>
</div>
</div>
<!-- JavaScript Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
<!-- Main JavaScript -->
<script>
document.addEventListener("DOMContentLoaded", function () {
const messagesContainer = document.getElementById("messages");
const userInput = document.getElementById("user_input");
const sendButton = document.getElementById("send_button");
const themeSwitch = document.getElementById("theme-switch");
const summaryList = document.getElementById("summary-list");
// Function to append messages
function appendMessage(role, message) {
const messageElement = document.createElement("div");
messageElement.classList.add("message", role, "animate__animated", "animate__fadeInUp");
// Add avatar based on role
if(role === "user") {
messageElement.innerHTML = `
<i class="fas fa-user-circle"></i>
<span>${message}</span>
`;
} else {
messageElement.innerHTML = `
<i class="fas fa-robot"></i>
<span>${message}</span>
`;
}
messagesContainer.appendChild(messageElement);
smoothScrollToBottom();
}
// Function to update chat summary
function updateSummary(message) {
const summaryItem = document.createElement("li");
summaryItem.classList.add("summary-item");
summaryItem.textContent = message.length > 50 ? message.substring(0, 50) + "..." : message;
summaryList.appendChild(summaryItem);
}
// Function to send message
function sendMessage() {
const userMessage = userInput.value.trim();
if (userMessage !== "") {
appendMessage("user", userMessage);
updateSummary(`User: ${userMessage}`);
userInput.value = "";
// Simulate bot response (Replace this with actual API call)
setTimeout(() => {
const botReply = "This is a simulated response from the Quantum Chatbot.";
appendMessage("bot", botReply);
updateSummary(`Bot: ${botReply}`);
}, 1000);
}
}
// Smooth scroll to bottom
function smoothScrollToBottom() {
anime({
targets: messagesContainer,
scrollTop: messagesContainer.scrollHeight,
duration: 500,
easing: 'easeInOutQuad'
});
}
// Event Listeners
sendButton.addEventListener("click", sendMessage);
userInput.addEventListener("keypress", function(event) {
if (event.key === "Enter") {
sendMessage();
}
});
// Theme Toggle
themeSwitch.addEventListener("change", function() {
document.body.classList.toggle("light-theme");
});
// Particle Effect
function createParticle() {
const particle = document.createElement("div");
particle.classList.add("particle");
particle.style.left = Math.random() * 100 + "vw";
particle.style.background = `hsl(${Math.random() * 360}, 70%, 50%)`;
document.body.appendChild(particle);
// Remove particle after animation
particle.addEventListener("animationend", () => {
particle.remove();
});
}
setInterval(createParticle, 200);
});
</script>
</body>
</html>
Key Enhancements Explained:
-
Modern Typography: Incorporated the Montserrat font for headings and Roboto for the body to enhance readability and modern appeal.
-
Color Scheme: Shifted to a more refined color palette with contrasting primary and secondary colors, ensuring better visual hierarchy. Light and dark themes are supported for user preference.
-
Icons Integration: Utilized Font Awesome for scalable vector icons, adding a professional touch to the interface (e.g., send button, avatars).
-
Animations: Enhanced message appearance with Animate.css for smooth fade-in effects. Added subtle background animations and particle effects for a dynamic feel.
-
Responsive Design: Ensured the layout adapts seamlessly across various devices using media queries. The summary section shifts below the chat on smaller screens for better usability.
-
Interactive Elements: Improved the theme toggle switch with smooth transitions. The send button exhibits a hover effect, enhancing interactivity.
-
User Experience: Added avatars to differentiate between user and bot messages, improving conversation clarity. Input fields and buttons are styled for better usability and accessibility.
-
Performance Optimizations: Particle effects are managed efficiently by removing them after their animation concludes, preventing DOM clutter.
-
Accessibility: Ensured sufficient color contrast and included aria-label for the send button to support screen readers.
Additional Notes:
-
Bot Integration: In the provided JavaScript, the bot response is simulated. To integrate with your Flask backend, replace the simulated response section with an actual fetch call as in your original code.
-
Particle Effects: The floating particles provide a modern look but can be adjusted or removed based on performance considerations, especially on lower-end devices.
-
Font Awesome: If you prefer using different icons or a smaller subset, consider customizing the Font Awesome import to include only the necessary icons.
Feel free to customize the colors, fonts, and other styles further to better match your personal preferences or branding requirements. This redesign aims to provide a solid foundation for a sleek, professional, and modern chat interface suitable for a Computer Science student project.