/* ============ 前台聊天窗口样式 ============ */
.chat-widget {
    position: fixed;
    right: 30px;
    bottom: 30px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* 悬浮按钮 */
.chat-widget-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.chat-widget-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.chat-widget-btn .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ff4d4f;
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    padding: 0 5px;
    display: none;
}

/* 聊天面板 */
.chat-widget-panel {
    position: absolute;
    right: 0;
    bottom: 80px;
    width: 340px;
    height: 480px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatFadeIn 0.3s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-widget-panel.active {
    display: flex;
}

/* 头部 */
.chat-widget-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-header .title {
    font-size: 15px;
    font-weight: 500;
}

.chat-widget-header .status {
    font-size: 12px;
    opacity: 0.85;
}

.chat-widget-header .status .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #52c41a;
    margin-right: 4px;
}

.chat-widget-header .close-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.chat-widget-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 消息列表 */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f7fb;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #dcdfe6;
    border-radius: 3px;
}

.chat-message-item {
    margin-bottom: 14px;
    display: flex;
    animation: msgFadeIn 0.2s ease;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message-item.guest {
    justify-content: flex-end;
}

.chat-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.chat-message-item.admin .chat-message-bubble {
    background: #fff;
    color: #333;
    border-top-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.chat-message-item.guest .chat-message-bubble {
    background: #667eea;
    color: #fff;
    border-top-right-radius: 2px;
}

.chat-message-meta {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    display: block;
}

/* 输入框 */
.chat-widget-input {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.chat-widget-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid #e4e7ed;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-widget-input textarea:focus {
    border-color: #667eea;
}

.chat-widget-input .send-btn {
    width: 60px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.chat-widget-input .send-btn:hover {
    background: #5568d3;
}

.chat-widget-input .send-btn:disabled {
    background: #c0c4cc;
    cursor: not-allowed;
}

/* 状态提示 */
.chat-system-tip {
    text-align: center;
    font-size: 12px;
    color: #909399;
    margin: 8px 0;
}

/* 响应式：移动端 */
@media (max-width: 768px) {
    .chat-widget {
        right: 15px;
        bottom: 15px;
    }
    .chat-widget-panel {
        width: calc(100vw - 30px);
        height: 70vh;
        right: -5px;
    }
}
