/* 右侧浮动客服菜单样式 */
.floating-service-menu {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 菜单开关按钮（移动端） */
.floating-menu-toggle {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    width: 50px;
    height: 50px;
    background: #003366;
    border-radius: 50%;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.floating-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #fff;
    margin: 3px 0;
    transition: all 0.3s ease;
}

.floating-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.floating-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.floating-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* 菜单容器 */
.floating-menu-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    transition: all 0.3s ease;
}

/* 菜单项 */
.floating-menu-item {
    position: relative;
    width: 60px;
    height: 60px;
    background: #003366;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.floating-menu-item:hover {
    background: #ffcc00;
    transform: translateX(-5px);
    width: auto;
    border-radius: 30px;
    padding-right: 15px;
}

.floating-menu-item:hover .floating-menu-label {
    opacity: 1;
    width: auto;
    margin-left: 10px;
    margin-right: 10px;
}

.floating-menu-link {
    display: flex;
    align-items: center;
    color: #fff;
    text-decoration: none;
    width: 100%;
    height: 100%;
    justify-content: center;
}

.floating-menu-item:hover .floating-menu-link {
    color: #003366;
    justify-content: flex-start;
    padding-left: 20px;
}

.floating-menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.floating-menu-label {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* 电话号码 */
.phone-number {
    display: none;
}

.phone-item:hover .phone-number {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-left: 5px;
    color: #003366;
}

.phone-item:hover .floating-menu-label {
    display: none;
}

/* 微信二维码 */
.wechat-item {
    position: relative;
}

.wechat-qrcode {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    padding: 15px;
    width: 180px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    /* 提高 z-index，确保在最上层 */
    z-index: 10002; /* 从 10000 改为 10002 */
}

.wechat-item:hover .wechat-qrcode {
    opacity: 1;
    visibility: visible;
    right: 75px;
}

.qrcode-content {
    text-align: center;
}

.qrcode-title {
    font-size: 14px;
    font-weight: 600;
    color: #003366;
    margin-bottom: 10px;
}

.qrcode-img img {
    width: 150px;
    height: 150px;
    border-radius: 4px;
    /* 确保图片层级正确 */
    position: relative;
    z-index: 1;
}

.qrcode-tip {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
}

.qrcode-arrow {
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #fff;
    /* 如果需要，箭头也可以设置 z-index */
    z-index: 10003;
}

/* WhatsApp 菜单项特殊样式 */
.whatsapp-item {
    background: #003366; /* 保持品牌主色 */
}

.whatsapp-item:hover {
    background: #25D366; /* WhatsApp品牌色 */
}

/* 在线客服对话框 */
.live-chat-modal {
    position: fixed;
    bottom: 100px;
    right: 90px;
    width: 320px;
    height: 450px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    /* 降低对话框的 z-index，让二维码可以显示在上面 */
    z-index: 10001; /* 从 10000 改为 10001 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.live-chat-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.chat-header {
    background: #003366;
    color: #fff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
}

.chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 15px;
}

.message {
    margin-bottom: 15px;
    max-width: 80%;
}

.message.agent {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-content {
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
}

.message.agent .message-content {
    background: #f0f2f5;
    color: #333;
}

.message.user .message-content {
    background: #003366;
    color: #fff;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

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

.chat-input-area {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border 0.3s;
}

.chat-input:focus {
    border-color: #003366;
}

.chat-send {
    background: #003366;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.chat-send:hover {
    background: #004488;
}

/* WhatsApp 悬浮提示 */
.whatsapp-tip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: #25D366;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    /* 保持或降低 WhatsApp 提示的 z-index */
    z-index: 10001; /* 从 10000 改为 10001 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.whatsapp-item:hover .whatsapp-tip {
    opacity: 1;
    visibility: visible;
    right: 75px;
}

.whatsapp-tip::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid #25D366;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .floating-service-menu {
        right: 10px;
        bottom: 20px;
        top: auto;
        transform: none;
    }
    
    .floating-menu-toggle {
        display: flex;
    }
    
    .floating-menu-container {
        position: absolute;
        right: 0;
        bottom: 60px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px);
        transition: all 0.3s ease;
    }
    
    .floating-menu-container.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .floating-menu-item {
        width: 50px;
        height: 50px;
    }
    
    .floating-menu-item:hover {
        width: 50px;
        border-radius: 50%;
        padding-right: 0;
        transform: translateX(0);
    }
    
    .floating-menu-item:hover .floating-menu-link {
        padding-left: 0;
        justify-content: center;
    }
    
    .floating-menu-item:hover .floating-menu-label {
        display: none;
    }
    
    .phone-item:hover .phone-number {
        display: none;
    }
    
    .wechat-qrcode {
        right: 60px;;
        width: 150px;
        padding: 10px;
        z-index: 10002;
    }
    
    .wechat-item:hover .wechat-qrcode {
        right: 65px;
    }
    
    .qrcode-img img {
        width: 130px;
        height: 130px;
    }
    
    .whatsapp-tip {
        right: 60px;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .whatsapp-item:hover .whatsapp-tip {
        right: 65px;
    }
    
    .live-chat-modal {
        width: calc(100% - 40px);
        height: 400px;
        right: 20px;
        bottom: 80px;
        z-index: 10001;
    }
}

@media (max-width: 480px) {
    .floating-service-menu {
        right: 5px;
        bottom: 15px;
    }
    
    .floating-menu-toggle {
        width: 45px;
        height: 45px;
    }
    
    .floating-menu-item {
        width: 45px;
        height: 45px;
    }
    
    .wechat-qrcode {
        width: 130px;
        right: 50px;
    }
    
    .wechat-item:hover .wechat-qrcode {
        right: 55px;
    }
    
    .qrcode-img img {
        width: 110px;
        height: 110px;
    }
    
    .whatsapp-tip {
        right: 50px;
        width: 120px;
        white-space: normal;
        text-align: center;
    }
    
    .whatsapp-item:hover .whatsapp-tip {
        right: 55px;
    }
    
    .live-chat-modal {
        width: calc(100% - 20px);
        right: 10px;
        bottom: 70px;
        height: 350px;
    }
}