/* ==========================================================================
   6.8 Messages - 私信系统
   ========================================================================== */

/* ==================== 私信按钮 ==================== */

.uap-message-btn,
.uap-message-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--uap-border, #e5e7eb);
    border-radius: 20px;
    color: var(--uap-text, #374151);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.uap-message-btn {
    padding: 6px 14px;
}

.uap-message-btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.uap-message-icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
}

.uap-message-btn:hover,
.uap-message-icon-btn:hover {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
    color: var(--uap-action-bg, #4f46e5) !important;
}

.uap-message-btn:focus,
.uap-message-icon-btn:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(var(--uap-primary-rgb), 0.2) !important;
}

.uap-message-btn svg,
.uap-message-icon-btn svg {
    flex-shrink: 0;
}

/* ==================== 聊天模态框 ==================== */

.uap-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
}

.uap-chat-modal.show {
    display: flex;
}

.uap-chat-modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    height: 600px;
    max-height: 80vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 聊天头部 */
.uap-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--uap-border, #e5e7eb);
    background: #fff;
}

.uap-chat-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.uap-chat-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.uap-chat-user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--uap-text, #374151);
}

.uap-chat-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--uap-text-light, #6b7280);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.uap-chat-close:hover {
    background: #f3f4f6;
    color: var(--uap-text, #374151);
}

/* 聊天主体 */
.uap-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
}

.uap-chat-loading,
.uap-chat-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--uap-text-light, #6b7280);
    font-size: 14px;
}

.uap-chat-load-more {
    text-align: center;
    margin-bottom: 16px;
}

.uap-chat-load-more-btn {
    padding: 6px 16px;
    background: #fff;
    border: 1px solid var(--uap-border, #e5e7eb);
    border-radius: 16px;
    color: var(--uap-text-light, #6b7280);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.uap-chat-load-more-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* 消息列表 */
.uap-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 单条消息 */
.uap-chat-message {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 80%;
}

.uap-chat-message.sent {
    margin-left: auto;
    flex-direction: row-reverse;
}

.uap-chat-message.received {
    margin-right: auto;
}

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

.uap-chat-msg-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.uap-chat-message.sent .uap-chat-msg-content {
    align-items: flex-end;
}

.uap-chat-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
}

.uap-chat-message.sent .uap-chat-msg-bubble {
    background: var(--uap-action-bg, #4f46e5);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.uap-chat-message.received .uap-chat-msg-bubble {
    background: #fff;
    color: var(--uap-text, #374151);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.uap-chat-msg-time {
    font-size: 11px;
    color: #9ca3af;
    padding: 0 4px;
}

.uap-chat-recalled {
    font-style: italic;
    color: #9ca3af;
}

/* 聊天底部输入区 */
.uap-chat-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--uap-border, #e5e7eb);
    background: #fff;
}

.uap-chat-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.uap-chat-input {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid var(--uap-border, #e5e7eb);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.uap-chat-input:focus {
    outline: none;
    border-color: var(--uap-primary);
}

.uap-chat-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.uap-chat-char-count {
    font-size: 12px;
    color: #9ca3af;
}

.uap-chat-send-btn {
    padding: 8px 20px;
    background: var(--uap-action-bg, #4f46e5);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.uap-chat-send-btn:hover:not(:disabled) {
    background: var(--uap-action-hover, #4338ca);
}

.uap-chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* 消息右键菜单 */
.uap-chat-msg-menu {
    position: fixed;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 4px;
    z-index: 100001;
}

.uap-chat-recall-btn {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--uap-text, #374151);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.uap-chat-recall-btn:hover {
    background: #f3f4f6;
}

/* ==================== 会话列表（用户中心内） ==================== */

.uap-messages-container {
    display: flex;
    height: 500px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.uap-conversations-panel {
    width: 280px;
    border-right: 1px solid var(--uap-border, #e5e7eb);
    display: flex;
    flex-direction: column;
}

.uap-conversations-header {
    padding: 16px;
    border-bottom: 1px solid var(--uap-border, #e5e7eb);
}

.uap-conversations-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--uap-text, #374151);
}

.uap-conversations-list {
    flex: 1;
    overflow-y: auto;
}

.uap-conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.uap-conversation-item:hover {
    background: #f9fafb;
}

.uap-conversation-item.active {
    background: var(--uap-primary-bg);
}

.uap-conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.uap-conv-info {
    flex: 1;
    min-width: 0;
}

.uap-conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.uap-conv-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--uap-text, #374151);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uap-conv-time {
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
}

.uap-conv-preview {
    font-size: 13px;
    color: var(--uap-text-light, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Unread count at the conversation row end (same shape as every unread badge). */
.uap-conv-unread {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    box-sizing: border-box;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--uap-error, #e11d48);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 聊天区域（用户中心内） */
.uap-messages-chat {
    flex: 1;
    display: none;
    flex-direction: column;
}

.uap-messages-chat.active {
    display: flex;
}

.uap-messages-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--uap-text-light, #6b7280);
    font-size: 14px;
}

/* ==================== 未读徽章 ==================== */

.uap-message-unread-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    box-sizing: border-box;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--uap-error, #e11d48);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--uap-surface, #fff);
}

/* ==================== 私信系统响应式 ==================== */

@media (max-width: 768px) {
    .uap-chat-modal {
        padding: 0;
    }

    .uap-chat-modal-content {
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .uap-messages-container {
        flex-direction: column;
        height: auto;
    }

    .uap-conversations-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--uap-border, #e5e7eb);
    }

    .uap-conversations-list {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .uap-chat-message {
        max-width: 85%;
    }

    .uap-chat-msg-bubble {
        padding: 8px 12px;
        font-size: 13px;
    }

    .uap-chat-input {
        min-height: 50px;
    }
}

/* ==================== 头像下方按钮组 ==================== */

.uap-uc-avatar-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    justify-content: center;
}

.uap-uc-avatar-actions .uap-avatar-follow-btn,
.uap-uc-avatar-actions .uap-message-icon-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.uap-uc-avatar-actions .uap-avatar-follow-btn {
    background: var(--uap-action-bg, #4f46e5);
    border: 2px solid #fff;
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--uap-primary-rgb), 0.4);
}

.uap-uc-avatar-actions .uap-avatar-follow-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(var(--uap-primary-rgb), 0.5);
}

.uap-uc-avatar-actions .uap-avatar-follow-btn.following {
    background: #10b981;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.uap-uc-avatar-actions .uap-message-icon-btn {
    background: #fff;
    border: 2px solid var(--uap-border, #e5e7eb);
    color: var(--uap-text, #374151);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.uap-uc-avatar-actions .uap-message-icon-btn:hover {
    background: var(--uap-action-bg, #4f46e5) !important;
    border-color: var(--uap-primary) !important;
    color: #fff !important;
    transform: scale(1.1);
}

.uap-uc-avatar-actions .uap-message-icon-btn svg {
    width: 14px;
    height: 14px;
}

