/* ==================== 企微风格 · 全局 ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body, #app { height: 100%; overflow: hidden; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: #191919;
    background: #f2f2f2;
}
#app { display: flex; }
a { color: #576b95; text-decoration: none; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #d6d6d6; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b8b8b8; }

/* ==================== 左侧栏 ==================== */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #2e2e2e;
    color: #d5d5d5;
    display: flex;
    flex-direction: column;
}
.sidebar-header { padding: 12px 12px 8px; }
.search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #3d3d3d;
    border-radius: 4px;
    padding: 6px 10px;
    color: #9a9a9a;
}
.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: #eee;
    font-size: 13px;
}
.search-box input::placeholder { color: #8b8b8b; }
.search-clear { cursor: pointer; color: #9a9a9a; font-size: 16px; padding: 0 2px; }

/* 企微切换下拉框 */
.corp-select-wrap { margin-top: 8px; }
.corp-select {
    width: 100%;
    padding: 6px 8px;
    border: none;
    outline: none;
    border-radius: 4px;
    background: #3d3d3d;
    color: #e2e2e2;
    font-size: 13px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%239a9a9a' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 26px;
}
.corp-select:hover { background-color: #474747; }
.corp-select option { background: #2e2e2e; color: #e2e2e2; }

.room-list, .search-results { flex: 1; overflow-y: auto; }

.room-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
}
.room-item:hover { background: #3a3a3a; }
.room-item.active { background: #4b4b4b; }
.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}
.room-info { flex: 1; min-width: 0; }
.room-row1 { display: flex; justify-content: space-between; align-items: center; }
.room-name {
    font-size: 14px;
    color: #e8e8e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.room-time { font-size: 11px; color: #8b8b8b; }
.room-row2 { display: flex; justify-content: space-between; gap: 8px; margin-top: 3px; }
.room-preview {
    font-size: 12px;
    color: #8b8b8b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.room-count { font-size: 11px; color: #6f6f6f; min-width: 28px; text-align: right; }

/* 搜索结果 */
.result-section-title {
    padding: 10px 12px 4px;
    font-size: 12px;
    color: #8b8b8b;
}
.result-item { padding: 9px 12px; cursor: pointer; }
.result-item:hover { background: #3a3a3a; }
.result-item .r1 {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #c9c9c9;
}
.result-item .r1 .sender { color: #7cb2e8; }
.result-item .r2 {
    margin-top: 3px;
    font-size: 12px;
    color: #8b8b8b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.result-item mark { background: #c9a016; color: #fff; padding: 0 1px; border-radius: 2px; }
.result-empty { padding: 24px 12px; text-align: center; font-size: 12px; color: #777; }

/* ==================== 中间聊天面板 ==================== */
.chat-panel { flex: 1; display: flex; background: #f5f5f5; min-width: 0; }
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #999;
}
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-header {
    height: 54px;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: #f7f7f7;
    border-bottom: 1px solid #e3e3e3;
}
.chat-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-room-type {
    font-size: 11px;
    color: #8f8f8f;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    padding: 1px 5px;
    flex-shrink: 0;
}
.chat-sub { font-size: 12px; color: #999; }

/* ==================== 当前会话内搜索 ==================== */
.chat-header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.room-search {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #ececec;
    border-radius: 14px;
    padding: 4px 10px;
}
.room-search-btn {
    border: none;
    outline: none;
    background: transparent;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    color: #8b8b8b;
    cursor: pointer;
    flex-shrink: 0;
    font: inherit;
    line-height: 1;
}
/* SVG 不参与命中测试，点击统一落在 button 上，避免内核差异导致点不到 */
.room-search-btn svg { pointer-events: none; display: block; }
.room-search-btn:hover, .room-search-btn:focus { color: #576b95; }
.room-search-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 12px;
    width: 140px;
    color: #444;
}
.room-search-input::placeholder { color: #aaa; }
.room-search-clear { cursor: pointer; color: #999; font-size: 15px; line-height: 1; }

.room-search-results {
    position: absolute;
    top: 56px;
    right: 18px;
    width: 380px;
    max-height: 65%;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e3e3e3;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
    z-index: 30;
}
.room-search-results .rs-title {
    padding: 8px 12px;
    font-size: 12px;
    color: #888;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}
.rs-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f5f5f5; }
.rs-item:last-child { border-bottom: none; }
.rs-item:hover { background: #f3f6fa; }
.rs-item .rs-r1 { display: flex; justify-content: space-between; font-size: 12px; color: #666; }
.rs-item .rs-r1 .rs-sender { color: #576b95; }
.rs-item .rs-r2 {
    margin-top: 3px;
    font-size: 12px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rs-item mark { background: #ffe08a; color: #a06000; padding: 0 1px; border-radius: 2px; }
.rs-empty { padding: 22px 12px; text-align: center; font-size: 12px; color: #999; }

.msg-area { flex: 1; overflow-y: auto; padding: 14px 24px 20px; }
.load-older { text-align: center; padding: 4px 0 10px; }
.load-older span {
    font-size: 12px;
    color: #576b95;
    cursor: pointer;
    padding: 4px 14px;
    border-radius: 3px;
}
.load-older span:hover { background: #e8e8e8; }
.loading-tip { text-align: center; font-size: 12px; color: #aaa; padding: 6px 0; }

/* 时间分割线 */
.time-divider { text-align: center; margin: 12px 0; }
.time-divider span {
    font-size: 12px;
    color: #9a9a9a;
    background: #e2e2e2;
    border-radius: 3px;
    padding: 2px 8px;
}

/* 消息行 */
.msg-row { display: flex; margin: 10px 0; gap: 10px; align-items: flex-start; }
.msg-row.right { flex-direction: row-reverse; }
.msg-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: default;
}
.msg-body { max-width: 62%; display: flex; flex-direction: column; }
.msg-row.right .msg-body { align-items: flex-end; }
.msg-sender {
    font-size: 12px;
    color: #9a9a9a;
    margin-bottom: 4px;
    padding: 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}
.msg-bubble {
    position: relative;
    background: #fff;
    border-radius: 6px;
    padding: 9px 12px;
    line-height: 1.5;
    word-break: break-all;
    box-shadow: 0 1px 1px rgba(0,0,0,0.03);
}
.msg-row.right .msg-bubble { background: #95ec69; }
.msg-row.highlight .msg-bubble { background: #fff3b8; transition: background .8s; }
.msg-row.right.highlight .msg-bubble { background: #e0f7a3; }

/* 系统消息（撤回等） */
.msg-system { text-align: center; margin: 12px 0; }
.msg-system span {
    font-size: 12px;
    color: #a3a3a3;
    background: #e5e5e5;
    border-radius: 3px;
    padding: 2px 10px;
}

/* 媒体消息 */
.media-thumb {
    max-width: 240px;
    max-height: 240px;
    border-radius: 4px;
    cursor: zoom-in;
    display: block;
    background: #eee;
    min-height: 40px;
    min-width: 60px;
}
.emotion-thumb { max-width: 120px; max-height: 120px; cursor: zoom-in; display: block; }
.media-placeholder {
    font-size: 12px;
    color: #b0b0b0;
    padding: 6px 4px;
    max-width: 200px;
}
video.msg-video {
    max-width: 300px;
    max-height: 220px;
    border-radius: 4px;
    display: block;
    background: #000;
}

/* 语音气泡 */
.voice-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    min-width: 96px;
    user-select: none;
}
.voice-bubble.playing .voice-wave span { animation: voiceAnim .6s infinite ease-in-out; }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 16px; }
.voice-wave span {
    width: 2.5px;
    border-radius: 2px;
    background: #5c5c5c;
}
.msg-row.right .voice-wave span { background: #18420f; }
.voice-wave span:nth-child(1) { height: 5px; }
.voice-wave span:nth-child(2) { height: 10px; }
.voice-wave span:nth-child(3) { height: 16px; }
.voice-wave span:nth-child(4) { height: 8px; }
@keyframes voiceAnim {
    0%, 100% { transform: scaleY(.5); }
    50% { transform: scaleY(1); }
}
.voice-dur { font-size: 13px; }

/* 文件卡片 */
.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 250px;
    cursor: pointer;
}
.file-card:hover .file-name { text-decoration: underline; }
.file-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 6px;
    background: #4a89e8;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.file-meta { flex: 1; min-width: 0; }
.file-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-size { font-size: 12px; color: #999; margin-top: 3px; }

/* 链接卡片 */
.link-card {
    width: 250px;
    border: 1px solid #ececec;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    cursor: pointer;
    display: block;
}
.msg-row.right .link-card { background: #a5ee7c; }
.link-title {
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.link-desc {
    padding: 0 10px;
    font-size: 12px;
    color: #999;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.link-img { width: 100%; max-height: 130px; object-fit: cover; display: block; }
.msg-row.right .link-desc, .msg-row.right .link-card a { color: #3f5a1e; }

/* mixed 组合消息 */
.mixed-item { margin: 4px 0; }
.mixed-item .m-text { line-height: 1.5; }

/* chatrecord 会话记录 */
.chatrecord { width: 260px; }
.chatrecord-title { font-size: 12px; color: #999; margin-bottom: 6px; }
.chatrecord-item {
    padding: 6px 0;
    border-top: 1px solid #f0f0f0;
    font-size: 13px;
    line-height: 1.45;
}
.msg-row.right .chatrecord-item { border-color: #d8f2c0; }
.chatrecord-item .cr-sender { color: #576b95; margin-right: 6px; }
.chatrecord-item .cr-text { white-space: pre-wrap; }

/* 兜底类型卡片 */
.raw-card {
    max-width: 280px;
    max-height: 160px;
    overflow: hidden;
    white-space: pre-wrap;
    font-size: 12px;
    color: #888;
    border: 1px dashed #d8d8d8;
    border-radius: 6px;
    padding: 8px 10px;
    background: #fafafa;
}
.msg-row.right .raw-card { background: #e9f9d4; border-color: #cfe8b6; color: #4a6b2c; }

/* ==================== 右侧群成员 ==================== */
.member-panel {
    width: 230px;
    min-width: 230px;
    background: #f7f7f7;
    border-left: 1px solid #e3e3e3;
    display: flex;
    flex-direction: column;
}
.member-header { padding: 14px 16px 10px; font-size: 13px; color: #666; font-weight: 600; }
.member-list { flex: 1; overflow-y: auto; padding: 0 10px 14px; }
.member-group-title { font-size: 11px; color: #aaa; margin: 12px 4px 6px; }
.member-item { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 4px; }
.member-item:hover { background: #ececec; }
.member-item .avatar { width: 30px; height: 30px; min-width: 30px; font-size: 12px; border-radius: 4px; }
.member-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.member-item.offline .member-name { color: #bbb; }
.member-tag {
    font-size: 10px;
    color: #fff;
    background: #c0c4cc;
    border-radius: 3px;
    padding: 1px 4px;
    flex-shrink: 0;
}

/* ==================== 图片放大层 ==================== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .78);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.lightbox img {
    max-width: 92vw;
    max-height: 88vh;
    border-radius: 4px;
    box-shadow: 0 4px 30px rgba(0,0,0,.5);
}
.lightbox-hint {
    position: fixed;
    bottom: 22px;
    left: 0;
    right: 0;
    text-align: center;
    color: #ddd;
    font-size: 12px;
}

/* 消息定位遮罩 */
.locating {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.72);
    color: #fff;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 1200;
}

/* ==================== 群成员详情弹窗 ==================== */
.member-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.member-card {
    width: 320px;
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .22);
}
.member-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}
.member-card-head .avatar { width: 46px; height: 46px; min-width: 46px; font-size: 18px; border-radius: 8px; }
.member-card-name { font-size: 16px; font-weight: 600; }
.member-card-sub { font-size: 12px; color: #999; margin-top: 3px; }
.member-card-rows { padding-top: 6px; }
.member-card-row {
    display: flex;
    padding: 7px 0;
    font-size: 13px;
    line-height: 1.45;
    border-bottom: 1px dashed #f5f5f5;
}
.member-card-row:last-child { border-bottom: none; }
.member-card-row .k {
    width: 72px;
    min-width: 72px;
    color: #999;
}
.member-card-row .v {
    flex: 1;
    min-width: 0;
    color: #333;
    word-break: break-all;
}
