hutmind / FrontEnd /src /ChatBot.css
tanmaivan's picture
feat: implement dark mode, knowledge base & multi-lang UI refinements
44009db
:root {
/* Light Theme Variables */
--bg-primary: #ffffff;
--bg-secondary: #f9fafb;
--bg-message-user: #e31837;
--text-primary: #111827;
--text-secondary: #6b7280;
--text-on-red: #ffffff;
--border-color: #f3f4f6;
--border-input: #e5e7eb;
--shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
--hover-btn: #f3f4f6;
}
.chatbot-container.dark, body.dark {
/* Dark Theme Variables */
--bg-primary: #121212; /* Slightly deeper dark */
--bg-secondary: #1e1e1e;
--bg-message-user: #e31837;
--text-primary: #ffffff;
--text-secondary: #d4d4d4; /* Much brighter for readability */
--border-color: #2a2a2a;
--border-input: #3a3a3a;
--hover-btn: #2a2a2a;
}
/* Global Resets */
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
overflow-x: hidden;
width: 100%;
}
body {
background-color: var(--bg-primary);
color: var(--text-primary);
transition: background-color 0.3s ease;
min-height: 100vh;
}
/* Container */
.chatbot-container {
width: 100%;
max-width: 1000px;
height: 100vh;
margin: 0 auto;
display: flex;
flex-direction: column;
background-color: var(--bg-primary);
position: relative;
font-family: 'Inter', sans-serif;
color: var(--text-primary);
transition: background-color 0.3s ease, color 0.3s ease;
overflow-x: hidden;
}
/* Header */
.chat-header {
height: 70px;
padding: 0 24px;
background-color: var(--bg-primary);
border-bottom: 1px solid var(--border-color);
display: flex;
align-items: center;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 100;
}
.header-left {
display: flex;
align-items: center;
gap: 16px;
}
.header-right {
display: flex;
align-items: center;
gap: 12px;
}
.header-logo {
display: flex;
align-items: center;
gap: 12px;
cursor: pointer;
}
.header-logo img {
object-fit: contain;
}
.header-title h1 {
font-size: 18px;
font-weight: 700;
color: var(--text-primary);
letter-spacing: -0.02em;
margin: 0;
}
.lang-switcher, .theme-switcher {
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
background-color: transparent;
border: none;
color: var(--text-primary); /* Higher contrast */
padding: 8px;
border-radius: 50%; /* For circular hover */
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
height: 38px;
min-width: 38px;
}
.theme-switcher {
width: 38px;
padding: 0;
}
.lang-switcher:hover, .theme-switcher:hover {
background-color: var(--hover-btn);
color: var(--text-primary);
}
.new-chat-btn {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
background-color: var(--bg-primary);
border: 1px solid var(--border-input);
color: var(--text-primary);
font-size: 13px;
font-weight: 500;
padding: 0 20px;
height: 38px;
border-radius: 20px; /* Pill-shaped */
cursor: pointer;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: var(--shadow-sm);
min-width: 140px; /* Stabilize size */
}
.new-chat-btn:hover {
background-color: var(--bg-primary);
border-color: #9ca3af;
box-shadow: var(--shadow-md);
transform: translateY(-1px);
}
.new-chat-btn:active {
transform: translateY(0);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}
/* Chat Window */
.chat-window {
flex: 1;
overflow-y: auto;
padding: 0;
display: flex;
flex-direction: column;
scroll-behavior: smooth;
}
.chat-window::-webkit-scrollbar {
width: 6px;
}
.chat-window::-webkit-scrollbar-thumb {
background-color: var(--border-input);
border-radius: 10px;
}
/* Welcome Screen */
.welcome-container {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 40px 20px;
margin: auto; /* Vertically and horizontally centered */
width: 100%;
max-width: 800px;
min-height: min-content;
}
.welcome-logo {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20px;
max-height: 15vh; /* Reduced height as it's smaller now */
}
.welcome-logo img {
max-height: 100%;
width: auto;
height: auto;
max-width: 100px; /* Reduced to 1/2 size as requested */
object-fit: contain;
}
.welcome-container h2 {
font-size: 24px;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 12px;
}
.welcome-subtitle {
font-size: clamp(12px, 2vw, 14px);
color: var(--text-secondary);
margin-bottom: 32px;
line-height: 1.5;
white-space: nowrap;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
/* Knowledge Base Button */
.knowledge-base-btn {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
background-color: transparent;
border: 1px solid var(--border-input);
color: var(--text-primary); /* Ensure white in dark mode */
padding: 8px 16px;
border-radius: 20px;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
margin-bottom: 32px;
min-width: 160px; /* Stabilize size */
}
.knowledge-base-btn:hover {
background-color: var(--hover-btn);
color: var(--text-primary);
border-color: #9ca3af;
transform: translateY(-1px);
}
/* Suggestion Chips */
.suggestion-chips {
display: flex;
flex-wrap: nowrap; /* Single line as requested */
overflow-x: auto; /* Horizontal scroll if too long */
gap: 12px;
justify-content: center; /* Center if enough space */
width: 100%;
max-width: 800px; /* Wider to match input area visibility better */
padding: 4px 10px;
scrollbar-width: none; /* Hide scrollbar Firefox */
-ms-overflow-style: none; /* Hide scrollbar IE/Edge */
}
.suggestion-chips::-webkit-scrollbar {
display: none; /* Hide scrollbar Chrome/Safari */
}
.suggestion-chips button {
flex-shrink: 0; /* Don't squash buttons */
background-color: var(--bg-primary);
border: 1px solid var(--border-input);
color: var(--text-primary); /* Use primary text (white in dark mode) */
padding: 10px 18px;
border-radius: 12px;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: var(--shadow-sm);
height: 44px; /* Consistent height */
display: flex;
align-items: center;
justify-content: center;
white-space: nowrap;
}
.suggestion-chips button:hover {
background-color: var(--hover-btn);
border-color: #9ca3af;
color: var(--text-primary);
transform: translateY(-1px);
}
/* Messages */
.messages-list {
display: flex;
flex-direction: column;
padding: 20px 0;
gap: 16px;
}
.message-row {
display: flex;
padding: 8px 24px;
gap: 16px;
width: 100%;
}
.message-row.bot {
justify-content: flex-start;
background-color: transparent; /* No background for bot */
}
.message-row.user {
justify-content: flex-end; /* User on the right */
}
.message-content {
width: 100%;
max-width: 100%;
overflow-wrap: break-word;
font-size: 16px;
line-height: 1.6;
}
.message-row.user .message-content {
display: flex;
justify-content: flex-end;
max-width: 80%;
}
.user-text {
white-space: pre-wrap;
color: var(--text-on-red);
background-color: var(--bg-message-user); /* Pizza Hut Red Bubble */
padding: 12px 18px;
border-radius: 20px 20px 2px 20px;
box-shadow: 0 2px 8px rgba(227, 24, 55, 0.15);
}
/* Bot message wrapper for copy button positioning */
.bot-message-wrapper {
position: relative;
width: 100%;
}
.copy-btn {
background-color: transparent;
color: #9ca3af; /* Gray icon */
margin-top: 12px;
margin-left: -8px; /* Alignment with text */
border: none;
cursor: pointer;
padding: 8px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
border-radius: 50%; /* Circular */
opacity: 0; /* Hidden by default */
width: 36px;
height: 36px;
}
/* Always show icon for the latest response */
.bot-message-wrapper.latest .copy-btn {
opacity: 1;
}
/* Show icon on hover for all responses */
.bot-message-wrapper:hover .copy-btn {
opacity: 1;
}
.copy-btn:hover {
background-color: var(--hover-btn); /* Light circular hover */
color: var(--text-primary); /* Darker on hover */
}
/* React Markdown Styles */
.markdown-body {
color: var(--text-primary);
width: 100%;
}
.markdown-body p {
margin-bottom: 12px;
}
.markdown-body p:last-child {
margin-bottom: 0;
}
.markdown-body strong {
font-weight: 600;
color: var(--text-primary);
}
.markdown-body ul, .markdown-body ol {
margin-bottom: 12px;
padding-left: 24px;
}
.markdown-body li {
margin-bottom: 4px;
}
.markdown-body code {
background-color: var(--bg-secondary);
padding: 2px 6px;
border-radius: 4px;
font-size: 14px;
font-family: 'Consolas', monospace;
color: var(--text-primary);
}
/* Typing Indicator */
.typing-indicator {
display: flex;
align-items: center;
height: 24px;
gap: 4px;
}
.dot {
width: 6px;
height: 6px;
background-color: var(--text-secondary);
border-radius: 50%;
animation: bounce 1.4s infinite ease-in-out both;
}
.dot1 { animation-delay: -0.32s; }
.dot2 { animation-delay: -0.16s; }
@keyframes bounce {
0%, 80%, 100% { transform: scale(0); }
40% { transform: scale(1); }
}
/* Input Area */
.input-area {
padding: 16px 24px 24px 24px;
background-color: var(--bg-primary);
}
.input-container {
display: flex;
align-items: flex-end;
background-color: var(--bg-primary);
border: 1px solid var(--border-input);
border-radius: 16px;
padding: 4px;
transition: all 0.2s;
position: relative;
}
.input-container:focus-within {
border-color: #9ca3af;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.chat-input {
flex: 1;
border: none;
background: transparent;
padding: 12px 16px;
font-size: 16px;
color: var(--text-primary);
font-family: inherit;
resize: none;
max-height: 200px;
min-height: 48px;
line-height: 1.5;
}
.chat-input:focus {
outline: none;
}
.chat-input::placeholder {
color: #9ca3af;
}
.send-button {
background-color: transparent;
color: #e31837; /* Pizza Hut Red */
border: none;
width: 36px;
height: 48px; /* Match input height */
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
margin: 0 8px;
transition: all 0.2s ease;
flex-shrink: 0;
}
.send-button:not(.disabled):hover {
transform: scale(1.1);
color: #ff5e62;
}
.send-button.disabled {
background-color: transparent;
color: #e5e7eb;
cursor: not-allowed;
}
.footer-text {
text-align: center;
font-size: 12px;
color: var(--text-secondary);
margin-top: 12px;
}
/* Responsive */
@media (max-width: 768px) {
.chatbot-container {
width: 100%;
height: 100vh;
height: 100dvh;
margin: 0;
border-radius: 0;
max-width: 100%;
}
.chat-header {
padding: 0 16px;
}
.header-title h1 {
font-size: 14px;
}
.header-right {
gap: 8px; /* Tighter gap on mobile */
}
.lang-switcher span, .new-chat-btn span {
display: none; /* Hide text to save space */
}
.lang-switcher, .theme-switcher, .new-chat-btn {
padding: 8px;
width: 38px;
min-width: 38px;
border-radius: 50%; /* Icon only style */
}
.welcome-container {
padding-top: 40px;
}
.welcome-logo img {
max-width: 80px; /* Proportional reduction for mobile */
}
.welcome-container h2 {
font-size: 20px;
}
.message-row {
padding: 8px 16px;
gap: 12px;
}
.message-content {
max-width: 90%;
font-size: 15px;
}
.user-text {
padding: 10px 14px;
}
.input-area {
padding: 12px 16px 20px 16px;
}
.chat-input {
font-size: 16px; /* Prevents iOS zoom */
padding: 10px 12px;
}
}
@media (max-width: 480px) {
.header-title {
display: none; /* Only logo on very small screens if needed */
}
.welcome-logo img {
max-width: 70px; /* Even smaller for very small screens */
}
.suggestion-chips {
justify-content: flex-start; /* Ensure scrolling starts from left */
padding-left: 16px;
padding-right: 16px;
}
.welcome-subtitle {
font-size: 13px;
margin-bottom: 24px;
padding: 0 10px;
white-space: normal; /* Allow wrap on very small screens to avoid horizontal scroll of plain text */
text-overflow: clip;
overflow: visible;
}
.modal-content {
margin: 20px; /* Prevent touching edges on mobile */
max-height: 85vh;
}
}
/* Knowledge Base Button */
.knowledge-base-btn {
display: flex;
align-items: center;
gap: 8px;
background-color: transparent;
border: 1px solid #e5e7eb;
color: #6b7280;
padding: 8px 16px;
border-radius: 20px;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.2s ease;
margin-bottom: 32px;
}
.knowledge-base-btn:hover {
background-color: #f9fafb;
color: #374151;
border-color: #d1d5db;
transform: translateY(-1px);
}
/* Modal Styles */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.6); /* Darker for better contrast */
backdrop-filter: blur(8px); /* Stronger blur */
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
animation: fadeIn 0.2s ease-out;
}
.modal-content {
background-color: var(--bg-primary);
width: 90%;
max-width: 500px;
max-height: 90vh; /* Keep within viewport */
display: flex;
flex-direction: column;
border-radius: 20px;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
overflow: hidden;
animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
border: 1px solid var(--border-color);
color: var(--text-primary);
}
.modal-header {
padding: 20px 24px;
border-bottom: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: center;
background-color: var(--bg-primary);
flex-shrink: 0; /* Header stays at the top */
}
.modal-header h3 {
font-size: 18px;
font-weight: 600;
color: var(--text-primary);
margin: 0;
}
.close-modal {
background: transparent;
border: none;
color: #9ca3af;
cursor: pointer;
padding: 4px;
font-size: 18px;
display: flex;
transition: color 0.2s;
}
.close-modal:hover {
color: #374151;
}
.modal-body {
padding: 24px;
overflow-y: auto; /* Contents scrollable */
flex: 1;
}
.modal-description {
font-size: 14px;
color: var(--text-secondary);
margin-bottom: 20px;
line-height: 1.5;
}
.sources-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.source-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 16px;
background-color: var(--bg-secondary);
border-radius: 12px;
transition: background-color 0.2s;
border: 1px solid var(--border-color);
}
.source-item:hover {
background-color: var(--hover-btn);
}
.source-icon {
font-size: 16px;
flex-shrink: 0;
}
.source-icon.pdf { color: #ef4444; }
.source-icon.word { color: #3b82f6; }
.source-icon.db { color: #10b981; }
.source-name {
font-size: 14px;
color: var(--text-primary);
font-weight: 500;
line-height: 1.4;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}