/* 在线客服聊天组件 */
.chat-widget {
    position: fixed;
    right: 25px;
    bottom: 25px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6b5bfc, #8e7cf3);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(107, 91, 252, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    flex-direction: column;
    line-height: 1.2;
}

.chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(107, 91, 252, 0.5);
}

.chat-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.chat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
}


.chat-box {
    position: absolute;
    right: 0;
    bottom: 70px;
    width: 360px;
    max-width: calc(100vw - 30px);
    height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.25s ease-out;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-header {
    padding: 14px 18px;
    background: linear-gradient(135deg, #6b5bfc, #8e7cf3);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-size: 15px;
    font-weight: 600;
}

.chat-close {
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-close:hover {
    opacity: 1;
}

.chat-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    display: flex;
    max-width: 80%;
}

.chat-msg-self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg-other {
    align-self: flex-start;
}

.chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    margin: 0 8px;
    object-fit: cover;
    background: #e0e0e0;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

.chat-msg-self .chat-bubble {
    background: #6b5bfc;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg-other .chat-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}

.chat-bubble img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    display: block;
}

.chat-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
    white-space: nowrap;
}

.chat-msg-other .chat-time {
    text-align: left;
}

.chat-status {
    font-size: 11px;
    color: #aaa;
    margin-top: 2px;
    text-align: right;
}

.chat-emoji-panel {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.chat-emoji {
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-emoji:hover {
    background: #f0f0f0;
}

.chat-input-area {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
}

.chat-tools {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.chat-tool-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    position: relative;
}

.chat-tool-btn:hover {
    background: #f0f0f0;
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 80px;
}

.chat-input:focus {
    border-color: #6b5bfc;
}

.chat-send-btn {
    padding: 8px 18px;
    background: #6b5bfc;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: #5a48e0;
}

.chat-empty {
    text-align: center;
    color: #999;
    font-size: 13px;
    padding: 30px 0;
}

.chat-loading {
    text-align: center;
    color: #999;
    font-size: 12px;
    padding: 10px;
}

@media (max-width: 480px) {
    .chat-widget {
        right: 15px;
        bottom: 15px;
    }
    .chat-box {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 70px;
    }
}
