/* ==========================================================================
   小程序内嵌（web-view）专属覆盖样式 —— 全站唯一的「环境差异」样式文件
   ==========================================================================
   隔离约定（新增规则必须遵守，由 check_style_isolation.ps1 自动校验）：
   1. 本文件每条规则的选择器必须以 html.mp-h5 / html.mp-immersive / html:not(.mp-h5) 开头，
      即「必须带环境门控」——不带门控的规则一律不准写在这里。
   2. 反过来：style.css（移动端网页版）、theme-green.css（青草绿主题）、pc.css 里不准出现 mp- 前缀类名。
   3. 加载顺序固定为 style.css → theme-green.css（仅青草绿主题下发） → mp.css → pc.css（本文件必须在移动版之后）。
   4. 是否进入小程序形态由 static/js/mp/mp-detect.js 判定：主通道是独立路径 /mp/（入口级隔离，
      网页版链接不会带出该路径）；过渡期兼容旧参数 ?mp=1，并叠加自洽性校验，
      防止「小程序里复制出来的链接在普通浏览器打开」也误入小程序形态。
   历史背景：本文件内容原先以 <style> 内联块的形式写在 templates/index.html 里，
   与页面通用规则混在同一处级联中，缺少物理边界，导致为小程序调出来的规则容易漏到网页版。
   ========================================================================== */

/* ===== 微信小程序内嵌沉浸式顶栏适配 =====
   仅在真全屏（html.mp-immersive，即原生导航栏已被隐藏）时生效：
   顶栏自身吸收状态栏高度，内容行正好落在胶囊那一行（与胶囊同高，堪称"顶替"原导航栏标题），
   右侧操作区左移让开胶囊。变量为 0 / 无该类时，全部样式不生效，页面与既有行为完全一致。 */
