/* ============ 用户端聊天页 ============ */

html, body.user-body {
    height: 100%;
    overflow: hidden;
}

.chat-app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--mk-panel);
}

/* ---------- 顶部标题栏 ---------- */
.chat-head {
    flex: 0 0 auto;
    height: 48px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--mk-border);
    background: #fff;
}

.chat-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.chat-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--mk-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    font-size: 12px;
    color: var(--mk-text-light);
    white-space: nowrap;
}

.chat-status.online { color: var(--mk-success); }
.chat-status.offline { color: var(--mk-warning); }
.chat-status.conn { color: var(--mk-warning); }

.chat-head-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.head-btn {
    height: 30px;
    padding: 0 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--mk-primary);
    font-size: 13px;
    transition: background .15s;
}

.head-btn:hover { background: var(--mk-primary-light); }

.head-icon {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--mk-text-sub);
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.head-icon:hover { background: #f2f4f8; }

/* ---------- 主体 ---------- */
.chat-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}

.chat-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.chat-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 14px;
}

/* ---------- 欢迎 + 常见问题 ---------- */
.welcome {
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--mk-primary-light);
    color: #23527c;
    font-size: 13px;
    line-height: 1.7;
}

.faq-list {
    border: 1px solid var(--mk-border);
    border-radius: 8px;
    overflow: hidden;
}

.faq-item { border-bottom: 1px solid var(--mk-border); }
.faq-item:last-child { border-bottom: none; }

.faq-q {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 14px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
    line-height: 1.5;
}

.faq-q:hover { background: #fafbfe; }

.faq-arrow {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    position: relative;
    transition: transform .2s;
}

.faq-arrow::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 3px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--mk-text-sub);
    border-bottom: 1.5px solid var(--mk-text-sub);
    transform: rotate(45deg);
}

.faq-item.open .faq-arrow { transform: rotate(180deg); }

