#chat-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    filter: drop-shadow(0 0 20px rgba(41, 151, 255, 0.2));
}

/* 移除原有的背景图片相关样式，改用 CSS 绘制的图标 */
#chat-widget-icon {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0052D4, #4364F7, #6FB1FC);
    box-shadow: 0 6px 24px rgba(67, 100, 247, 0.4),
                inset 0 2px 12px rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

/* 主对话框 */
#chat-widget-icon::before {
    content: '';
    position: absolute;
    width: 32px;
    height: 26px;
    background: #ffffff;
    border-radius: 12px;
    transform: translateX(-6px) translateY(-2px);
    box-shadow: inset 0 -1px 4px rgba(0, 0, 0, 0.1),
                0 4px 12px rgba(67, 100, 247, 0.2);
    transition: all 0.3s ease;
}

/* 小对话框 */
#chat-widget-icon::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 18px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 10px;
    transform: translateX(8px) translateY(4px);
    box-shadow: inset 0 -1px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

/* 动态消息点 */
.chat-dots {
    position: absolute;
    display: flex;
    gap: 4px;
    z-index: 2;
}

.chat-dots span {
    width: 5px;
    height: 5px;
    background: #ffffff;
    border-radius: 50%;
    opacity: 0.9;
    animation: dotPulse 1.5s infinite;
}

.chat-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* 悬停效果 */
#chat-widget-icon:hover {
    transform: scale(1.1) rotate(-4deg);
    background: linear-gradient(135deg, #4364F7, #6FB1FC, #89f7fe);
    box-shadow: 0 8px 32px rgba(67, 100, 247, 0.5),
                0 0 0 2px rgba(255, 255, 255, 0.2),
                inset 0 2px 12px rgba(255, 255, 255, 0.4);
}

#chat-widget-icon:hover::before {
    transform: translateX(-8px) translateY(-3px) scale(1.05);
}

#chat-widget-icon:hover::after {
    transform: translateX(10px) translateY(3px) scale(0.95);
}

/* 点击效果 */
#chat-widget-icon:active {
    transform: scale(0.95);
    box-shadow: 0 4px 16px rgba(0, 209, 255, 0.3);
}

/* 动画定义 */
@keyframes dotPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.5);
        opacity: 1;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

#chat-widget-icon:not(:hover) {
    animation: bounce 3s ease-in-out infinite;
}

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

/* 光晕效果 */
#chat-widget-icon::before,
#chat-widget-icon::after {
    animation: glow 4s linear infinite;
}

@keyframes glow {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

/* 新增消息提示徽标 */
.chat-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ff3366;
    color: white;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    border: 2px solid #ffffff;
    transform: translate(25%, -25%);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0% {
        transform: translate(25%, -25%) scale(1);
    }
    50% {
        transform: translate(25%, -25%) scale(1.1);
    }
    100% {
        transform: translate(25%, -25%) scale(1);
    }
}

/* 聊天窗口模块样式 */
#chat-widget-modal {
    width: 350px;
    height: 500px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
    overflow: hidden;
    display: none;
    opacity: 0;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0;
    transform: translateY(20px) scale(0.95);
}

#chat-widget-modal.pre-open {
    display: block;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
}

/* 展开时的动画类 */
#chat-widget-modal.open {
    display: block;
    transform: translateY(0) scale(1);
    opacity: 1;
    animation: modalOpen 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12), 
                0 0 0 1px rgba(0, 0, 0, 0.02);
}

/* 收起时的动画类 */
#chat-widget-modal.closing {
    animation: modalClose 0.3s ease forwards;
}

/* 添加预开启状态样式 */
#chat-widget-modal.pre-open {
    display: block;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

/* 展开动画 */
@keyframes modalOpen {
    0% {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
        backdrop-filter: blur(0);
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
        backdrop-filter: blur(10px);
    }
}

/* 收起动画 */
@keyframes modalClose {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
        backdrop-filter: blur(10px);
    }
    100% {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
        backdrop-filter: blur(0);
    }
}

/* 添加最小化动画 */
#chat-widget-modal.minimized {
    transform: translateY(80%) scale(0.95);
    opacity: 0.8;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}


/* iframe容器样式 */
#chat-iframe {
    border: none;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* 添加欢迎消息样式 */
.chat-welcome-toast {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4364F7, #6FB1FC);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(67, 100, 247, 0.3);
    color: white;
    font-size: 14px;
    max-width: 320px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
}

.chat-welcome-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.welcome-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.welcome-icon {
    font-size: 24px;
    margin-top: 2px;
}

.welcome-text {
    flex: 1;
}

.welcome-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px 0;
}

.welcome-subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
    line-height: 1.4;
}

.chat-welcome-toast.fade-out {
    opacity: 0;
    transform: translateY(20px);
}

.welcome-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.welcome-icon {
    font-size: 20px;
}

.chat-welcome-toast.fade-out {
    animation: slideOut 0.5s ease-in forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* 添加引导动画 */
@keyframes gentle-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

#chat-widget-modal:not(.minimized) {
    animation: gentle-bounce 2s infinite;
}

/* 移动端优化 */
@media (max-width: 768px) {
    #chat-widget-container {
        bottom: 15px;
        right: 15px;
    }
    
    #chat-widget-icon {
        width: 55px;
        height: 55px;
        transform-origin: center;
        will-change: transform;
    }
    
    #chat-widget-modal {
        width: 300px;
        height: 450px;
        border-radius: 8px;
    }
    
    /* 减轻动画复杂度 */
    @keyframes modalOpen {
        0% {
            transform: translateY(20px) scale(0.95);
            opacity: 0;
        }
        100% {
            transform: translateY(0) scale(1);
            opacity: 1;
        }
    }
    
    /* 确保显示在前面，不被其他元素覆盖 */
    #chat-widget-modal.open {
        z-index: 10001;
    }
    
    /* 点击区域优化 */
    #chat-widget-icon {
        padding: 5px;
    }
}

/* 小屏幕设备特别优化 */
@media (max-width: 480px) {
    #chat-widget-icon {
        width: 48px;
        height: 48px;
    }
    
    #chat-widget-modal {
        width: calc(100vw - 40px);
        max-width: 300px;
    }
    
    /* 精简动画以提高性能 */
    .chat-dots span {
        animation-duration: 2s;
    }
    
    /* 简化悬浮效果 */
    #chat-widget-icon:hover {
        transform: scale(1.05);
    }
}

/* 低端设备性能优化 */
@media (prefers-reduced-motion: reduce) {
    #chat-widget-icon,
    #chat-widget-modal,
    .chat-dots span,
    .chat-welcome-toast {
        transition: none !important;
        animation: none !important;
    }
    
    /* 提供简单过渡作为替代 */
    #chat-widget-modal.open {
        display: block;
        opacity: 1;
        transform: none;
    }
    
    #chat-widget-modal.closing {
        opacity: 0;
    }
}