senangwebs-chatbot
Version:
Lightweight JavaScript library with OpenRouter API integration for AI-powered conversations.
318 lines (272 loc) • 5.76 kB
CSS
/* SenangWebs Chatbot Styles */
[data-swc] {
font-family: inherit;
max-width: 100%;
margin: 0 auto;
overflow: hidden;
}
.swc-chat-display {
height: 300px;
overflow-y: auto;
padding: 6px 16px;
background-color: #f9f9f9;
scroll-behavior: smooth;
position: relative;
}
.swc-chat-display.swc-modern {
display: flex;
flex-direction: column;
}
.swc-message {
margin: 4px 0;
padding: 8px 12px;
border-radius: 12px;
max-width: 80%;
animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.swc-classic .swc-message {
border-radius: 0;
max-width: 100%;
background-color: transparent;
padding: 4px 0;
}
.swc-bot-message {
align-self: flex-start;
background-color: #e0e0e0;
}
.swc-bot-message::before {
content: var(--swc-bot-name);
font-weight: bold;
display: block;
margin-bottom: 4px;
}
.swc-user-message {
align-self: flex-end;
background-color: var(--swc-theme-color, #007bff);
color: white;
}
.swc-classic .swc-user-message {
background-color: transparent;
color: inherit;
}
.swc-classic .swc-user-message::before {
content: "You: ";
font-weight: bold;
color: var(--swc-theme-color, #007bff);
}
.swc-input-container {
display: flex;
background-color: #fff;
}
.swc-user-input {
flex-grow: 1;
padding: 8px 16px;
border: none;
}
.swc-user-input:focus {
outline: none;
}
.swc-user-input:disabled {
background-color: #f0f0f0;
cursor: not-allowed;
}
.swc-send-button {
padding: 6px 16px;
background-color: var(--swc-theme-color, #007bff);
color: white;
border: none;
cursor: pointer;
}
.swc-send-button:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
.swc-options-container {
padding: 8px 12px;
background-color: rgba(0, 0, 0, 0.05);
display: none;
flex-wrap: wrap;
gap: 8px;
}
.swc-options-container button {
padding: 6px 16px;
background-color: #fff;
border: 2px solid var(--swc-theme-color, #007bff);
color: var(--swc-theme-color, #007bff);
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
.swc-options-container button:hover {
background-color: var(--swc-theme-color, #007bff);
color: #fff;
}
.swc-typing-indicator {
display: flex;
align-items: center;
column-gap: 6px;
padding: 8px 12px;
background-color: #e0e0e0;
border-radius: 12px;
width: fit-content;
margin: 8px 0;
align-self: flex-start;
}
.swc-typing-indicator span {
width: 8px;
height: 8px;
background-color: #666;
border-radius: 50%;
display: inline-block;
animation: pulse 1s infinite;
}
.swc-typing-indicator span:nth-child(2) {
animation-delay: 0.2s;
}
.swc-typing-indicator span:nth-child(3) {
animation-delay: 0.4s;
}
@keyframes pulse {
0%,
100% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.2);
opacity: 0.5;
}
}
/* AI-Powered Features */
/* AI message styling */
.swc-ai-message {
/* background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
position: relative; */
}
.swc-ai-message::before {
content: " " var(--swc-bot-name);
}
/* Streaming animation */
.swc-streaming {
position: relative;
}
.swc-streaming::after {
content: "";
animation: blink 0.7s infinite;
margin-left: 2px;
}
@keyframes blink {
0%,
49% {
opacity: 1;
}
50%,
100% {
opacity: 0;
}
}
/* Stop button */
.swc-stop-button {
padding: 6px 12px;
background-color: #ff4444;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
font-weight: 600;
margin-right: 8px;
transition: background-color 0.2s;
display: inline-flex;
align-items: center;
gap: 4px;
}
.swc-stop-button:hover {
background-color: #cc0000;
}
.swc-stop-button:active {
transform: scale(0.95);
}
/* Error message styling */
.swc-error-message {
background-color: #fff3cd;
color: #856404;
border-left: 4px solid #ffc107;
}
.swc-error-message::before {
content: " Error";
font-weight: bold;
}
/* API indicator badge (optional) */
.swc-model-badge {
display: inline-block;
font-size: 10px;
padding: 2px 6px;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 10px;
margin-left: 6px;
opacity: 0.7;
}
/* Loading state for AI */
.swc-ai-loading {
display: flex;
align-items: center;
gap: 8px;
padding: 12px;
background-color: rgba(102, 126, 234, 0.1);
border-radius: 12px;
margin: 8px 0;
}
.swc-ai-loading::before {
content: "";
font-size: 20px;
}
.swc-ai-loading-text {
color: #667eea;
font-style: italic;
}
/* Classic mode adjustments for AI */
.swc-classic .swc-ai-message {
background: transparent;
color: inherit;
border-left: 3px solid #667eea;
padding-left: 12px;
}
.swc-classic .swc-ai-message::before {
content: " " var(--swc-bot-name) ": ";
color: #667eea;
}
.swc-classic .swc-error-message {
background: transparent;
border-left: 3px solid #ffc107;
}
/* Responsive adjustments */
@media (max-width: 768px) {
.swc-stop-button {
font-size: 11px;
padding: 5px 10px;
}
.swc-ai-message,
.swc-bot-message,
.swc-user-message {
max-width: 90%;
}
}
/* Accessibility improvements */
.swc-stop-button:focus,
.swc-send-button:focus,
.swc-user-input:focus {
/* outline: 2px solid var(--swc-theme-color, #007bff); */
outline-offset: 2px;
}