/* chat-widget.css */
/* 聊天插件样式 */

/* 客服按钮 - 右下角浮动 */
#chat-widget-button {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6600 0%, #ff0000 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: all 0.3s ease;
    font-weight: bold;
    color: #fff;
    font-size: 24px;
    line-height: 28px;
}

#chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#chat-widget-button svg {
    width: 30px;
    height: 30px;
    fill: white;
    display: inline-block;
}

/* 聊天窗口容器 */
#chat-widget-container {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

#chat-widget-container.show {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 聊天窗口头部 */
.chat-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chat-widget-header .status {
    display: flex;
    align-items: center;
    font-size: 13px;
    opacity: 0.9;
    margin-top: 4px;
}

.chat-widget-header .status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    margin-right: 6px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-widget-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-widget-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 消息区域外层容器（新增） */
.chat-widget-messages-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 消息区域 */
.chat-widget-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
}

.chat-widget-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

/* 消息气泡 */
.chat-message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.user .chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.agent .chat-message-content {
    background: white;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.chat-message.system .chat-message-content {
    background: #e2e8f0;
    color: #718096;
    font-size: 13px;
    text-align: center;
    margin: 0 auto;
}

.chat-message-time {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 4px;
    text-align: right;
}

.chat-message.agent .chat-message-time {
    text-align: left;
}

/* 新消息提示按钮 */
.chat-new-messages-tip {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff6600 0%, #ff0000 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    z-index: 10;
    animation: slideInUp 0.3s ease;
    transition: all 0.2s;
}

.chat-new-messages-tip.show {
    display: flex;
}

.chat-new-messages-tip:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.chat-new-messages-tip .badge {
    background: rgba(255, 255, 255, 0.3);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.chat-new-messages-tip .arrow {
    font-size: 16px;
    animation: bounce-arrow 1s infinite;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce-arrow {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(3px);
    }
}

/* 输入区域 */
.chat-widget-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
}

.chat-widget-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-widget-input input:focus {
    border-color: #667eea;
}

.chat-widget-input button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-widget-input button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chat-widget-input button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

.chat-widget-input button svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* 加载状态 */
.chat-loading {
    display: flex;
    gap: 4px;
    padding: 12px;
}

.chat-loading-dot {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 移动端适配 */
@media (max-width: 480px) {
    #chat-widget-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    #chat-widget-button {
        bottom: 46px;
        right: 16px;
        width: 80px;
        height: 80px;
        font-size: 20px;
    line-height: 24px;
    }
    
    .chat-new-messages-tip {
        bottom: 16px;
        right: 16px;
    }
}