/* ---------- 在线客服 /kefu（淡蓝配色，避免高饱和 #1989fa 刺眼） ---------- */

/* 独立客服页：无整站顶栏时顶边距拉满 */
body.kefu-standalone .main.page-kefu {
    margin-top: 0;
    padding-top: 12px;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
}

.kefu-wrap {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 8px 0 32px;
    box-sizing: border-box;
}
.kefu-left {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.kefu-box {
    background: #fff;
    border-radius: 3px;
    border: var(--surface-border);
    box-shadow: var(--surface-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.kefu-hd {
    background: #f2f3f4;
    color: #1a4d6e;
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 600;
}
.kefu-msgs {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}
.kefu-msgs .msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 3px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}
.kefu-msgs .msg.visitor {
    align-self: flex-end;
    background: #e0eff9;
    color: #2c4a6b;
    border: 1px solid rgba(44, 74, 107, 0.08);
    border-bottom-right-radius: 4px;
}
.kefu-msgs .msg.staff {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: var(--surface-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.kefu-msgs .msg .time { font-size: 11px; opacity: 0.75; margin-top: 4px; }
.kefu-msgs .msg.visitor .time { text-align: right; }
.kefu-msgs .msg.sending { opacity: 0.55; }
.kefu-msgs .sys-tip { text-align: center; font-size: 13px; color: #999; padding: 10px 0; }
.kefu-ipt {
    display: flex;
    border-top: var(--divider-soft);
    background: #fff;
}
.kefu-ipt textarea {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 14px;
    font-size: 14px;
    resize: none;
    height: 60px;
    font-family: inherit;
}
/* 发送：与 layui 按钮同类交互——纯色 + background-color 过渡，悬停略亮、按下略暗 */
.kefu-ipt button {
    width: 80px;
    border: none;
    background-color: #000;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s ease;
}
.kefu-ipt button:hover {
    background-color: #4a4a4a;
}
.kefu-ipt button:active {
    background-color: #1a1a1a;
}

.kefu-right { width: 280px; flex-shrink: 0; }
.kefu-info {
    background: #fff;
    border-radius: 3px;
    border: var(--surface-border);
    box-shadow: var(--surface-shadow);
    padding: 22px 20px;
    text-align: center;
}
.kefu-info .tg-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, #0088cc, #00aaff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.kefu-info .tg-icon svg { width: 32px; height: 32px; fill: #fff; }
.kefu-info .tg-label { font-size: 13px; color: #666; margin-bottom: 8px; }
.kefu-info .tg-link {
    display: inline-block;
    font-size: 16px;
    font-weight: 600;
    color: #1989fa;
    text-decoration: none;
    padding: 8px 18px;
    background: #e8f4ff;
    border-radius: 3px;
    border: 1px solid rgba(25, 137, 250, 0.22);
    transition: background 0.2s, box-shadow 0.2s;
}
.kefu-info .tg-link:hover { background: #d6ebff; box-shadow: var(--surface-shadow); }
.kefu-info .notice--solo {
    margin-top: 0;
}
.kefu-info .notice {
    margin-top: 20px;
    padding: 14px 16px;
    background: #f3f8fc;
    border-radius: 3px;
    border: 1px solid rgba(61, 122, 158, 0.12);
    text-align: left;
}
.kefu-info .notice-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.kefu-info .notice-title::before { content: "📱"; font-size: 16px; }
.kefu-info .notice-text { font-size: 13px; color: #666; line-height: 1.75; }

/* 客服页（桌面）：整页不滚动，仅 .kefu-msgs 内滚动；原 body.page-kefu 用 :has 挂在 body 上 */
body:has(.main.page-kefu) {
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}
/* 客服页主栏：占满顶栏与页脚之间 */
.main.page-kefu {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-top: 8px;
    margin-bottom: 0;
    padding-bottom: 8px;
}
.main.page-kefu .kefu-wrap {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 0 0;
    overflow: hidden;
    align-items: stretch;
}
.main.page-kefu .kefu-right {
    max-height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
body:has(.main.page-kefu) .site-footer-wrap {
    margin-top: 0;
}

@media (max-width: 768px) {
    body:has(.main.page-kefu) {
        min-height: 0;
        max-height: none;
        overflow: visible;
    }
    /* .kefu-wrap 仅用于 /kefu：竖向 column，DOM 顺序先左后右 → 聊天在上、TG 在下 */
    .kefu-wrap { flex-direction: column; padding-bottom: 0; }
   .kefu-right { width: 100%; }

    /* 手机：允许整页滚动（根节点也要放开，否则 common.css 里 html{height:100%} 时滚动链断裂） */
    html:has(.main.page-kefu) {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .main.page-kefu {
        height: auto;
        max-height: none;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 0 1 auto;
    }
    .main.page-kefu .kefu-wrap {
        flex: 0 1 auto;
        min-height: auto;
        overflow: visible;
    }
    .main.page-kefu .kefu-left {
        flex: 0 1 auto;
        min-height: auto;
    }
    .main.page-kefu .kefu-box {
        flex: 0 1 auto;
        min-height: min(65vh, 560px);
    }
    .main.page-kefu .kefu-msgs {
        flex: 1 1 auto;
        min-height: min(38vh, 320px);
    }
    .main.page-kefu .kefu-right {
        flex-shrink: 0;
        max-height: none;
        overflow: visible;
    }
}
