/* ============================================================
   智能客服悬浮组件（独立新增模块，类名统一 kefu- 前缀，不影响原有样式）
   1. 入口按钮固定在 TOP 按钮正下方
   2. 点击后以页面图层方式弹出客服会话窗口（非浏览器新窗口）
   ============================================================ */

/* ---------- 入口按钮：与 TOP 按钮同宽同位，位于其下方 10px ---------- */
/* TOP 按钮原样式：width:77px; position:fixed; right:14%; top:60%; */
.kefu-fab {
    position: fixed;
    right: 14%;
    top: 71%;                 /* 不支持 calc 的旧浏览器兜底 */
    top: calc(60% + 87px);    /* 60% + TOP 高度 77px + 间距 10px */
    width: 77px;
    height: 77px;
    margin: 0;
    padding: 0;
    border: none;
    outline: none;
    overflow: hidden;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    background: #707070;
    z-index: 99999;
    -webkit-transition: background .3s;
    -moz-transition: background .3s;
    transition: background .3s;
}
.kefu-fab:hover,
.kefu-fab:focus {
    background: #6ebdcc;      /* 与全站 hover 强调色一致 */
}
.kefu-fab svg {
    display: block;
    width: 36px;
    height: 36px;
    margin: 9px auto 1px;
}
.kefu-fab .kefu-fab-txt {
    display: block;
    color: #fff;
    font-size: 13px;
    line-height: 16px;
    font-family: Arial, Helvetica, sans-serif;
}

/* 与 TOP 按钮保持相同的响应式右偏移 */
@media screen and (max-width: 1600px) {
    .kefu-fab { right: 5%; }
}

/* 移动端（<=1004px，与 media.css 断点一致；此时 TOP 按钮已隐藏） */
@media screen and (max-width: 1004px) {
    .kefu-fab {
        right: 12px;
        top: auto;
        bottom: 12px;
        width: 58px;
        height: 58px;
    }
    .kefu-fab svg {
        width: 28px;
        height: 28px;
        margin: 6px auto 1px;
    }
    .kefu-fab .kefu-fab-txt {
        font-size: 11px;
        line-height: 13px;
    }
}

/* ---------- 遮罩层 ---------- */
.kefu-mask {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .35);
    z-index: 99998;
}
.kefu-mask.kefu-open {
    display: block;
}

/* ---------- 弹窗主体（图层模拟弹窗） ---------- */
.kefu-panel {
    display: none;
    position: fixed;
    right: 14%;
    bottom: 20px;
    width: 380px;
    height: 600px;
    max-height: 82vh;
    background: #fff;
    z-index: 99999;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
    -moz-box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
    -webkit-box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.kefu-panel.kefu-open {
    display: block;
}
@media screen and (max-width: 1600px) {
    .kefu-panel { right: 5%; }
}

/* 弹窗标题栏 */
.kefu-panel .kefu-head {
    position: relative;
    height: 48px;
    line-height: 48px;
    padding: 0 12px;
    background: #6ebdcc;
    color: #fff;
}
.kefu-panel .kefu-title {
    font-size: 16px;
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
}
.kefu-panel .kefu-tools {
    position: absolute;
    right: 10px;
    top: 0;
    height: 48px;
    line-height: 48px;
    white-space: nowrap;
}
.kefu-panel .kefu-ext {
    color: #fff;
    font-size: 13px;
    font-family: Arial, Helvetica, sans-serif;
    text-decoration: none;
    margin-right: 12px;
    opacity: .9;
}
.kefu-panel .kefu-ext:hover {
    opacity: 1;
    text-decoration: underline;
}
.kefu-panel .kefu-close {
    display: inline-block;
    vertical-align: middle;
    width: 28px;
    height: 28px;
    line-height: 26px;
    color: #fff;
    font-size: 20px;
    font-family: Arial, Helvetica, sans-serif;
    text-align: center;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 50%;
}
.kefu-panel .kefu-close:hover {
    background: rgba(255, 255, 255, .2);
}

/* 弹窗体：iframe 填满剩余区域 */
.kefu-panel .kefu-body {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f5f5;
}
.kefu-panel iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #fff;
}
.kefu-loading {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    margin-top: -10px;
    text-align: center;
    color: #888;
    font-size: 13px;
    font-family: Arial, Helvetica, sans-serif;
}
.kefu-loading.kefu-hide {
    display: none;
}

/* ---------- 移动端适配：弹窗近乎全屏 ---------- */
@media screen and (max-width: 1004px) {
    .kefu-panel {
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        height: 75vh;
        max-height: none;
    }
}
@media screen and (max-width: 360px) {
    .kefu-panel .kefu-ext {
        display: none;
    }
}
