/* 聊天浮窗样式 - 用于访客端 */
#chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #4a90d9;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}
.chat-toggle:hover {
    transform: scale(1.05);
    background: #357abd;
}

.chat-window {
    width: 360px;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
}
.chat-window.open {
    display: flex;
}

.chat-header {
    background: #4a90d9;
    color: #fff;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: normal;
}
.chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    padding: 12px 16px;
    overflow-y: auto;
    background: #f7f9fc;
}
.message-item {
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
}
.message-item .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ccc;
    flex-shrink: 0;
    margin-right: 10px;
}
.message-item .bubble {
    max-width: 75%;
    padding: 8px 14px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    word-break: break-word;
    font-size: 14px;
    line-height: 1.5;
}
.message-item.mine {
    flex-direction: row-reverse;
}
.message-item.mine .avatar {
    margin-right: 0;
    margin-left: 10px;
}
.message-item.mine .bubble {
    background: #95ec69;
}
.message-item.system .bubble {
    background: #e9ecef;
    color: #666;
    font-style: italic;
    text-align: center;
    width: 100%;
}

.chat-input-area {
    display: flex;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fff;
    align-items: center;
}
.chat-input-area input[type="text"] {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    outline: none;
    font-size: 14px;
}
.chat-input-area input[type="text"]:focus {
    border-color: #4a90d9;
}
.chat-input-area button {
    margin-left: 6px;
    padding: 8px 16px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
}
.chat-input-area button:hover {
    background: #357abd;
}
.chat-input-area .file-btn {
    background: #6c757d;
    padding: 8px 12px;
}
.chat-input-area .file-btn:hover {
    background: #5a6268;
}

/* 嵌入前台主题时的移动端适配：上移避开页面底部固定导航栏 */
@media (max-width: 1023px) {
    #chat-widget {
        bottom: 118px;
        right: 12px;
    }
    .chat-window {
        width: min(360px, calc(100vw - 24px));
        height: min(500px, calc(100vh - 220px));
    }
}

/* 消息时间 */
.chat-messages .bubble .msg-time {
    font-size: 11px;
    color: #bbb;
    margin-top: 4px;
    line-height: 1.4;
}
.chat-messages .message-item.mine .msg-time {
    text-align: right;
}

/* 头像图片（客服自定义头像 / 访客默认头像） */
.message-item .avatar {
    overflow: hidden;
}
.message-item .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

/* 业务员用户名（气泡内顶部小字） */
.chat-messages .bubble .msg-sender {
    font-size: 11px;
    color: #90a4ae;
    margin-bottom: 2px;
    line-height: 1.4;
}
.chat-messages .message-item.mine .bubble .msg-sender {
    text-align: right;
}