#chat-widget-container {
    position: fixed;
    bottom: 120px;
    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: 70px;
    height: 70px;
    border-radius: 50%;
    background: #2196F3; /* Keep the blue base color */
    box-shadow: 0 6px 24px rgba(33, 150, 243, 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: visible; /* Changed to visible to show the speech bubbles */
}

/* Add speech bubble design */
#chat-widget-icon::before {
    content: '';
    position: absolute;
    width: 38px;
    height: 38px;
    background: white;
    border-radius: 15px 15px 15px 4px; /* Speech bubble shape */
    top: 10px;
    left: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#chat-widget-icon::after {
    content: '';
    position: absolute;
    width: 28px;
    height: 28px;
    background: #E3F2FD; /* Light blue for contrast */
    border-radius: 15px 15px 4px 15px; /* Speech bubble shape */
    bottom: 12px;
    right: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 主对话框 */
#chat-widget-icon::before {
    content: '';
    position: absolute;
    width: 32px;
    height: 0px;
    background: #ffffff;
    border-radius: 12px;
    transform: translateX(-6px) translateY(-2px);
    box-shadow: inset 0 -1px 4px #e0e0e0,
                0 4px 12px #1e88e5;
    transition: all 0.3s ease;
}

/* 小对话框 */
#chat-widget-icon::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 18px;
    background: #ffffff;
    border-radius: 10px;
    transform: translateX(8px) translateY(4px);
    box-shadow: inset 0 -1px 4px #e0e0e0;
    transition: all 0.3s ease;
}

/* 动态消息点 */
.chat-dots {
    position: absolute;
    z-index: 2;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #ffffff;
    text-align: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    background: rgba(33, 150, 243, 0.35);
    padding: 3px 6px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    animation: gentle-pulse 2s infinite;
    content: "客服";
}

.chat-dots::before {
    content: "客服";
}

@keyframes gentle-pulse {
    0%, 100% { 
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1);
    }
    50% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.chat-dots span {
    width: 5px;
    height: 5px;
    background: #ffffff;
    border-radius: 50%;
    opacity: 1; /* Full opacity */
    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: #42a5f5; /* Lighter blue on hover */
    box-shadow: 0 8px 32px #42a5f5,
                0 0 0 2px #ffffff,
                inset 0 2px 12px #ffffff;
}

#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 20px 16px #1976d2;
}
/* 顶层提示遮挡 */
.chat-tooltip-overlay {
    position: absolute;
    top: -10px;
    right: 0;
    background: linear-gradient(135deg, #2196F3, #42a5f5, #64b5f6);
    color: white;
    padding: 10px 14px;
    font-size: 16px;
    border-radius: 12px 12px 2px 12px;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3), 
                0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 1000;
    text-align: center;
    max-width: 180px;
    line-height: 1.5;
    transform: translateY(0);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-tooltip-overlay:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

.chat-tooltip-overlay::before {
    content: "💬";
    display: inline-block;
    margin-right: 8px;
    animation: float 2s ease-in-out infinite;
}

.chat-tooltip-overlay::after {
    content: "可点击蓝色气泡收起聊天窗";
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Fade animation for the tooltip */
@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

.chat-tooltip-overlay {
    animation: fadeInOut 3s infinite;
}
/* 动画定义 */
@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: 300%; /* Increased from 180% for better adaptivity */
    max-width: 600px; /* Increased from 380px to provide more space */
    height: 75vh; /* Use viewport height for adaptivity */
    max-height: 750px; /* Maximum height for large screens */
    min-height: 400px; /* Minimum height for small screens */
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
    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);
}

/* Media queries for different screen sizes */
@media (max-width: 480px) {
    #chat-widget-modal {
        width: 150%;
        height: 80vh;
    }
}

@media (max-height: 600px) {
    #chat-widget-modal {
        height: 85vh;
        min-height: 300px;
    }
}

@media (min-width: 1200px) {
    #chat-widget-modal {
        max-width: 550px;
        max-height: 800px;
    }
}

#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;
}