/* ============================================================
 * 私信管理组件样式（独立组件，前缀 pm-）
 * 主色：#1677ff ｜ 页面底：#f5f7fa ｜ 文本：#1f2329 / #646a73 / #8f959e
 * ============================================================ */

.pm-panel {
    display: flex;
    height: 100%;
    min-height: 460px;
    background: #f5f7fa;
    border-radius: 8px;
    overflow: hidden;
    font-size: 13px;
    color: #1f2329;
    box-shadow: 0 1px 6px rgba(31, 35, 41, 0.06);
}

/* ---------------- 左侧：会话列表 ---------------- */
.pm-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #eef0f4;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pm-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 12px;
    flex-shrink: 0;
}

.pm-source-select {
    flex-shrink: 0;
    height: 36px;
    min-width: 60px;
    padding: 0 16px 0 8px;
    border: 1px solid #e5e6eb;
    border-radius: 6px;
    background: #f7f8fa;
    color: #646a73;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
    appearance: auto;
    transition: border-color .2s, color .2s;
}

.pm-source-select:hover {
    border-color: #1677ff;
    color: #1677ff;
}

.pm-search-icon {
    position: absolute;
    left: 27px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.pm-search-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    background: #f7f8fa;
    font-size: 13px;
    color: #1f2329;
    outline: none;
    box-sizing: border-box;
    transition: border-color .2s, background .2s, box-shadow .2s;
}

.pm-search-input:focus {
    border-color: #1677ff;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.pm-search-input::placeholder {
    color: #a3a9b3;
}

/* 标签栏 */
.pm-filter {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 14px 12px;
    border-bottom: 1px solid #f0f1f4;
    flex-shrink: 0;
}

.pm-filter-item {
    flex: 1;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 12px;
    color: #646a73;
    border-radius: 6px;
    cursor: pointer;
    transition: background .2s, color .2s;
    user-select: none;
}

.pm-filter-item:hover {
    background: #f5f7fa;
    color: #1f2329;
}

.pm-filter-item.is-active {
    background: rgba(22, 119, 255, 0.08);
    color: #1677ff;
    font-weight: 600;
}

.pm-filter-count {
    font-style: normal;
    font-size: 11px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    background: #f0f1f4;
    color: #8f959e;
    padding: 0 4px;
    box-sizing: border-box;
}

.pm-filter-item.is-active .pm-filter-count {
    background: rgba(22, 119, 255, 0.14);
    color: #1677ff;
}

/* 「未读」计数：红色气泡样式 */
.pm-filter-count[data-count="unread"],
.pm-filter-item.is-active .pm-filter-count[data-count="unread"] {
    background: #f5222d;
    color: #fff;
    border-radius: 8px;
}

/* 会话列表 */
.pm-conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 8px 16px;
}

.pm-conv-list::-webkit-scrollbar,
.pm-chat::-webkit-scrollbar,
.pm-attach::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.pm-conv-list::-webkit-scrollbar-thumb,
.pm-chat::-webkit-scrollbar-thumb,
.pm-attach::-webkit-scrollbar-thumb {
    background: #e2e5ea;
    border-radius: 3px;
}

.pm-conv-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 10px;
    margin-bottom: 2px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .18s;
}

.pm-conv-item:hover {
    background: #f5f7fa;
}

.pm-conv-item.is-active {
    background: rgba(22, 119, 255, 0.08);
}

.pm-conv-avatar {
    position: relative;
    flex-shrink: 0;
    margin-right: 12px;
}

/* 平台标识角标（头像右下角） */
.pm-platform-badge {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 15px;
    height: 15px;
    padding: 1px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 1px #fff, 0 1px 3px rgba(31, 35, 41, 0.18);
    box-sizing: content-box;
    z-index: 2;
}

.pm-platform-badge img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}

.pm-dot {
    position: absolute;
    right: -4px;
    top: -4px;
    min-width: 17px;
    height: 17px;
    line-height: 17px;
    text-align: center;
    font-style: normal;
    font-size: 10px;
    color: #fff;
    background: #f5222d;
    border-radius: 9px;
    padding: 0 4px;
    box-sizing: border-box;
    box-shadow: 0 0 0 2px #fff;
}

/* 会话行右侧未读数：垂直居中、更小巧 */
.pm-conv-right {
    flex-shrink: 0;
    margin-left: 8px;
    display: flex;
    align-items: center;
    align-self: center;
}
.pm-conv-right .pm-dot {
    position: static;
    min-width: 15px;
    height: 15px;
    line-height: 15px;
    font-size: 9px;
    border-radius: 8px;
    box-shadow: none;
}

