/* ===== 消息/聊天列表页 ===== */
.page-title {
    padding: 20px 20px 12px;
    font-size: 24px;
    font-weight: 700;
}

/* 会话列表 */
.chat-list {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
}
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
}
.chat-list-item:active { background: #f5f5f5; }
.chat-list-item img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.chat-list-body { flex: 1; min-width: 0; }
.chat-list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.chat-list-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}
.chat-list-time {
    font-size: 11px;
    color: #bbb;
    flex-shrink: 0;
}
.chat-list-preview {
    font-size: 13px;
    color: #999;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-list-badge {
    min-width: 18px;
    height: 18px;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
    margin-left: 8px;
}

/* 无会话 */
.matches-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-light);
}
.matches-empty i { font-size: 56px; color: #e0e0e0; margin-bottom: 16px; }
.matches-empty p { font-size: 16px; margin-bottom: 6px; }
.matches-empty .sub { font-size: 13px; color: #bbb; }

/* ===== 聊天页 ===== */
#page-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    position: relative;
    overflow: hidden;
    padding-bottom: 0;
}
#page-chat.active { display: flex !important; }
.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.chat-back {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f5f5f5;
    color: #333;
    font-size: 16px;
}
.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}
.chat-header-info { flex: 1; }
.chat-header-info h3 { font-size: 16px; font-weight: 600; }
.chat-online { font-size: 12px; color: #27ae60; }
.chat-online.syncing { color: #b7791f; }
.chat-online.offline { color: #c53030; }
.service-disclosure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 12px;
    background: #fff7e6;
    border-bottom: 1px solid #ffe2a8;
    color: #8a5b00;
    font-size: 12px;
    line-height: 1.4;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f5f5f5;
}
.chat-msg {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}
.chat-msg.received { align-self: flex-start; }
.chat-msg.sent { align-self: flex-end; }
.chat-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-msg.received .chat-bubble {
    background: white;
    border-bottom-left-radius: 6px;
    color: #333;
}
.chat-msg.sent .chat-bubble {
    background: linear-gradient(135deg, #0d6efd, #667eea);
    border-bottom-right-radius: 6px;
    color: white;
}
.chat-msg-time {
    font-size: 11px;
    color: #bbb;
    margin-top: 4px;
    padding: 0 4px;
}
.chat-msg.sent .chat-msg-time { text-align: right; }
.chat-receipt { margin-left: 6px; color: #6f7f95; }
.chat-msg.pending .chat-msg-time { color: #8b95a7; }
.chat-msg.failed .chat-bubble { background: #fff1f1; border: 1px solid #f1aaaa; color: #a12a2a; }
.chat-msg.failed .chat-msg-time { color: #d14343; }
.chat-retry { margin-left: 5px; color: inherit; font: inherit; text-decoration: underline; }
.chat-new-message { position: absolute; right: 16px; bottom: 74px; z-index: 2; padding: 8px 11px; border-radius: 18px; background: #0d6efd; color: #fff; box-shadow: 0 3px 10px rgba(13,110,253,.28); font-size: 12px; }
.chat-new-message.hidden { display: none; }
.chat-history-load { position: absolute; top: 126px; left: 50%; z-index: 2; transform: translateX(-50%); padding: 6px 10px; border: 1px solid #dbe4f0; border-radius: 14px; background: #fff; color: #667085; font-size: 11px; box-shadow: 0 1px 4px rgba(16,24,40,.1); white-space: nowrap; }
.chat-history-load.hidden { display: none; }
.chat-history-load:disabled { opacity: .6; cursor: wait; }
.chat-connection { align-self: center; margin: 4px auto; padding: 4px 9px; border-radius: 12px; background: #fff0f0; color: #a12a2a; font-size: 11px; }

.chat-system-msg {
    text-align: center;
    font-size: 12px;
    color: #aaa;
    padding: 8px 0;
}
.chat-system-msg.guarantee {
    align-self: center;
    max-width: 92%;
    padding: 10px 12px;
    border: 1px solid #ffd58a;
    border-radius: 6px;
    color: #7a5200;
    background: #fff8e8;
    line-height: 1.55;
}
.service-label {
    margin-bottom: 4px;
    font-size: 11px;
    color: #667eea;
    font-weight: 600;
}
.match-chat-btn { width: 100%; margin-top: 8px; }
.session-mode {
    margin-left: 8px;
    padding: 3px 7px;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 600;
}
.h5-unread-badge {
    position: absolute;
    top: 3px;
    right: calc(50% - 22px);
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    display: grid;
    place-items: center;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    line-height: 1;
}
.nav-messages { position: relative; }
.h5-unread-badge[hidden] { display: none !important; }

.chat-input-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: white;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
.chat-input-bar input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e8e8e8;
    border-radius: 22px;
    font-size: 14px;
    background: #f5f5f5;
}
.chat-input-bar input:focus { border-color: #0d6efd; background: white; }
.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #667eea);
    color: white;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}
.chat-send:active { transform: scale(0.9); }
.chat-send:disabled { opacity: .55; cursor: wait; }
