Fix AI chatbot role mapping, add markdown formatting, update system prompts, and handle OpenRouter API errors
This commit is contained in:
@@ -0,0 +1,406 @@
|
||||
/* ============================================================
|
||||
chatbot.css — BookKeepPro Chatbot Widget
|
||||
Floating chat bubble + chat window
|
||||
============================================================ */
|
||||
|
||||
/* ── Chat Bubble (FAB) ──────────────────────────────────── */
|
||||
.chatbot-fab {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
right: 24px;
|
||||
width: 58px;
|
||||
height: 58px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, var(--blue) 0%, var(--accent) 100%);
|
||||
color: #fff;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 20px rgba(0, 119, 200, 0.35);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 28px;
|
||||
z-index: 9998;
|
||||
transition: transform 0.25s ease, box-shadow 0.25s ease;
|
||||
}
|
||||
.chatbot-fab:hover {
|
||||
transform: scale(1.08);
|
||||
box-shadow: 0 6px 28px rgba(0, 119, 200, 0.45);
|
||||
}
|
||||
.chatbot-fab:active {
|
||||
transform: scale(0.96);
|
||||
}
|
||||
.chatbot-fab .fab-icon { transition: transform 0.3s ease; }
|
||||
.chatbot-fab.open .fab-icon { transform: rotate(90deg); }
|
||||
|
||||
/* Pulse ring animation */
|
||||
.chatbot-fab::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -4px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid var(--blue);
|
||||
opacity: 0;
|
||||
animation: chatPulse 2.5s ease-out infinite;
|
||||
}
|
||||
.chatbot-fab.open::before { animation: none; opacity: 0; }
|
||||
|
||||
@keyframes chatPulse {
|
||||
0% { transform: scale(1); opacity: 0.5; }
|
||||
100% { transform: scale(1.4); opacity: 0; }
|
||||
}
|
||||
|
||||
/* Notification dot */
|
||||
.chatbot-fab .notif-dot {
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
right: 2px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 50%;
|
||||
background: var(--orange);
|
||||
border: 2px solid #fff;
|
||||
animation: dotBounce 1.5s ease infinite;
|
||||
}
|
||||
.chatbot-fab.open .notif-dot { display: none; }
|
||||
|
||||
@keyframes dotBounce {
|
||||
0%, 100% { transform: scale(1); }
|
||||
50% { transform: scale(1.2); }
|
||||
}
|
||||
|
||||
/* ── Chat Window ────────────────────────────────────────── */
|
||||
.chatbot-window {
|
||||
position: fixed;
|
||||
bottom: 96px;
|
||||
right: 24px;
|
||||
width: 380px;
|
||||
max-height: 520px;
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--card);
|
||||
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 9999;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
transform: translateY(20px) scale(0.95);
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
.chatbot-window.visible {
|
||||
opacity: 1;
|
||||
transform: translateY(0) scale(1);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* ── Header ─────────────────────────────────────────────── */
|
||||
.chatbot-header {
|
||||
background: linear-gradient(135deg, var(--blue) 0%, #005fa3 100%);
|
||||
color: #fff;
|
||||
padding: 16px 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.chatbot-header .bot-avatar {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.chatbot-header .bot-info h4 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
}
|
||||
.chatbot-header .bot-info span {
|
||||
font-size: 11px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
.chatbot-header .close-chat {
|
||||
margin-left: auto;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border: none;
|
||||
color: #fff;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.chatbot-header .close-chat:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
/* ── Messages Area ──────────────────────────────────────── */
|
||||
.chatbot-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
background: #f8fbfe;
|
||||
min-height: 200px;
|
||||
max-height: 340px;
|
||||
}
|
||||
.chatbot-messages::-webkit-scrollbar { width: 5px; }
|
||||
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
|
||||
.chatbot-messages::-webkit-scrollbar-thumb { background: #c5d9ee; border-radius: 10px; }
|
||||
|
||||
/* ── Message Bubbles ────────────────────────────────────── */
|
||||
.chat-msg {
|
||||
max-width: 85%;
|
||||
padding: 10px 14px;
|
||||
border-radius: 14px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
animation: msgSlideIn 0.3s ease;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
@keyframes msgSlideIn {
|
||||
from { opacity: 0; transform: translateY(8px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
.chat-msg.bot {
|
||||
background: #fff;
|
||||
color: #222;
|
||||
border: 1px solid var(--border);
|
||||
border-bottom-left-radius: 4px;
|
||||
align-self: flex-start;
|
||||
box-shadow: 0 1px 4px rgba(0,0,0,0.04);
|
||||
}
|
||||
.chat-msg.user {
|
||||
background: linear-gradient(135deg, var(--blue), var(--accent));
|
||||
color: #fff;
|
||||
border-bottom-right-radius: 4px;
|
||||
align-self: flex-end;
|
||||
}
|
||||
|
||||
/* ── Typing Indicator ───────────────────────────────────── */
|
||||
.typing-indicator {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding: 12px 16px;
|
||||
align-self: flex-start;
|
||||
}
|
||||
.typing-indicator span {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--blue);
|
||||
opacity: 0.4;
|
||||
animation: typingDot 1.2s ease-in-out infinite;
|
||||
}
|
||||
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
|
||||
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
|
||||
|
||||
@keyframes typingDot {
|
||||
0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
|
||||
30% { transform: translateY(-6px); opacity: 1; }
|
||||
}
|
||||
|
||||
/* ── Quick Reply Buttons ────────────────────────────────── */
|
||||
.quick-replies {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.quick-reply-btn {
|
||||
background: #fff;
|
||||
border: 1.5px solid var(--blue);
|
||||
color: var(--blue);
|
||||
padding: 9px 14px;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: all 0.2s ease;
|
||||
font-family: inherit;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.quick-reply-btn:hover {
|
||||
background: var(--blue);
|
||||
color: #fff;
|
||||
transform: translateX(4px);
|
||||
box-shadow: 0 2px 8px rgba(0, 119, 200, 0.2);
|
||||
}
|
||||
.quick-reply-btn .qr-icon {
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ── Doc Status Cards ───────────────────────────────────── */
|
||||
.doc-status-card {
|
||||
background: #fff;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-xs);
|
||||
padding: 10px 12px;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.doc-status-card .doc-name {
|
||||
font-weight: 600;
|
||||
color: var(--navy);
|
||||
margin-bottom: 4px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.doc-status-card .doc-year {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
.doc-status-card .doc-badge {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--radius-pill);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
.doc-badge.pending { background: var(--warn-bg); color: var(--warn); }
|
||||
.doc-badge.approved { background: var(--success-bg); color: var(--success); }
|
||||
.doc-badge.rejected { background: var(--error-bg); color: var(--error); }
|
||||
|
||||
.doc-status-card .doc-note {
|
||||
margin-top: 4px;
|
||||
color: var(--muted);
|
||||
font-style: italic;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* ── Summary Banner ─────────────────────────────────────── */
|
||||
.status-summary {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.summary-item {
|
||||
text-align: center;
|
||||
padding: 8px 4px;
|
||||
border-radius: var(--radius-xs);
|
||||
background: #f1f7fb;
|
||||
}
|
||||
.summary-item .count {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
display: block;
|
||||
}
|
||||
.summary-item .label {
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.summary-item.pending .count { color: var(--warn); }
|
||||
.summary-item.approved .count { color: var(--success); }
|
||||
.summary-item.rejected .count { color: var(--error); }
|
||||
|
||||
/* ── FAQ List ───────────────────────────────────────────── */
|
||||
.faq-question {
|
||||
background: #fff;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-xs);
|
||||
padding: 9px 12px;
|
||||
font-size: 12.5px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
text-align: left;
|
||||
color: var(--navy);
|
||||
width: 100%;
|
||||
font-family: inherit;
|
||||
display: block;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.faq-question:hover {
|
||||
border-color: var(--blue);
|
||||
color: var(--blue);
|
||||
background: var(--blue-light);
|
||||
}
|
||||
|
||||
/* ── Back Button ────────────────────────────────────────── */
|
||||
.back-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--blue);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
padding: 4px 0;
|
||||
font-family: inherit;
|
||||
font-weight: 500;
|
||||
margin-top: 6px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.back-btn:hover { text-decoration: underline; }
|
||||
|
||||
/* ── Mobile Responsive ──────────────────────────────────── */
|
||||
@media (max-width: 480px) {
|
||||
.chatbot-window {
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
max-height: 75vh;
|
||||
border-radius: var(--radius-md) var(--radius-md) 0 0;
|
||||
}
|
||||
.chatbot-fab {
|
||||
bottom: 16px;
|
||||
right: 16px;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Dark Mode Support ──────────────────────────────────── */
|
||||
[data-theme="dark"] .chatbot-window { background: #1a2332; }
|
||||
[data-theme="dark"] .chatbot-messages { background: #0f1923; }
|
||||
[data-theme="dark"] .chat-msg.bot {
|
||||
background: #1e2d3d;
|
||||
border-color: #2a3f54;
|
||||
color: #d4dde6;
|
||||
}
|
||||
[data-theme="dark"] .quick-reply-btn {
|
||||
background: #1e2d3d;
|
||||
border-color: var(--blue);
|
||||
color: var(--accent);
|
||||
}
|
||||
[data-theme="dark"] .quick-reply-btn:hover {
|
||||
background: var(--blue);
|
||||
color: #fff;
|
||||
}
|
||||
[data-theme="dark"] .doc-status-card {
|
||||
background: #1e2d3d;
|
||||
border-color: #2a3f54;
|
||||
}
|
||||
[data-theme="dark"] .doc-status-card .doc-name { color: #d4dde6; }
|
||||
[data-theme="dark"] .faq-question {
|
||||
background: #1e2d3d;
|
||||
border-color: #2a3f54;
|
||||
color: #d4dde6;
|
||||
}
|
||||
[data-theme="dark"] .faq-question:hover {
|
||||
background: #253648;
|
||||
border-color: var(--blue);
|
||||
}
|
||||
[data-theme="dark"] .summary-item { background: #1e2d3d; }
|
||||
Reference in New Issue
Block a user