neochat-widget
Version:
Universal JavaScript SDK and Widget for NeoChat AI Assistant
326 lines (311 loc) • 6.13 kB
CSS
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes bounceIn {
0% {
transform: scale(0.9);
opacity: 0;
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
opacity: 1;
}
}
.neochat-widget {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", sans-serif;
font-size: 14px;
line-height: 1.5;
color: #1f2937;
box-sizing: border-box;
}
.neochat-widget * {
box-sizing: border-box;
}
.neochat-widget-container {
position: fixed;
z-index: 9999;
width: 360px;
max-width: 100%;
height: 600px;
max-height: 80vh;
display: flex;
flex-direction: column;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
overflow: hidden;
animation: fadeIn 0.2s ease-out;
transform-origin: bottom right;
transition: transform 0.2s ease, opacity 0.2s ease;
opacity: 1;
}
.neochat-widget-container.bottom-right {
bottom: 24px;
right: 24px;
}
.neochat-widget-container.bottom-left {
bottom: 24px;
left: 24px;
}
.neochat-widget-container.top-right {
top: 24px;
right: 24px;
}
.neochat-widget-container.top-left {
top: 24px;
left: 24px;
}
.neochat-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 24px;
background: #4f46e5;
color: white;
font-weight: 600;
user-select: none;
}
.neochat-title {
font-size: 16px;
font-weight: 600;
}
.neochat-close {
background: none;
border: none;
color: white;
font-size: 24px;
cursor: pointer;
padding: 0 8px;
line-height: 1;
opacity: 0.8;
transition: opacity 0.2s;
}
.neochat-close:hover {
opacity: 1;
}
.neochat-messages {
flex: 1;
overflow-y: auto;
padding: 16px;
background: #f9fafb;
scroll-behavior: smooth;
}
.neochat-messages::-webkit-scrollbar {
width: 6px;
}
.neochat-messages::-webkit-scrollbar-track {
background: transparent;
}
.neochat-messages::-webkit-scrollbar-thumb {
background: #d1d5db;
border-radius: 3px;
}
.message {
margin-bottom: 16px;
max-width: 80%;
animation: fadeIn 0.2s ease-out;
}
.message.user {
margin-left: auto;
}
.message.user .message-content {
background: #4f46e5;
color: white;
border-top-right-radius: 4px;
}
.message.bot {
margin-right: auto;
}
.message.bot .message-content {
background: white;
border: 1px solid #e5e7eb;
border-top-left-radius: 4px;
}
.message.error .message-content {
background: #fee2e2;
color: #b91c1c;
border: 1px solid #fecaca;
}
.message-content {
padding: 16px;
border-radius: 8px;
line-height: 1.5;
word-wrap: break-word;
white-space: pre-wrap;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.message-timestamp {
font-size: 11px;
color: #6b7280;
margin-top: 4px;
text-align: right;
}
.typing-indicator {
display: flex;
align-items: center;
}
.typing-indicator span {
display: inline-block;
width: 6px;
height: 6px;
margin: 0 2px;
background-color: #9ca3af;
border-radius: 50%;
animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) {
animation-delay: -0.32s;
}
.typing-indicator span:nth-child(2) {
animation-delay: -0.16s;
}
@keyframes bounce {
0%, 80%, 100% {
transform: translateY(0);
opacity: 0.6;
}
40% {
transform: translateY(-6px);
opacity: 1;
}
}
.neochat-input-container {
display: flex;
padding: 16px;
border-top: 1px solid #e5e7eb;
background: white;
}
.neochat-input {
flex: 1;
min-height: 44px;
max-height: 120px;
padding: 8px 16px;
border: 1px solid #e5e7eb;
border-radius: 8px;
resize: none;
font-family: inherit;
font-size: 14px;
line-height: 1.5;
color: #1f2937;
background: #f9fafb;
transition: border-color 0.2s, box-shadow 0.2s;
}
.neochat-input:focus {
outline: none;
border-color: #4f46e5;
box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}
.neochat-input::placeholder {
color: #9ca3af;
}
.neochat-send-button {
margin-left: 8px;
padding: 0 16px;
background: #4f46e5;
color: white;
border: none;
border-radius: 8px;
font-weight: 500;
cursor: pointer;
transition: background-color 0.2s;
white-space: nowrap;
}
.neochat-send-button:hover {
background: #4338ca;
}
.neochat-send-button:disabled {
background: #d1d5db;
cursor: not-allowed;
}
.neochat-launch-button {
position: fixed;
width: 60px;
height: 60px;
border-radius: 50%;
background: #4f46e5;
color: white;
border: none;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: transform 0.2s, background-color 0.2s;
z-index: 9998;
animation: bounceIn 0.3s ease-out;
}
.neochat-launch-button:hover {
transform: scale(1.05);
background: #4338ca;
}
.neochat-launch-button.bottom-right {
bottom: 24px;
right: 24px;
}
.neochat-launch-button.bottom-left {
bottom: 24px;
left: 24px;
}
.neochat-launch-button.top-right {
top: 24px;
right: 24px;
}
.neochat-launch-button.top-left {
top: 24px;
left: 24px;
}
.neochat-icon {
font-size: 24px;
line-height: 1;
}
@media (max-width: 480px) {
.neochat-widget-container {
width: 100%;
height: 100%;
max-height: none;
border-radius: 0;
top: 0 ;
left: 0 ;
right: 0 ;
bottom: 0 ;
}
.neochat-launch-button {
width: 56px;
height: 56px;
bottom: 16px ;
right: 16px ;
}
}
[dir=rtl] .message.user {
margin-left: 0;
margin-right: auto;
}
[dir=rtl] .message.user .message-content {
border-top-right-radius: 0;
border-top-left-radius: 4px;
}
[dir=rtl] .message.bot {
margin-right: 0;
margin-left: auto;
}
[dir=rtl] .message.bot .message-content {
border-top-left-radius: 0;
border-top-right-radius: 4px;
}
[dir=rtl] .message-timestamp {
text-align: left;
}
[dir=rtl] .neochat-send-button {
margin-left: 0;
margin-right: 8px;
}