﻿/* ========================================
   在线咨询悬浮按钮 - 公共样式
   ======================================== */

/* 悬浮按钮 */
.online-consult-btn {
    position: fixed;
    left: 20px;
    bottom: 80px;
    z-index: 99998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transition: all 0.3s ease;
    border: none;
    font-size: 24px;
}

.online-consult-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.5);
}

.online-consult-btn .consult-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.online-consult-btn .consult-icon svg {
    width: 100%;
    height: 100%;
    fill: #fff;
}

/* 按钮上的小红点（有新咨询时显示） */
.online-consult-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
}

/* 未读小红点（只显示圆点，不显示数字） */
.online-consult-btn .unread-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    z-index: 1;
    animation: unreadPulse 2s infinite;
}

@keyframes unreadPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
}

/* 弹窗表单 */
.online-consult-modal {
    position: fixed !important;
    left: 20px !important;
    bottom: 150px !important;
    top: auto !important;
    right: auto !important;
    z-index: 99999 !important;
    width: 340px !important;
    max-width: 340px !important;
    background: #fff !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
    display: none !important;
    overflow: hidden !important;
    opacity: 1 !important;
    transform: none !important;
    animation: consultSlideUp 0.3s ease !important;
}

@keyframes consultSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.online-consult-modal.show {
    display: block !important;
    opacity: 1 !important;
}

/* 弹窗头部 */
.consult-modal-header {
    background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
    color: #fff !important;
    padding: 16px 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    width: auto !important;
    height: auto !important;
    line-height: normal !important;
    text-align: left !important;
}

.consult-modal-header h3 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #fff !important;
    padding: 0 !important;
    border: none !important;
    line-height: normal !important;
    text-align: left !important;
}

.consult-modal-header .close-btn {
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 20px !important;
    cursor: pointer !important;
    padding: 0 !important;
    width: 28px !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 4px !important;
    transition: background 0.2s !important;
    margin: 0 !important;
    line-height: 1 !important;
}

.consult-modal-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* 弹窗内容 */
.consult-modal-body {
    padding: 20px;
}

.consult-form-group {
    margin-bottom: 14px;
}

/* 表单行：两个字段同一行 */
.consult-form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.consult-form-row .consult-form-group {
    flex: 1;
    margin-bottom: 0;
}

.consult-form-group label {
    display: block;
    font-size: 13px;
    color: #374151;
    margin-bottom: 6px;
    font-weight: 500;
}

.consult-form-group label .required {
    color: #ef4444;
    margin-left: 2px;
}

.consult-form-group input[type="text"],
.consult-form-group input[type="tel"],
.consult-form-group select,
.consult-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #1f2937;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    background: #fff;
}

.consult-form-group select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.consult-form-group input:focus,
.consult-form-group select:focus,
.consult-form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.consult-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 验证码 */
.consult-captcha-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.consult-captcha-row input {
    flex: 1;
}

.consult-captcha-img {
    height: 40px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    background: #f9fafb;
}

/* 提交按钮 */
.consult-submit-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 6px;
}

.consult-submit-btn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
}

.consult-submit-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* 提示信息 */
.consult-msg {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

.consult-msg.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    display: block;
}

.consult-msg.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    display: block;
}

/* 底部提示 */
.consult-modal-footer {
    padding: 10px 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}

.consult-modal-footer a {
    color: #3b82f6;
    text-decoration: none;
}

.consult-modal-footer a:hover {
    text-decoration: underline;
}

/* ========================================
   移动端适配
   ======================================== */
@media (max-width: 768px) {
    .online-consult-btn {
        width: 48px;
        height: 48px;
        left: 12px;
        bottom: 70px;
        font-size: 20px;
    }

    .online-consult-btn .consult-icon {
        width: 24px;
        height: 24px;
    }

    .online-consult-modal {
        width: calc(100% - 24px);
        left: 12px;
        right: 12px;
        bottom: 130px;
    }

    .consult-modal-header {
        padding: 14px 16px;
    }

    .consult-modal-header h3 {
        font-size: 15px;
    }

    .consult-modal-body {
        padding: 16px;
    }

    .consult-form-group {
        margin-bottom: 12px;
    }

    .consult-form-row {
        flex-direction: row;
        gap: 10px;
    }
    
    .consult-form-row .consult-form-group {
        flex: 1;
        margin-bottom: 0;
    }

    .consult-form-group input[type="text"],
    .consult-form-group input[type="tel"],
    .consult-form-group select,
    .consult-form-group textarea {
        padding: 10px;
        font-size: 15px; /* 防止iOS缩放 */
    }
}

/* ========================================
   右下角悬浮按钮组
   ======================================== */
.right-float-group {
    position: fixed;
    right: 27px;
    bottom: 45px;
    z-index: 99997;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 在线咨询包裹层：占一个按钮位（与其它按钮同尺寸），角标可溢出不被裁切 */
.right-float-group .chat-frame-wrap {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}
.right-float-group .chat-frame-wrap #__chatFrame {
    border-radius: 50%;
}
/* 外部未读角标：位于图标圆外右上角 */
.right-float-group .chat-ext-badge {
    position: absolute;
    top: -7px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 2px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #fff;
    box-sizing: border-box;
    z-index: 2;
}
/* 展开聊天时 iframe 脱离包裹层浮于右下角 */
.right-float-group #__chatFrame.chat-open {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 99999;
    border-radius: 14px;
}

.right-float-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
    border: none;
    font-size: 15px;
    text-decoration: none;
    position: relative;
}

.right-float-btn:hover {
    background: #2563eb;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.22);
}

.right-float-btn.back-to-top-btn {
    display: none;
}

.right-float-btn.back-to-top-btn.show {
    display: flex;
}

.right-float-btn.call-btn {
    background: #10b981;
    color: #fff;
}

.right-float-btn.call-btn:hover {
    background: #059669;
}

.right-float-btn.wechat-btn {
    background: #07c160;
    color: #fff;
}

.right-float-btn.wechat-btn:hover {
    background: #06ad56;
}

/* 微信二维码弹窗 */
.wechat-qr-popup {
    position: absolute;
    right: 130%;
    bottom: 50%;
    transform: translateY(50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 12px;
    display: none;
    width: 200px;
    text-align: center;
}

.right-float-btn.wechat-btn:hover .wechat-qr-popup,
.right-float-btn.wechat-btn.open .wechat-qr-popup {
    display: block;
}

.wechat-qr-popup img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.wechat-qr-popup p {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: #374151;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .right-float-group {
        right: 30px;
        bottom: 42px;
        gap: 10px;
    }

    .right-float-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }

    .right-float-group .chat-frame-wrap {
        width: 42px;
        height: 42px;
    }
    .right-float-group #__chatFrame.chat-open {
        right: 12px;
        bottom: 12px;
    }

    .wechat-qr-popup {
        width: 160px;
        right: 110%;
    }
}