.pm-avatar {
    display: inline-block;
    width: 38px;
    height: 38px;
    line-height: 38px;
    text-align: center;
    border-radius: 50%;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    flex-shrink: 0;
    overflow: hidden;
}

/* 会话/联络人头像图：有 head_img_url 时显示图片，铺满圆形容器 */
.pm-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
    background: #fff;
}

.pm-conv-body {
    flex: 1;
    min-width: 0;
}

.pm-conv-top {
    display: flex;
    align-items: center;
}

.pm-conv-name {
    font-size: 13px;
    color: #8f959e;
    font-weight: 400;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pm-conv-time {
    font-size: 11px;
    color: #a3a9b3;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 6px;
}

/* 性别标识 */
.pm-sex {
    display: inline-block;
    flex-shrink: 0;
    margin-left: 6px;
    width: 16px;
    line-height: 16px;
    font-size: 12px;
    text-align: center;
    font-style: normal;
    border-radius: 8px;
    vertical-align: 1px;
}

/* 私信列表：性别标识放在昵称左边 */
.pm-conv-top .pm-sex {
    margin-left: 0;
    margin-right: 6px;
}

.pm-sex-male {
    color: #1677ff;
    background: rgba(22, 119, 255, 0.12);
}

.pm-sex-female {
    color: #ff5c8a;
    background: rgba(255, 92, 138, 0.12);
}

.pm-head-name .pm-sex {
    margin-left: 8px;
    width: 18px;
    line-height: 18px;
    border-radius: 9px;
    vertical-align: 2px;
}

.pm-conv-meta {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: #8f959e;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 电脑端/后台消息标识 */
.pm-source-computer {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 2px;
}

.pm-platform-icon {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    flex-shrink: 0;
}

.pm-conv-preview {
    font-size: 13px;
    color: #1f2329;
    font-weight: 600;
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pm-conv-item.is-active .pm-conv-preview {
    color: #4b7fd6;
}

.pm-list-empty {
    padding: 60px 0;
    text-align: center;
    color: #a3a9b3;
    font-size: 13px;
}

.pm-list-empty-icon {
    display: block;
    margin-bottom: 10px;
}

/* 会话列表触底加载提示 */
.pm-list-more {
    padding: 10px 0;
    text-align: center;
    color: #a3a9b3;
    font-size: 12px;
}

/* 置顶分组（可折叠） */
.pm-pin-group {
    margin-bottom: 6px;
}

.pm-pin-head {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 12px;
    color: #8f959e;
    cursor: pointer;
    user-select: none;
    transition: background .2s;
}

.pm-pin-head:hover {
    background: #f5f7fa;
}

.pm-pin-arrow {
    display: inline-flex;
    font-size: 10px;
    color: #b4bac4;
    transition: transform .2s;
}

.pm-pin-group.is-collapsed .pm-pin-arrow {
    transform: rotate(-90deg);
}

.pm-pin-label {
    font-weight: 600;
    color: #646a73;
}

.pm-pin-count,
.pm-pin-unread {
    font-style: normal;
    font-size: 11px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
    box-sizing: border-box;
}

.pm-pin-count {
    background: #f0f1f4;
    color: #8f959e;
}

.pm-pin-unread {
    background: #f5222d;
    color: #fff;
    margin-left: auto;
}

/* 会话行置顶角标 */
.pm-pin-badge {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 4px;
    color: #1677ff;
}

/* 会话右键菜单 */
.pm-menu {
    position: fixed;
    z-index: 9999;
    min-width: 120px;
    padding: 4px;
    background: #fff;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(31, 35, 41, 0.14);
}

.pm-menu-item {
    height: 32px;
    line-height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 13px;
    color: #1f2329;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.pm-menu-item:hover {
    background: rgba(22, 119, 255, 0.08);
    color: #1677ff;
}

/* ---------------- 右侧：聊天主区域 ---------------- */
.pm-main {
    flex: 1;
    min-width: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 顶部 */
.pm-main-head {
    height: 62px;
    flex-shrink: 0;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eef0f4;
    background: #fff;
}

.pm-head-empty {
    color: #a3a9b3;
    font-size: 13px;
}

.pm-head-user {
    display: flex;
    align-items: center;
    min-width: 0;
}

.pm-head-avatar {
    margin-right: 10px;
}

.pm-head-info {
    min-width: 0;
}

.pm-head-name {
    font-size: 15px;
    font-weight: 600;
    color: #1f2329;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pm-head-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    border-radius: 6px;
    color: #1677ff;
    background: rgba(22, 119, 255, 0.08);
    text-decoration: none;
    transition: background .2s;
}

.pm-head-link:hover {
    background: rgba(22, 119, 255, 0.16);
}

.pm-head-meta {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    color: #8f959e;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pm-history-btn {
    flex-shrink: 0;
    height: 30px;
    padding: 0 14px;
    border: 1px solid #d9dce1;
    border-radius: 6px;
    background: #fff;
    color: #1f2329;
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
}

.pm-history-btn:hover {
    border-color: #1677ff;
    color: #1677ff;
    background: rgba(22, 119, 255, 0.04);
}

/* 聊天窗口 */
.pm-chat {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
    background: #f7f8fa;
    box-sizing: border-box;
}

.pm-empty {
    padding: 120px 0;
    text-align: center;
    color: #b4bac4;
    font-size: 14px;
}

/* 日期分隔 */
.pm-msg-date {
    text-align: center;
    margin: 8px 0 16px;
}

.pm-msg-date span {
    display: inline-block;
    padding: 2px 10px;
    background: #e9ebef;
    border-radius: 10px;
    color: #8f959e;
    font-size: 11px;
}

/* 消息气泡 */
.pm-msg {
    display: flex;
    align-items: flex-start;
    margin-bottom: 16px;
    animation: pmFadeIn .25s ease;
}

.pm-msg-out {
    /* DOM 顺序为 头像->内容，row-reverse 布局下头像位于最右侧，内容靠右对齐 */
    flex-direction: row-reverse;
}

@keyframes pmFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pm-msg-avatar {
    margin: 0 10px;
    flex-shrink: 0;
}

.pm-msg-avatar img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
}

.pm-msg-content {
    max-width: 66%;
    min-width: 0;
}

.pm-msg-out .pm-msg-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* 消息昵称（上昵称下内容，侧边头像布局） */
.pm-msg-name {
    font-size: 12px;
    color: #8f959e;
    line-height: 1.4;
    margin-bottom: 4px;
    padding: 0 2px;
    word-break: break-all;
}

.pm-msg-out .pm-msg-name {
    text-align: right;
}

/* 后台/任务主动发送消息的小标签 */
.pm-tag-send {
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
    font-size: 10px;
    line-height: 1;
    color: #ff7d47;
    background: #fff2ea;
    border: 1px solid #ffc7a8;
    border-radius: 3px;
    padding: 2px 4px;
    transform: translateY(-1px);
}

.pm-msg-bubble {
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(31, 35, 41, 0.05);
}

.pm-msg-in .pm-msg-bubble {
    background: #fff;
    border: 1px solid #eceef2;
    border-top-left-radius: 2px;
    color: #1f2329;
}

.pm-msg-out .pm-msg-bubble {
    background: #1677ff;
    color: #fff;
    border-top-right-radius: 2px;
}

.pm-msg-text {
    white-space: pre-wrap;
}

.pm-msg-imgs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.pm-msg-img {
    max-width: 180px;
    max-height: 160px;
    border-radius: 6px;
    cursor: zoom-in;
    display: block;
}

.pm-msg-time {
    font-size: 11px;
    color: #a3a9b3;
    margin-top: 4px;
}

.pm-msg-out .pm-msg-time {
    text-align: right;
}

/* 发送失败标识 */
.pm-msg-fail {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    color: #ff4d4f;
    font-size: 11px;
}

/* 时间已并入日期分组，失败标识独立展示在消息下方 */
.pm-msg-content > .pm-msg-fail {
    margin-left: 0;
    margin-top: 4px;
}

.pm-msg-fail::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff4d4f;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

/* 输入区 */
.pm-input {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #eef0f4;
    padding: 10px 14px 12px;
}

.pm-attach {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    max-height: 110px;
    overflow-y: auto;
}

.pm-attach-item {
    position: relative;
    width: 66px;
    height: 66px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e5e6eb;
    animation: pmFadeIn .2s ease;
}

.pm-attach-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pm-attach-item-close {
    position: absolute;
    right: 2px;
    top: 2px;
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
    border-radius: 50%;
    cursor: pointer;
}

.pm-input-area {
    width: 100%;
    min-height: 76px;
    max-height: 160px;
    border: 1px solid #d9dde3;
    outline: none;
    resize: none;
    font-size: 13px;
    line-height: 1.6;
    color: #1f2329;
    box-sizing: border-box;
    padding: 8px 10px;
    border-radius: 6px;
    background: #fff;
    transition: border-color .2s, box-shadow .2s;
    box-shadow: 0 0 8px rgba(22, 119, 255, 0.12);
}

.pm-input-area:focus {
    border-color: #1677ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1), 0 0 14px rgba(22, 119, 255, 0.25);
}

.pm-input-area:disabled {
    background: #fafafa;
    border-color: #e5e6eb;
    box-shadow: none;
}

.pm-input-area::placeholder {
    color: #b4bac4;
}

.pm-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.pm-img-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid #e5e6eb;
    border-radius: 6px;
    background: #fff;
    color: #5a6169;
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
}

.pm-img-btn:hover {
    border-color: #1677ff;
    color: #1677ff;
}

.pm-img-btn:hover svg {
    stroke: #1677ff;
}

.pm-input-tip {
    font-size: 11px;
    color: #b4bac4;
}

.pm-send-btn {
    margin-left: auto;
    height: 34px;
    padding: 0 18px;
    border: none;
    border-radius: 6px;
    background: #1677ff;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: background .2s;
}

.pm-send-btn:hover {
    background: #0f6ce8;
}

.pm-send-btn:disabled {
    background: #c8d9f5;
    cursor: not-allowed;
}

/* 历史消息弹窗 */
.pm-history {
    padding-top: 14px;
}

/* 历史消息筛选栏：搜索 + 时间范围 各占50%，查询按钮在行尾 */
.pm-history-filter {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f1f4;
}

.pm-history-search {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 50%;
    min-width: 0;
}

.pm-history-range {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 50%;
    min-width: 0;
}

.pm-history-searchbtn {
    flex-shrink: 0;
    flex: 0 0 auto;
}

.pm-history-search-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    pointer-events: none;
}

.pm-history-keyword {
    flex: 1;
    min-width: 0;
    height: 32px;
    padding: 0 10px;
    border: 1px solid #e5e6eb;
    border-radius: 6px;
    font-size: 13px;
    color: #1f2329;
    outline: none;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}

.pm-history-keyword:focus {
    border-color: #1677ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.pm-history-keyword::placeholder {
    color: #b4bac4;
}

.pm-history-date {
    flex: 1;
    min-width: 0;
    width: auto;
    height: 32px;
    padding: 0 6px;
    border: 1px solid #e5e6eb;
    border-radius: 6px;
    font-size: 12px;
    color: #1f2329;
    outline: none;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}

.pm-history-date:focus {
    border-color: #1677ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.pm-history-sep {
    flex-shrink: 0;
    font-size: 12px;
    color: #a3a9b3;
}

.pm-history-searchbtn {
    flex-shrink: 0;
    height: 32px;
    padding: 0 16px;
    border: none;
    border-radius: 6px;
    background: #1677ff;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: background .2s;
}

.pm-history-searchbtn:hover {
    background: #0f6ce8;
}

/* 历史消息列表容器（可滚动） */
.pm-history-list {
    max-height: 52vh;
    overflow-y: auto;
    padding-right: 4px;
}

.pm-history-list::-webkit-scrollbar {
    width: 6px;
}

.pm-history-list::-webkit-scrollbar-thumb {
    background: #e2e5ea;
    border-radius: 3px;
}

.pm-history-loading,
.pm-history-empty {
    padding: 40px 0;
    text-align: center;
    color: #a3a9b3;
    font-size: 13px;
}

.pm-history-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f7f8fa;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.pm-history-item.is-out {
    background: rgba(22, 119, 255, 0.06);
}

.pm-history-label {
    flex-shrink: 0;
    font-size: 11px;
    color: #1677ff;
    border: 1px solid rgba(22, 119, 255, 0.4);
    border-radius: 3px;
    padding: 0 5px;
    line-height: 16px;
    margin-top: 2px;
}

.pm-history-label.is-in {
    color: #8f959e;
    border-color: #d9dce1;
    background: #f2f3f5;
}

.pm-history-img img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.pm-history-content {
    flex: 1;
    word-break: break-word;
}

.pm-history-time {
    flex-shrink: 0;
    font-size: 11px;
    color: #a3a9b3;
    margin-top: 2px;
}

/* 历史消息发送失败标识 */
.pm-history-fail {
    flex-shrink: 0;
    margin-left: 8px;
    color: #ff4d4f;
    font-size: 11px;
}
