:root {
--chat-primary: #4f46e5;
--chat-primary-light: #6366f1;
--chat-bg: #ffffff;
--chat-border: #e5e7eb;
--chat-text: #1f2937;
--chat-text-light: #6b7280;
--chat-msg-self: #4f46e5;
--chat-msg-other: #f3f4f6;
}
.knn-chat {
position: fixed;
bottom: 24px;
z-index: 99999;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
.knn-chat.pos-right { right: 24px; }
.knn-chat.pos-left { left: 24px; } .chat-btn {
width: 56px;
height: 56px;
background: var(--chat-primary);
border-radius: 28px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
transition: all 0.3s ease;
position: relative;
}
.chat-btn:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}
.chat-btn i {
color: #fff;
font-size: 24px;
}
.chat-btn .badge {
position: absolute;
top: -4px;
right: -4px;
background: #ef4444;
color: #fff;
font-size: 11px;
font-weight: 600;
min-width: 20px;
height: 20px;
border-radius: 10px;
display: none;
align-items: center;
justify-content: center;
border: 2px solid #fff;
} .chat-box {
display: none;
position: absolute;
bottom: 70px;
width: 380px;
height: 520px;
background: var(--chat-bg);
border-radius: 16px;
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
flex-direction: column;
overflow: hidden;
border: 1px solid var(--chat-border);
}
.pos-right .chat-box { right: 0; }
.pos-left .chat-box { left: 0; }
.chat-box.open { display: flex; } .chat-head {
padding: 16px 20px;
background: var(--chat-bg);
border-bottom: 1px solid var(--chat-border);
display: flex;
justify-content: space-between;
align-items: center;
}
.chat-head span {
font-size: 16px;
font-weight: 600;
color: var(--chat-text);
display: flex;
align-items: center;
gap: 8px;
}
.chat-head span i {
color: var(--chat-primary);
font-size: 20px;
}
.chat-close {
width: 32px;
height: 32px;
background: #f3f4f6;
border: none;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.chat-close:hover {
background: #e5e7eb;
}
.chat-close i {
color: var(--chat-text-light);
font-size: 14px;
} .chat-body {
flex: 1;
overflow-y: auto;
padding: 16px;
background: #fafafa;
}
.chat-body::-webkit-scrollbar {
width: 4px;
}
.chat-body::-webkit-scrollbar-thumb {
background: #d1d5db;
border-radius: 2px;
}
.chat-body::-webkit-scrollbar-track {
background: transparent;
} .chat-msg {
display: flex;
margin-bottom: 16px;
align-items: flex-end;
animation: msgIn 0.3s ease;
}
@keyframes msgIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.chat-msg .avatar {
width: 36px;
height: 36px;
border-radius: 50%;
flex-shrink: 0;
object-fit: cover;
background: #e5e7eb;
}
.chat-msg .content {
max-width: 65%;
display: flex;
flex-direction: column;
}
.chat-msg .head {
display: flex;
align-items: center;
margin-bottom: 4px;
gap: 8px;
}
.chat-msg .name {
font-size: 12px;
font-weight: 500;
color: var(--chat-text-light);
}
.chat-msg .time {
font-size: 11px;
color: #9ca3af;
}
.chat-msg .text {
padding: 12px 16px;
font-size: 14px;
line-height: 1.5;
word-break: break-word;
position: relative;
}
.chat-msg .del {
position: absolute;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
color: #9ca3af;
cursor: pointer;
font-size: 12px;
opacity: 0;
transition: opacity 0.2s;
padding: 4px;
}
.chat-msg:hover .del { opacity: 1; }
.chat-msg .del:hover { color: #ef4444; } .chat-msg.other {
flex-direction: row;
}
.chat-msg.other .avatar {
margin-right: 10px;
}
.chat-msg.other .text {
background: #fff;
color: var(--chat-text);
border-radius: 4px 16px 16px 16px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.chat-msg.other .del {
right: -24px;
} .chat-msg.self {
flex-direction: row-reverse;
}
.chat-msg.self .avatar {
margin-left: 10px;
}
.chat-msg.self .content {
align-items: flex-end;
}
.chat-msg.self .text {
background: var(--chat-msg-self);
color: #fff;
border-radius: 16px 4px 16px 16px;
}
.chat-msg.self .del {
left: -24px;
} .chat-foot {
padding: 16px;
background: var(--chat-bg);
border-top: 1px solid var(--chat-border);
}
.chat-foot-inner {
display: flex;
gap: 10px;
align-items: flex-end;
}
.chat-foot textarea {
flex: 1;
border: 1px solid var(--chat-border);
border-radius: 12px;
padding: 12px 16px;
resize: none;
font-size: 14px;
line-height: 1.4;
max-height: 80px;
min-height: 44px;
outline: none;
transition: border-color 0.2s;
font-family: inherit;
}
.chat-foot textarea:focus {
border-color: var(--chat-primary);
}
.chat-foot textarea::placeholder {
color: #9ca3af;
}
.chat-foot button {
height: 44px;
padding: 0 20px;
background: var(--chat-primary);
color: #fff;
border: none;
border-radius: 12px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.2s;
flex-shrink: 0;
}
.chat-foot button:hover {
background: var(--chat-primary-light);
}
.chat-foot button:disabled {
opacity: 0.5;
cursor: not-allowed;
} .chat-tip {
text-align: center;
padding: 12px;
color: var(--chat-text-light);
font-size: 14px;
}
.chat-tip a {
color: var(--chat-primary);
text-decoration: none;
font-weight: 500;
}
.chat-tip a:hover {
text-decoration: underline;
} .chat-sys {
text-align: center;
padding: 8px 16px;
color: #9ca3af;
font-size: 12px;
} .msg-card {
display: flex;
background: #fff;
border: 1px solid var(--chat-border);
border-radius: 12px;
overflow: hidden;
text-decoration: none;
color: inherit;
transition: all 0.2s;
max-width: 260px;
}
.msg-card:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
transform: translateY(-1px);
}
.chat-msg.self .msg-card {
background: #fff;
}
.card-thumb {
width: 70px;
height: 70px;
object-fit: cover;
flex-shrink: 0;
}
.card-info {
flex: 1;
padding: 8px 10px;
display: flex;
flex-direction: column;
justify-content: space-between;
min-width: 0;
}
.card-title {
font-size: 13px;
font-weight: 600;
color: var(--chat-text);
line-height: 1.3;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.card-desc {
font-size: 11px;
color: var(--chat-text-light);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin: 4px 0;
}
.card-foot {
display: flex;
align-items: center;
gap: 6px;
}
.card-tag {
font-size: 10px;
padding: 2px 6px;
background: linear-gradient(135deg, #f093fb, #f5576c);
color: #fff;
border-radius: 4px;
}
.card-price {
font-size: 13px;
font-weight: 600;
color: #ef4444;
} @media (max-width: 480px) {
.knn-chat {
bottom: 80px;
}
.chat-box {
width: calc(100vw - 32px);
height: 60vh;
bottom: 70px;
}
.knn-chat.pos-right { right: 16px; }
.knn-chat.pos-left { left: 16px; }
}