/* 消息页 */
.message-page {
    padding-bottom: 0;
}

.message-page .feed-load-more-wrap {
    padding-bottom: 8px;
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 8px;
}

.message-header .page-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.message-summary {
    display: flex;
    gap: 6px;
}

.message-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(0, 195, 206, 0.12);
    color: var(--cm-primary, #00c3ce);
}

.message-tabs-wrap {
    background: #fff;
    border-bottom: 1px solid var(--cm-border, #eee);
}

.message-tabs {
    display: flex;
    gap: 24px;
    padding: 0 0 0 4px;
}

.message-tab {
    position: relative;
    padding: 12px 4px;
    font-size: 15px;
    color: var(--cm-text-muted, #999);
    text-decoration: none;
}

.message-tab.active {
    color: var(--cm-primary, #00c3ce);
    font-weight: 600;
}

.message-tab.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--cm-primary, #00c3ce);
    border-radius: 1px;
}

.message-list {
    padding-top: 8px;
}

.message-session-item,
.message-notification-item {
    display: flex;
    gap: 12px;
    padding: 14px 12px;
    background: #fff;
    border-radius: var(--cm-radius, 8px);
    margin-bottom: 8px;
    color: inherit;
    text-decoration: none;
}

.message-notification-item.unread {
    background: rgba(0, 195, 206, 0.04);
}

.message-session-avatar,
.message-notification-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.message-session-avatar img,
.message-notification-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--cm-bg, #f5f5f5);
    color: var(--cm-text-muted, #ccc);
    font-size: 20px;
}

.message-unread-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4d4f;
    border: 2px solid #fff;
}

.message-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    color: #fff;
    background: #ff4d4f;
    border-radius: 9px;
    border: 2px solid #fff;
    box-sizing: border-box;
}

.message-session-item.has-unread .message-session-name,
.message-session-item.has-unread .message-session-preview {
    font-weight: 600;
    color: var(--cm-text, #333);
}

.message-tab-badge {
    display: inline-block;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin-left: 4px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: #ff4d4f;
    border-radius: 8px;
    vertical-align: middle;
    font-weight: normal;
}

.message-tab.active .message-tab-badge {
    background: #ff4d4f;
}

.message-session-body,
.message-notification-body {
    flex: 1;
    min-width: 0;
}

.message-session-top,
.message-notification-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.message-session-name,
.message-notification-title {
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-session-time,
.message-notification-time {
    font-size: 12px;
    color: var(--cm-text-muted, #999);
    flex-shrink: 0;
}

.message-session-preview,
.message-notification-content {
    font-size: 13px;
    color: var(--cm-text-muted, #999);
    margin: 6px 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-notification-from {
    font-size: 12px;
    color: var(--cm-text-muted, #bbb);
    margin-top: 4px;
    display: block;
}

/* 聊天页 */
.message-chat-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--cm-pc-nav-height));
}

.message-chat-header {
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid var(--cm-border, #eee);
}

.message-chat-header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
}

.message-back-link {
    font-size: 24px;
    color: var(--cm-text, #333);
    text-decoration: none;
    line-height: 1;
    flex-shrink: 0;
}

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

.message-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.message-chat-name {
    font-size: 16px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--cm-bg, #f5f6f8);
}

.message-chat-messages-inner {
    padding: 16px 0;
}

.message-bubble-wrap {
    display: flex;
    margin-bottom: 12px;
}

.message-bubble-wrap.is-me {
    justify-content: flex-end;
}

.message-bubble-wrap.is-other {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.message-bubble-wrap.is-me .message-bubble {
    background: var(--cm-primary, #00c3ce);
    color: #fff;
}

.message-bubble-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.message-bubble-image {
    display: block;
    max-width: 200px;
    border-radius: 8px;
}

.message-bubble-wrap.is-me .message-bubble-image {
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.message-bubble-wrap.is-me .message-bubble:has(.message-bubble-image),
.message-bubble-wrap.is-other .message-bubble:has(.message-bubble-image) {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.message-bubble-wrap.is-me .message-bubble:has(.message-bubble-image) .message-bubble-time {
    color: var(--cm-text-muted, #999);
    opacity: 1;
}

.message-chat-compose {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid var(--cm-border, #eee);
    padding: 0 0 calc(8px + env(safe-area-inset-bottom, 0px));
}

.message-emoji-panel {
    border-bottom: 1px solid var(--cm-border, #eee);
    background: #fafafa;
    padding: 8px 12px;
}

.message-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.message-emoji-item {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1.2;
    padding: 4px 0;
    cursor: pointer;
}

.message-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding-top: 8px;
}

.message-chat-tool-btn {
    flex-shrink: 0;
    width: 34px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--cm-text-muted, #999);
    font-size: 20px;
    padding: 0;
    cursor: pointer;
}

.message-chat-tool-btn:active {
    color: var(--cm-primary, #00c3ce);
}

.message-chat-form textarea {
    flex: 1;
    border: 1px solid var(--cm-border, #eee);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    resize: none;
    min-height: 38px;
    max-height: 100px;
    outline: none;
}

.message-chat-form textarea:focus {
    border-color: var(--cm-primary, #00c3ce);
}

.message-bubble-time {
    display: block;
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.message-chat-form .btn {
    flex-shrink: 0;
    height: 38px;
    min-width: 56px;
}

/* 手机聊天全屏 */
@media (max-width: 767px) {
    .community-chat-mode .message-chat-page {
        flex: 1;
        min-height: 0;
        height: 100%;
    }

    .community-chat-mode .message-chat-header {
        padding-top: env(safe-area-inset-top, 0px);
    }

    .community-chat-mode .message-chat-header-inner {
        padding-top: 8px;
        padding-bottom: 10px;
    }
}

/* 底栏未读角标 */
.tab-item .tab-unread-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 18px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: #ff4d4f;
    border-radius: 8px;
}

.tab-item {
    position: relative;
}