.faq-a {
    display: none;
    padding: 0 14px 14px;
    background: #fff;
    color: var(--mk-text-sub);
    font-size: 13px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.faq-item.open .faq-a { display: block; }

.faq-more {
    margin-top: 10px;
    font-size: 13px;
}

.faq-more a { cursor: pointer; }

/* ---------- 消息列表 ---------- */
.msg-list { padding: 2px; }

.msg-row {
    display: flex;
    margin-bottom: 14px;
    align-items: flex-start;
}

.msg-row.me { flex-direction: row-reverse; }

.msg-avatar {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e8eefb;
    overflow: hidden;
    margin: 0 8px;
}

.msg-avatar img { width: 100%; height: 100%; display: block; }

.msg-main { max-width: calc(100% - 90px); }

.msg-time {
    font-size: 11px;
    color: var(--mk-text-light);
    margin-bottom: 4px;
    text-align: left;
}

.msg-row.me .msg-time { text-align: right; }

.msg-bubble {
    display: inline-block;
    padding: 9px 12px;
    border-radius: 10px;
    background: #f4f5f8;
    color: var(--mk-text);
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
    text-align: left;
}

.msg-row.me .msg-bubble {
    background: var(--mk-primary);
    color: #fff;
}

.msg-bubble a { color: inherit; text-decoration: underline; }

.msg-row.me .msg-bubble a { color: #fff; }

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

.msg-file {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.msg-file .fi {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.msg-row.me .msg-file .fi { background: rgba(255, 255, 255, .22); }

.msg-sys {
    text-align: center;
    margin: 16px 0;
}

.msg-sys span {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 10px;
    background: #f2f4f8;
    color: var(--mk-text-light);
    font-size: 12px;
    line-height: 1.6;
}

.typing-tip {
    padding: 4px 8px 10px 48px;
    font-size: 12px;
    color: var(--mk-text-light);
}

/* ---------- 快捷链接 ---------- */
.quick-links {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 26px;
    padding: 8px 16px;
    border-top: 1px solid var(--mk-border);
    background: #fff;
}

.quick-links a {
    font-size: 13px;
    color: var(--mk-primary);
    cursor: pointer;
    white-space: nowrap;
}

.quick-links:empty { display: none; }

/* ---------- 输入区 ---------- */
.chat-input {
    flex: 0 0 auto;
    border-top: 1px solid var(--mk-border);
    padding: 10px 14px 12px;
    background: #fff;
    position: relative;
}

#inputBox {
    width: 100%;
    height: 56px;
    max-height: 110px;
    padding: 8px 2px;
    border: none;
    resize: none;
    font-size: 14px;
    line-height: 1.6;
    background: transparent;
}

#inputBox::placeholder { color: var(--mk-text-light); }

.input-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.input-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mk-text-sub);
    transition: background .15s;
}

.icon-btn:hover { background: #f2f4f8; }

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #dfe3ea;
    color: #fff;
    font-size: 17px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

.send-btn.active {
    background: linear-gradient(135deg, #3f8bff, #2f7cf6);
    box-shadow: 0 3px 10px rgba(47, 124, 246, .32);
}

.send-btn:disabled { cursor: not-allowed; opacity: .7; }

/* 表情面板 */
.emoji-panel {
    display: none;
    position: absolute;
    left: 14px;
    bottom: 76px;
    width: 260px;
    max-height: 160px;
    overflow-y: auto;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--mk-border);
    border-radius: 10px;
    box-shadow: var(--mk-shadow);
    z-index: 20;
    font-size: 20px;
    line-height: 1.4;
}

.emoji-panel.show { display: block; }

.emoji-panel span {
    display: inline-block;
    width: 34px;
    height: 34px;
    text-align: center;
    line-height: 34px;
    border-radius: 6px;
    cursor: pointer;
}

.emoji-panel span:hover { background: #f2f4f8; }

/* ---------- 右侧资料卡 ---------- */
.chat-side {
    flex: 0 0 300px;
    border-left: 1px solid var(--mk-border);
    background: #f7f9fc;
    overflow-y: auto;
    padding: 24px 20px;
}

.side-card { text-align: center; }

.side-avatar {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    display: block;
    margin: 0 auto 10px;
    box-shadow: 0 4px 14px rgba(47, 124, 246, .22);
}

.side-name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 6px;
}

.side-slogan {
    font-size: 12px;
    color: var(--mk-text-sub);
    margin-bottom: 16px;
    line-height: 1.6;
}

.side-links {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--mk-border);
}

.side-links a {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--mk-text-sub);
    word-break: break-all;
}

.side-links a:hover { color: var(--mk-primary); }

.side-links .ico { flex: 0 0 auto; }

.side-desc {
    text-align: left;
    font-size: 12.5px;
    color: var(--mk-text-sub);
    line-height: 1.9;
    margin-bottom: 18px;
    white-space: pre-wrap;
    word-break: break-word;
}

.side-qr-title {
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--mk-border);
}

.side-qrs {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.side-qr {
    flex: 0 0 auto;
    width: 92px;
    text-align: center;
}

.side-qr img {
    width: 92px;
    height: 92px;
    display: block;
    border-radius: 6px;
    background: #fff;
    object-fit: contain;
}

.side-qr span {
    display: block;
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--mk-text-sub);
    line-height: 1.4;
}

/* 图片放大预览 */
.img-viewer {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .78);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.img-viewer.show { display: flex; }

.img-viewer img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 6px;
}

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
    .chat-side {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 48px;
        bottom: 0;
        flex: none;
        z-index: 30;
        border-left: none;
        background: #f7f9fc;
        padding: 20px 18px 30px;
    }

    .chat-side.show { display: block; }

    .chat-body { position: relative; }

    .chat-scroll { padding: 12px; }

    .chat-head { padding: 0 10px; }

    .msg-main { max-width: calc(100% - 76px); }

    .quick-links {
        gap: 18px;
        padding: 8px 12px;
        overflow-x: auto;
    }

    .chat-input { padding: 8px 10px 10px; }

    .emoji-panel { left: 10px; right: 10px; width: auto; }
}