/* 消息页 PlainView 弹层样式（+按钮菜单 + 通讯录）——
 * 主机由 static/js/messages.js 创建，可在任何持有 messages.js 的页面触发。
 * CSS 必须全站加载：避免在非 /messages 页面打开弹层时丢样式。
 * 由 base.html <link> 引入。 */

/* ---------- +按钮弹的「我的好友」菜单（.msg-popover-*）----------
   全屏遮罩 + 浮动菜单卡片。菜单用 position: fixed，
   顶部坐标和 right 坐标由 JS 在打开时根据 + 按钮的 getBoundingClientRect()
   注入到 inline style；这里只负责卡片视觉与菜单项样式。
   菜单只活一轮：打开后用户的下一个动作（触摸/滑动/点按/滚轮，无论落在
   哪里）即关闭，由 messages.js 在 document 捕获阶段监听；落在菜单内的
   交互放行给菜单自身处理，视图切换时同步关闭。遮罩只负责挡住底层内容、
   消费首次点按。 */
.msg-popover-mask {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
}
.msg-popover {
    position: fixed;
    z-index: 101;
    /* top/right 由 JS 注入；这里给最小宽度与边距兜底 */
    min-width: 156px;
    margin-top: 8px;
    padding: 6px 0;
    background: rgba(40, 40, 40, 0.92);
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-tap-highlight-color: transparent;
    /* 入场：微淡入 + 轻微缩放，比 PlainView 的 shell-enter 更紧凑 */
    animation: msg-popover-in 0.12s ease-out;
}
@keyframes msg-popover-in {
    from { opacity: 0; transform: scale(0.96) translateY(-4px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.msg-popover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;        /* 触摸可达：与 mobile-shell 触摸基线一致 */
    padding: 0 14px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.92rem;
    line-height: 1;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}
.msg-popover-item:hover { background: rgba(255, 255, 255, 0.08); }
.msg-popover-item:active { background: rgba(255, 255, 255, 0.16); }
.msg-popover-item:focus-visible {
    outline: none;
    background: rgba(255, 255, 255, 0.12);
}
.msg-popover-icon {
    flex: none;
    width: 22px;
    text-align: center;
    font-size: 1rem;
    line-height: 1;
}
.msg-popover-label { flex: 1; }

/* ---------- 「我的好友」列表（PlainView 内，仿微信通讯录） ----------
   微信通讯录风格：顶部搜索 + 列表（按 username 首字母 A-Z 分组，# 兜底非字母）+
   右侧字母索引条（点字跳到对应分组）。PlainView 内容区是纵向 flex 容器；
   wrap 用横向 flex 把列表和索引条并排，列表 flex:1 占满，索引条 fixed 贴在右侧。 */
.msg-friend-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
    background: #f7fafc;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
/* 顶部搜索框：白底圆角，跟随 PlainView 顶栏风格 */
.msg-friend-search {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 14px 8px;
    padding: 0 12px;
    min-height: 40px;
    background: #edf2f7;
    border-radius: 10px;
    color: var(--text-3, #718096);
}
.msg-friend-search-icon {
    flex: none;
    font-size: 0.95rem;
    line-height: 1;
}
.msg-friend-search-input {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-1, #2d3748);
    font-size: 0.92rem;
    font-family: inherit;
    padding: 0;
}
.msg-friend-search-input::placeholder { color: var(--text-3, #718096); }
/* 点击不出蓝色聚焦框：同 msg-search-input，全局 input:focus-visible 特异性更高，
   上面的 outline: none 压不住，需显式覆盖 */
.msg-friend-search-input:focus,
.msg-friend-search-input:focus-visible { outline: none; }
/* 滚动列表：占满剩余高度，滚动交给 PlainView 的 .pv-scroll；
   这里把滚动禁用，让出滚动权给外层，避免双重滚动条。
   索引条绝对定位在内部右侧，不挤压列表宽度。 */
.msg-friend-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
}
/* 分组标题条：微信风格——浅灰底、小字、左对齐、字距稍宽；带 data-letter 供索引跳转 */
.msg-friend-group-head {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 4px 16px;
    background: #f5f6f8;
    color: var(--text-3, #718096);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 0.04em;
    border-top: 1px solid var(--border-soft, #edf2f7);
}
.msg-friend-group-head:first-child { border-top: none; }
.msg-friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 8px 16px;
    background: #fff;
    border: none;
    border-bottom: 1px solid var(--border-soft, #edf2f7);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}
.msg-friend-item:hover { background: #f7fafc; }
.msg-friend-item:active { background: #eef2f7; }
.msg-friend-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}
.msg-friend-avatar {
    flex: none;
    width: 40px;
    height: 40px;
}
.msg-friend-name {
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-1, #2d3748);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* 右侧字母索引条：fixed 在好友列表弹层视口右侧、垂直居中；节点归属于
   自己的 .pv-overlay，所在 stacking context 会随好友列表整体低于后开的子弹层。
   z-index 只负责高于好友列表内容，气泡更高一档。
   [hidden] 显式 display:none：本类有 display:flex，浏览器默认的 [hidden] {display:none}
   会被覆盖；搜索 / 加载失败时 JS 设 el.hidden=true 必须真的不可见。 */
.msg-friend-index {
    position: fixed;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4500;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 4px 2px;
    /* 半透明背景：让字在内容上浮起时仍可读，但又不完全遮挡 */
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: none;
}
.msg-friend-index[hidden] { display: none; }
.msg-friend-index-letter {
    flex: none;
    width: 18px;
    height: 16px;
    /* 覆盖 mobile-shell.css 全局 button 基线 min-height: 44px，否则每个字母
       按钮会被撑到 44px 高，整条索引条会超出视口 */
    min-height: auto;
    border: none;
    background: transparent;
    color: var(--text-3, #718096);
    font-size: 0.66rem;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}
.msg-friend-index-letter.active {
    color: var(--primary);
    font-weight: 700;
}
/* 索引悬停/按住时的中央提示气泡 */
.msg-friend-index-tip {
    position: fixed;
    z-index: 4501;
    /* 居中定位由 JS 计算并写入 inline style */
    width: 56px;
    height: 56px;
    margin-left: -28px;
    margin-top: -28px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 600;
    pointer-events: none;
}
.msg-friend-index-tip[hidden] { display: none; }
/* 空状态 / 加载 / 错误：与 .msg-empty 同款风格 */
.msg-friend-status {
    text-align: center;
    color: var(--text-muted, #a0aec0);
    padding: 40px 24px;
    font-size: 0.88rem;
}
.msg-friend-status .emoji { font-size: 2rem; display: block; margin-bottom: 8px; opacity: 0.5; }