/* ============================================================
 * i8HOME-Next 在线客服悬浮窗
 * 所有类名前缀 i8-service-，避免与主题样式冲突
 *
 * ⚠️ 本文件**同时承载"全站键盘焦点可见性"**（见文件末尾那一段，`TD-1.5.1-103`）。
 *   为什么放这里、而不是主题自己的 css：本文件是**系统侧组件样式**，
 *   **每个页面都会加载**，且**按设计必须自包含**（可能出现在客户自己的主题上）——
 *   这三条正好就是那个缺陷要的形态："系统侧注入一段全局样式，对老站/客户主题也有效"。
 * ============================================================ */

.i8-service {
    position: fixed;
    z-index: 9990;
    font-family: system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
    box-sizing: border-box;
}

.i8-service * {
    box-sizing: border-box;
}

/* ============ 位置 ============ */

.i8-service[data-position="right-bottom"] {
    right: 20px;
    bottom: 20px;
}

.i8-service[data-position="left-bottom"] {
    left: 20px;
    bottom: 20px;
}

.i8-service[data-position="right-middle"] {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.i8-service[data-position="left-middle"] {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

/* ============ 悬浮按钮 ============ */

.i8-service-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0a7a35;
    color: #fff;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(10, 122, 53, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    padding: 0;
    outline: none;
}

.i8-service-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(10, 122, 53, 0.45);
}

.i8-service-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    display: block;
}

/* 呼吸动画（未打开面板时，吸引注意力） */
.i8-service-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(10, 122, 53, 0.4);
    animation: i8-service-pulse 2s infinite;
    pointer-events: none;
}

.i8-service.is-open .i8-service-btn::after {
    display: none;
}

@keyframes i8-service-pulse {
    0%   { transform: scale(1);    opacity: 0.7; }
    70%  { transform: scale(1.25); opacity: 0;   }
    100% { transform: scale(1.25); opacity: 0;   }
}

/* ============ 面板 ============ */

.i8-service-panel {
    position: absolute;
    width: 320px;
    max-width: calc(100vw - 40px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    pointer-events: none;
}

.i8-service.is-open .i8-service-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* 面板位置：底部锚点时在按钮上方 */
.i8-service[data-position="right-bottom"] .i8-service-panel,
.i8-service[data-position="left-bottom"] .i8-service-panel {
    bottom: 72px;
}

.i8-service[data-position="right-bottom"] .i8-service-panel,
.i8-service[data-position="right-middle"] .i8-service-panel {
    right: 0;
}

.i8-service[data-position="left-bottom"] .i8-service-panel,
.i8-service[data-position="left-middle"] .i8-service-panel {
    left: 0;
}

.i8-service[data-position="right-middle"] .i8-service-panel,
.i8-service[data-position="left-middle"] .i8-service-panel {
    top: 50%;
    transform: translateY(calc(-50% + 12px));
}

.i8-service.is-open[data-position="right-middle"] .i8-service-panel,
.i8-service.is-open[data-position="left-middle"] .i8-service-panel {
    transform: translateY(-50%);
}

/* ============ 面板头部 ============ */

.i8-service-header {
    background: linear-gradient(135deg, #0a7a35 0%, #0f9d4a 100%);
    color: #fff;
    padding: 18px 20px;
    position: relative;
}

.i8-service-header h4 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
}

.i8-service-welcome {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    opacity: 0.9;
}

.i8-service-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 0;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
}

.i8-service-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============ 面板主体 ============ */

.i8-service-body {
    padding: 16px 20px 20px;
    max-height: 420px;
    overflow-y: auto;
}

.i8-service-body::-webkit-scrollbar {
    width: 4px;
}

.i8-service-body::-webkit-scrollbar-thumb {
    background: #dcdcdc;
    border-radius: 2px;
}

/* 二维码区块 */
.i8-service-qr {
    text-align: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.i8-service-qr img {
    width: 160px;
    height: 160px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    margin: 0 auto 8px;
    background: #fafbfc;
    padding: 6px;
    border: 1px solid #f0f0f0;
}

.i8-service-qr-text {
    font-size: 12px;
    color: #999;
    margin: 0;
}

/* 信息列表 */
.i8-service-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.i8-service-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 14px;
}

.i8-service-item:last-child {
    border-bottom: 0;
}

.i8-service-icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    color: #0a7a35;
    margin-top: 1px;
}

.i8-service-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}

.i8-service-content {
    flex: 1;
    min-width: 0;
}