html.mp-immersive .header {
    padding-top: var(--mp-sb, 0px);
    padding-bottom: 0;
    min-height: calc(var(--mp-sb, 0px) + var(--mp-nav-h, 0px));
}
/* 首页浅底头部：小程序内改为主题色，与状态栏、胶囊融为一体 */
html.mp-immersive .home-header {
    background: var(--primary);
    align-items: center;
}
html.mp-immersive .home-header .hb-logo { background: rgba(255,255,255,.22); box-shadow: none; }
html.mp-immersive .home-header .hb-name { color: #fff; }
html.mp-immersive .home-header .bell-btn { color: #fff; }
html.mp-immersive .home-header .bell-badge,
html.mp-immersive .home-header .cs-msg-badge { border-color: var(--primary); }
/* 右侧操作区整体左移，避开右上角胶囊 */
html.mp-immersive .home-header .home-actions {
    padding-right: calc(var(--mp-capsule-w, 0px) + 0.8rem);
}
/* 青草绿主题主页顶栏同样避让状态栏 */
html.mp-immersive .grn-hero { padding-top: var(--mp-sb, 0px); }

/* ===== 小程序竖屏兜底：原生导航栏无法隐藏时 =====
   微信官方限制——web-view 竖屏下无法隐藏/自定义原生导航栏（iOS/Android 6.7.2 起
   navigationStyle:custom 对 web-view 无效，仅横屏 + 基础库 3.2.4+ 支持）。
   此时首页标题交由原生蓝底标题栏承担（其文案同步自 H5 的 document.title），
   故隐藏 H5 里重复的 logo+标题行，只把聊天/通知按钮并入搜索栏同一行右侧，
   既不出现两条标题，也不与右上角胶囊冲突。 */
html.mp-h5:not(.mp-immersive) .home-header { display: none; }

/* 青草绿主题：原生标题栏已经显示系统名（安佑陪护），页内再放一条同名品牌行就是「两条标题对冲」。
   这里藏掉页内品牌名，把口号「严选护工 · 平台保障 就在襄阳」接管品牌行的位置。
   口号定位是「小号备注型」宣传语：字号、透明度都保持原值，仅加粗，不做标题化放大。 */
html.mp-h5:not(.mp-immersive) .grn-brand b { display: none; }
html.mp-h5:not(.mp-immersive) .grn-brand span {
    font-size: calc(1.1rem * var(--fs));
    font-weight: 800;
}

/* 底部导航：小程序内全局硬锁死在视口底部。
   键盘避让抬升方案（--kb-h）在安卓 WebView 里不可靠——收起键盘时往往不派发 resize、
   输入框也不失焦，无法复位，底栏就被永久顶起悬空在页面中间。
   这里用 !important 彻底掐断 transform 的纵向位移，任何情况下都钉在底部；
   键盘弹出时最多被键盘遮住（可接受），绝不再悬空。 */
html.mp-h5 .tab-bar {
    bottom: 0 !important;
    top: auto !important;
    transform: translateX(-50%) !important;
}
html.mp-h5 .mp-home-search-row {
    display: flex; align-items: center; gap: 0.8rem;
    margin: 2.4rem 1.6rem 1.2rem; /* 与原生标题栏拉开呼吸间距，避免贴着标题 */
}
html.mp-h5 .mp-home-search-row .home-search { flex: 1 1 auto; min-width: 0; margin: 0; }
html.mp-h5 .mp-home-search-row .home-actions { flex-shrink: 0; }
html.mp-h5 .mp-home-search-row .bell-btn { color: var(--text); margin-left: 0; margin-right: 0; }
html.mp-h5 .mp-home-search-row .bell-badge,
html.mp-h5 .mp-home-search-row .cs-msg-badge { border-color: var(--card-bg); }

/* ===== 小程序内嵌：子页面首行 = 与首页同款（无背景工具条） =====
   页面标题已由小程序原生标题栏承担（app.js syncMpNavTitle 同步 document.title）。
   首行不再另铺白色工具条，直接落在页面的原始底色（--bg）上，与首页首行完全一致：
     左「返回（详情页）/ 白色圆角搜索胶囊（列表页）」 + 右「消息 / 通知」。
   既无突兀的白底色块，也不显拥挤。 */
html.mp-h5:not(.mp-immersive) .header {
    background: var(--bg);
    color: var(--text);
    padding: 1.6rem 1.6rem 1rem;
    min-height: 0;
    justify-content: flex-start;
    gap: 0.8rem;
    border-bottom: none;
    box-shadow: none;
}
/* 标题与占位用的 3.2rem 空格子一并隐去（标题已在原生栏，占位不再需要） */
html.mp-h5:not(.mp-immersive) .header h1,
html.mp-h5:not(.mp-immersive) .header > div[style*="width:3.2rem"] { display: none; }
/* 返回键：透明无底，仅留箭头；根页面（底部导航页）由 JS 加 .mp-no-back 整体隐藏 */
html.mp-h5:not(.mp-immersive) .header .back-btn {
    margin-right: auto;
    width: 3.4rem; height: 3.4rem; flex-shrink: 0;
    background: transparent; border: none; color: var(--text);
    font-size: calc(2.2rem * var(--fs));
}
html.mp-h5:not(.mp-immersive) .header.mp-no-back .back-btn { display: none; }
/* 消息 / 通知：透明图标，贴在首行最右 */
html.mp-h5:not(.mp-immersive) .header .bell-btn {
    width: 3.4rem; height: 3.4rem; margin-left: 0;
    border-radius: 50%; background: transparent; border: none;
    color: var(--text); font-size: calc(1.7rem * var(--fs));
}
html.mp-h5:not(.mp-immersive) .header .bell-badge,
html.mp-h5:not(.mp-immersive) .header .cs-msg-badge { border-color: var(--bg); }
html.mp-h5:not(.mp-immersive) .header .right-btn { color: var(--primary); font-weight: 600; flex-shrink: 0; white-space: nowrap; }
/* 首个右侧动作元素左推，保证「返回 + 动作」详情页里动作贴右 */
html.mp-h5:not(.mp-immersive) .header .mp-actions-first { margin-left: auto; }
/* 列表页搜索：并入首行，塑成首页同款白色圆角胶囊（.search-bar / .lt-search 两种来源统一） */
html.mp-h5:not(.mp-immersive) .header > .search-bar,
html.mp-h5:not(.mp-immersive) .header > .lt-search {
    position: static; top: auto; z-index: auto;
    flex: 1 1 auto; min-width: 0; height: 4.2rem;
    display: flex; align-items: center; gap: 0.8rem;
    margin: 0; padding: 0 1.4rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 99.9rem;
    box-shadow: 0 2px 1rem rgba(var(--primary-rgb),.07);
}
html.mp-h5:not(.mp-immersive) .header > .search-bar input,
html.mp-h5:not(.mp-immersive) .header > .lt-search input {
    flex: 1; min-width: 0; height: 100%;
    margin: 0; padding: 0; border: none; outline: none; background: transparent;
    font-size: calc(1.35rem * var(--fs)); color: var(--text);
}
html.mp-h5:not(.mp-immersive) .header > .lt-search i {
    color: var(--text-light); font-size: calc(1.4rem * var(--fs)); flex-shrink: 0;
}
/* 搜索已上移至首行后，工具条只余排序 → 透明右对齐，融进页面底色 */
html.mp-h5:not(.mp-immersive) .list-toolbar {
    justify-content: flex-end;
    padding: 0.6rem 1.6rem 0.8rem;
    background: transparent;
    border-bottom: none;
}
/* 个人中心：消息 / 通知移入首个个人信息卡片右上角 */
html.mp-h5 .mp-card-actions {
    margin-left: auto; align-self: flex-start;
    display: flex; align-items: center; gap: 0.4rem;
}
html.mp-h5 .mp-card-actions .bell-btn { margin-left: 0; color: var(--text); }

/* ===== 反向例外：网页版（非小程序）专属 =====
   这两条原先是写在 style.css 里的 html:not(.mp-h5) 「反向补丁」——
   症状而非解法：说明正向覆盖没兜住，只好给网页版单独补一刀。
   现集中迁入本文件（环境差异只此一处），视觉行为与迁移前完全一致；
   后续若收敛成正向规则可移除。 */
html:not(.mp-h5) #page-notifications .header > .right-btn,
html:not(.mp-h5) #page-notifications .header > .cs-msg-entry { margin-left: 0.6rem; }
html:not(.mp-h5) #page-notifications #ntf-manage-btn.active { background: rgba(255,255,255,.25); }