.i8-service-label {
    font-size: 12px;
    color: #999;
    display: block;
    margin-bottom: 2px;
    line-height: 1.3;
}

.i8-service-value {
    font-size: 14px;
    color: #222;
    line-height: 1.5;
    word-break: break-word;
    text-decoration: none;
    display: block;
}

.i8-service-value.is-link {
    color: #0a7a35;
    cursor: pointer;
    transition: color 0.15s;
}

.i8-service-value.is-link:hover {
    text-decoration: underline;
}

/* 复制按钮 */
.i8-service-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #0a7a35;
    background: #eafaf0;
    border: 1px solid #c4e7d0;
    border-radius: 4px;
    padding: 2px 8px;
    margin-left: 6px;
    cursor: pointer;
    transition: all 0.15s;
    vertical-align: middle;
}

.i8-service-copy:hover {
    background: #d8f2e2;
}

.i8-service-copy.is-copied {
    background: #0a7a35;
    border-color: #0a7a35;
    color: #fff;
}

/* 工作时间 */
.i8-service-worktime {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #f0f0f0;
    font-size: 12px;
    color: #999;
    text-align: center;
    line-height: 1.6;
}

/* ============ 移动端 ============ */

@media (max-width: 640px) {
    .i8-service[data-position="right-bottom"],
    .i8-service[data-position="right-middle"] {
        right: 14px;
    }

    .i8-service[data-position="left-bottom"],
    .i8-service[data-position="left-middle"] {
        left: 14px;
    }

    .i8-service[data-position="right-bottom"],
    .i8-service[data-position="left-bottom"] {
        bottom: 14px;
    }

    .i8-service-btn {
        width: 48px;
        height: 48px;
    }

    .i8-service-btn svg {
        width: 22px;
        height: 22px;
    }

    .i8-service-panel {
        width: calc(100vw - 28px);
        max-width: 340px;
    }

    .i8-service[data-position="right-bottom"] .i8-service-panel,
    .i8-service[data-position="left-bottom"] .i8-service-panel {
        bottom: 62px;
    }

    .i8-service-body {
        max-height: 60vh;
    }
}
/* ============================================================
 * ★ 全站键盘焦点可见性（WCAG 2.4.7）——  `TD-1.5.1-103` · P1
 * ------------------------------------------------------------
 * 【为什么这段放在这里】（**位置是刻意的，别搬走**）
 *   ① 本文件**每个页面都会加载**（第一手实测：首页 HTML 里有
 *      `<link … /themes/default/css/service.css>`，由主题布局输出）；
 *   ② 更要紧的是：本文件按设计**必须自包含**（见 `tokens.css` §9 的注释）——
 *      它是**系统侧注入组件**（客服浮窗）的样式，**可能出现在客户自己的主题上**，
 *      那时 `tokens.css` 根本不存在、`var(--c-brand)` 会解析失败。
 *      → 所以这段**一个字面量都不许换成 `var(--…)`**，这是**故意的**，不是漏改。
 *   ③ 这三条合起来正是本缺陷要的形态：**"系统侧注入一段全局样式，对老站/客户主题也有效"**。
 *
 * 【为什么要修】：全 CSS 里**没有任何 `:focus` / `:focus-visible` 规则**能让人看见焦点 ——
 *   只有 2 处把 `outline` **抹掉**（`page.css:142`、`admin.css:221` 那一族），
 *   改成"只变边框颜色"（**不等效**：键盘用户仍然不知道焦点在哪）。**WCAG 2.4.7 不达标**。
 *
 * 【三条设计决定，都写了理由】
 *   ① **用 `:focus-visible` 而不是 `:focus`** —— 前者只在"键盘/辅助技术"导航时出现，
 *      鼠标点击**不会**弹出焦点环。这样修好无障碍，**又不破坏鼠标用户的原观感**
 *      （否则"点一下输入框就有个圈"会让整套界面显得廉价）。
 *   ② **只加、不覆盖**（`outline` + `outline-offset` + 圆角），**不用 `!important`** ——
 *      理由与 §6.5 的"系统侧不许抢主题的活"一致：主题若自己做了更好的焦点样式，**让它赢**。
 *      本段是**兜底**（"至少看得见"），不是"唯一正确答案"。
 *   ③ **颜色用 `currentColor`** —— 它自动跟随所在元素的文字色：
 *      深色区块上是浅环、浅色区块上是深环，**一套规则在全站都够用**，
 *      而且**不需要**知道主题的主色（这正是"自包含"要求的副产品）。
 * ============================================================ */

:focus-visible {
    outline: 3px solid currentColor;
    /* 让环与元素之间留一道空隙，环才"看得清是围着谁"（0 会贴在边框上，观感糊） */
    outline-offset: 2px;
    /* 圆角只为让直角元素的焦点环**跟着圆角走**（现代浏览器支持；不支持的忽略这一行，无害） */
    border-radius: inherit;
}

/* 深色底/品牌底上的元素：`currentColor` 可能恰好与底色接近 → 再补一圈"外白内描"。
 * ⚠️ 这一段**仍是只加不覆盖**：它只给"本来就是深底"的少数元素更清楚的环。 */
.i8-service button:focus-visible,
.i8-service a:focus-visible,
.i8-service [tabindex]:focus-visible {
    /* 浮窗可能压在图片/深色区上 → 用双色环保证在**任何底色**上都看得见 */
    outline: 3px solid #ffffff;
    box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.45);
}

/* 跳转锚（"跳到主内容"那类）：键盘用户按下 Tab 的**第一站**，必须一眼可见。
 * 本项目当前没有这种锚点，这段是给**将来加**的时候兜底（`sitemap` 之外的无障碍常备件）。 */
a[href^="#"]:focus-visible,
[role="button"]:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

/* ============================================================
 * ★「主推方式」高亮 —— `TD-1.5.1-086` · P1
 * ------------------------------------------------------------
 * 【修的是什么，以及**没有**修什么（诚实边界，别误读）】
 *   账本这两件事**必须分开看**：
 *     · `service_type`（后台"主推方式"，`0025` 迁移的**描述原文**是
 *       **"点击按钮后主要展示哪种联系方式"**）—— 这是**纯展示**口径 ✓ **本条修的就是它**；
 *     · "零事件埋点"是**另一件事**，口径完全不同，已**拆成自己的债**（见账本 `TD-1.5.1-112`）——
 *       **为什么拆**：全站 **0 处 `fetch`/`XMLHttpRequest`/`sendBeacon`**，
 *       系统**没有**任何"JS 向服务器写数据"的通道；为埋点新造一条公开写入端点，
 *       是在跟这套系统的设计对抗（S-206）。**不许把两件事混在一条里蒙过去。**
 *
 * 【修法】（为什么是纯 CSS，不碰 JS）
 *   模板里已经有 `data-primary="<主推方式>"`（`<ul>` 上）与 `data-type="<方式>"`（每个 `<li>` 上），
 *   于是**属性选择器**就能把"主推行"标出来 —— **不需要**改 JS、**不需要**新增任何请求。
 *
 * 【为什么用"强调行"而不是"只留主推"】
 *   描述原文是"**主要展示**哪种" —— 是**主次**，不是**独家**。
 *   把其余联系方式藏掉会让"客户想打电话却只看到微信"这种最常见的情况变糟。
 *   → 所以：**主推行加一道左侧强调条 + 浅底**，其余照常可见、只是不抢眼。
 *
 * 【兼容性】只用 `[data-*]` 属性选择器（**不用 `:has()`**）——
 *   本文件是系统侧样式，可能出现在客户主题上，**不能假设浏览器版本**。
 * ============================================================ */

.i8-service-list[data-primary="wechat"] .i8-service-item[data-type="wechat"],
.i8-service-list[data-primary="phone"]  .i8-service-item[data-type="phone"],
.i8-service-list[data-primary="qq"]     .i8-service-item[data-type="qq"],
.i8-service-list[data-primary="email"]  .i8-service-item[data-type="email"] {
    /* 左侧强调条：不占额外宽度、不动布局（padding 本来就够） */
    box-shadow: inset 3px 0 0 #0a7a35;
    background: #eafaf0;
    border-radius: 4px;
    padding-left: 10px;
}

/* 主推行的标签也跟着强调一下，让人一眼认出"这就是他们希望我先用的" */
.i8-service-list[data-primary="wechat"] .i8-service-item[data-type="wechat"] .i8-service-label,
.i8-service-list[data-primary="phone"]  .i8-service-item[data-type="phone"]  .i8-service-label,
.i8-service-list[data-primary="qq"]     .i8-service-item[data-type="qq"]     .i8-service-label,
.i8-service-list[data-primary="email"]  .i8-service-item[data-type="email"]  .i8-service-label {
    color: #0a7a35;
    font-weight: 700;
}
