/* ========================================
   私信系统样式
   ======================================== */

/* 私信按钮 */
.uap-message-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.uap-message-btn:hover {
    background: #e5e7eb;
    color: #1f2937;
}

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

.uap-message-btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.uap-message-btn-small svg {
    width: 14px;
    height: 14px;
}

/* 私信图标按钮 */
.uap-message-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.uap-message-icon-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* 私信页面容器 */
.uap-messages-container {
    display: flex;
    height: 600px;
    max-height: calc(100vh - 300px);
    min-height: 400px;
    background: #fff;
    border: 1px solid var(--uap-border, #e5e7eb);
    border-radius: 12px;
    overflow: hidden;
}

/* 左侧会话列表 */
.uap-messages-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--uap-border, #e5e7eb);
    background: #fafafa;
}

.uap-messages-sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--uap-border, #e5e7eb);
    background: #fff;
}

.uap-messages-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

/* Unread total at the heading's top-right (same shape as every unread badge). */
.uap-messages-unread-badge {
    position: relative;
    top: -7px;
    margin-left: 1px;
    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: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 会话列表 */
.uap-conversations-list {
    flex: 1;
    overflow-y: auto;
}

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

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

.uap-conversation-item.active {
    background: #e5e7eb;
}

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

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

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

.uap-conv-name {
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

.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: flex;
    flex-direction: column;
    min-width: 0;
    background: #fff;
}

/* 聊天占位符 */
.uap-chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.uap-chat-placeholder-icon {
    margin-bottom: 16px;
    opacity: 0.5;
}

.uap-chat-placeholder p {
    margin: 0;
    font-size: 15px;
}

/* 聊天头部 */
.uap-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--uap-border, #e5e7eb);
    background: #fff;
}

.uap-chat-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s;
}

.uap-chat-back-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.uap-chat-user-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
}

.uap-chat-user-link:hover .uap-chat-user-name {
    color: var(--uap-action-bg, #4f46e5);
}

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

.uap-chat-user-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    transition: color 0.15s;
}

.uap-chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.uap-chat-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s;
}

.uap-chat-delete-btn:hover {
    background: #fef2f2;
    color: #ef4444;
}

/* 聊天内容区 */
.uap-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

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

.uap-chat-load-more-btn {
    padding: 8px 20px;
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.uap-chat-load-more-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.uap-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.uap-chat-loading,
.uap-chat-empty {
    text-align: center;
    color: #9ca3af;
    padding: 40px 20px;
    font-size: 14px;
}

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

.uap-chat-message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.uap-chat-message.received {
    align-self: flex-start;
}

.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: 16px;
    font-size: 14px;
    line-height: 1.5;
    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: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

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

/* 撤回的消息 */
.uap-chat-recalled {
    font-style: italic;
    color: #9ca3af;
}

.uap-chat-message.recalled .uap-chat-msg-bubble {
    background: #f9fafb !important;
    color: #9ca3af !important;
}

/* 消息右键菜单 */
.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: 10000;
}

.uap-chat-msg-menu button {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #374151;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.uap-chat-msg-menu button:hover {
    background: #f3f4f6;
}

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

.uap-chat-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    transition: border-color 0.15s;
}

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

.uap-chat-input {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 0;
    background: transparent;
    border: none;
    outline: none;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    color: #1f2937;
}

.uap-chat-input::placeholder {
    color: #9ca3af;
}

.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 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--uap-action-bg, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

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

.uap-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 聊天模态框（从用户主页打开） */
.uap-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.uap-chat-modal.show {
    opacity: 1;
    visibility: visible;
}

.uap-chat-modal-content {
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.2s;
}

.uap-chat-modal.show .uap-chat-modal-content {
    transform: translateY(0);
}

.uap-chat-modal .uap-chat-header {
    padding: 16px 20px;
}

.uap-chat-modal .uap-chat-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s;
    margin-left: auto;
}

.uap-chat-modal .uap-chat-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.uap-chat-modal .uap-chat-body {
    height: 400px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .uap-messages-container {
        height: calc(100vh - 200px);
        max-height: none;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .uap-messages-sidebar {
        width: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
        transition: transform 0.3s;
    }

    .uap-messages-chat {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 2;
        transform: translateX(100%);
        transition: transform 0.3s;
    }

    .uap-messages-chat.active {
        transform: translateX(0);
    }

    .uap-chat-back-btn {
        display: flex;
    }

    .uap-chat-message {
        max-width: 85%;
    }

    /* 模态框全屏 */
    .uap-chat-modal-content {
        max-width: none;
        max-height: none;
        height: 100%;
        border-radius: 0;
    }

    .uap-chat-modal .uap-chat-body {
        height: auto;
        flex: 1;
    }
}

/* ==================== 私信弹窗（全局） ==================== */
.uap-messages-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.uap-messages-modal.show {
    display: flex;
    opacity: 1;
}

.uap-messages-modal-content {
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    background: var(--uap-surface);
    border-radius: var(--uap-radius-xl);
    /* overflow: hidden removed to allow dropdowns / emoji pickers to display outside */
    box-shadow: var(--uap-shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
    transform: scale(0.95) translateY(10px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.uap-messages-modal.show .uap-messages-modal-content {
    transform: none;
}

.uap-messages-modal .uap-dm-container {
    display: flex;
    height: 636px;
    position: relative;
    border-radius: inherit;
    overflow: hidden;
    /* Put the hidden overflow clipping specifically on the inner box so fixed popups attached elsewhere aren't clipped */
}

/* 会话列表侧边栏 */
.uap-messages-modal .uap-dm-sidebar {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--uap-border-light);
    display: flex;
    flex-direction: column;
    background: var(--uap-bg);
}

.uap-messages-modal .uap-dm-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--uap-border-light);
    background: var(--uap-surface);
}

.uap-messages-modal .uap-dm-sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--uap-text);
}

.uap-messages-modal .uap-dm-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 50%;
    color: #6b7280 !important;
    cursor: pointer;
    transition: all 0.2s;
}

.uap-messages-modal .uap-dm-sidebar-close:hover {
    background: #f3f4f6 !important;
    color: #374151 !important;
}

.uap-messages-modal .uap-dm-conv-list {
    flex: 1;
    overflow-y: auto;
}

/* 会话列表滚动条样式 - 现代简约设计 */
.uap-messages-modal .uap-dm-conv-list::-webkit-scrollbar {
    width: 6px;
}

.uap-messages-modal .uap-dm-conv-list::-webkit-scrollbar-track {
    background: transparent;
}

.uap-messages-modal .uap-dm-conv-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 3px;
    transition: background 0.2s;
}

.uap-messages-modal .uap-dm-conv-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Firefox 滚动条样式 */
.uap-messages-modal .uap-dm-conv-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}

/* 会话项 */
.uap-messages-modal .uap-dm-conv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 4px 8px;
    border-radius: var(--uap-radius);
    cursor: pointer;
    transition: var(--uap-transition);
}

.uap-messages-modal .uap-dm-conv-item:hover {
    background: var(--uap-surface-hover);
    transform: translateX(4px);
}

.uap-messages-modal .uap-dm-conv-item.active {
    background: var(--uap-primary-light);
    color: var(--uap-action-bg, #4f46e5);
}

.uap-messages-modal .uap-dm-conv-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.uap-messages-modal .uap-dm-conv-avatar-wrap img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

/* Unread count on the avatar's top-right (same shape as every unread badge); the ring separates it from the photo. */
.uap-messages-modal .uap-dm-conv-avatar-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);
    pointer-events: none;
}

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

.uap-messages-modal .uap-dm-conv-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.uap-messages-modal .uap-dm-conv-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.uap-messages-modal .uap-dm-conv-preview {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uap-messages-modal .uap-dm-conv-empty,
.uap-messages-modal .uap-dm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
    text-align: center;
}

/* 顶部加载指示器（加载历史消息时） */
.uap-messages-modal .uap-dm-loading-top {
    padding: 12px 20px;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
    margin-bottom: 10px;
}

/* 聊天区域 */
.uap-messages-modal .uap-dm-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.uap-messages-modal .uap-dm-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.uap-messages-modal .uap-dm-empty svg {
    opacity: 0.4;
    margin-bottom: 12px;
}

.uap-messages-modal .uap-dm-empty p {
    margin: 0;
    font-size: 14px;
}

.uap-messages-modal .uap-dm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--uap-border-light);
    background: var(--uap-surface);
    min-height: 60px;
}

.uap-messages-modal .uap-dm-back-btn {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 12px !important;
    background: #f3f4f6 !important;
    border: none !important;
    border-radius: 20px;
    color: #6b7280 !important;
    font-size: 13px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.uap-messages-modal .uap-dm-back-btn svg {
    width: 16px;
    height: 16px;
}

.uap-messages-modal .uap-dm-back-btn:hover {
    background: #e5e7eb !important;
    color: #374151 !important;
}

.uap-messages-modal .uap-dm-header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
}

.uap-messages-modal .uap-dm-user-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    max-width: 200px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.uap-messages-modal .uap-dm-user-link:hover {
    background: #f3f4f6;
}

.uap-messages-modal .uap-dm-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    max-width: 200px;
}

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

.uap-messages-modal .uap-dm-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uap-messages-modal .uap-dm-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0 !important;
    background: var(--uap-surface-hover) !important;
    border: none !important;
    border-radius: 50%;
    color: var(--uap-text-muted) !important;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--uap-transition-bounce);
}

.uap-messages-modal .uap-dm-close-btn:hover {
    background: var(--uap-border) !important;
    color: var(--uap-text) !important;
    transform: scale(1.1);
}

/* 消息区域 */
.uap-messages-modal .uap-dm-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* 消息区域滚动条样式 - 现代简约设计 */
.uap-messages-modal .uap-dm-body::-webkit-scrollbar {
    width: 6px;
}

.uap-messages-modal .uap-dm-body::-webkit-scrollbar-track {
    background: transparent;
}

.uap-messages-modal .uap-dm-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
    transition: background 0.2s;
}

.uap-messages-modal .uap-dm-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Firefox 滚动条样式 */
.uap-messages-modal .uap-dm-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

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

.uap-messages-modal .uap-dm-load-more button {
    padding: 6px 16px;
    background: #f3f4f6 !important;
    border: none !important;
    border-radius: 16px;
    color: #6b7280 !important;
    font-size: 13px;
    cursor: pointer;
}

.uap-messages-modal .uap-dm-load-more button:hover {
    background: #e5e7eb !important;
}

/* 消息气泡 */
.uap-messages-modal .uap-dm-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
    max-width: 75%;
}

.uap-messages-modal .uap-dm-msg.sent {
    margin-left: auto;
    flex-direction: row-reverse;
}

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

.uap-messages-modal .uap-dm-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.uap-messages-modal .uap-dm-msg.received .uap-dm-msg-bubble {
    background: var(--uap-surface-hover);
    color: var(--uap-text);
    border-bottom-left-radius: 4px;
}

.uap-messages-modal .uap-dm-msg.sent .uap-dm-msg-bubble {
    background: var(--uap-action-bg, #4f46e5);
    background: linear-gradient(135deg, var(--uap-action-bg, #4f46e5) 0%, var(--uap-action-end, #5b55c7) 100%);
    color: #fff !important;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px var(--uap-primary-alpha, rgba(79, 70, 229, 0.25));
}

.uap-messages-modal .uap-dm-msg-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.uap-messages-modal .uap-dm-msg.sent .uap-dm-msg-time {
    text-align: right;
}

.uap-messages-modal .uap-dm-recalled {
    font-style: italic;
    opacity: 0.7;
}

/* 输入区 - 优化版 */
.uap-messages-modal .uap-dm-footer {
    padding: 16px;
    border-top: 1px solid var(--uap-border-light);
    background: var(--uap-surface);
}

.uap-messages-modal .uap-dm-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--uap-bg);
    border: 1px solid var(--uap-border);
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
    transition: var(--uap-transition);
}

.uap-messages-modal .uap-dm-input-container:focus-within {
    background: var(--uap-surface);
    border-color: var(--uap-primary);
    box-shadow: 0 0 0 3px var(--uap-primary-alpha);
}

.uap-messages-modal .uap-dm-input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.uap-messages-modal .uap-dm-input {
    width: 100%;
    min-height: 36px;
    max-height: 120px;
    padding: 8px 0;
    background: transparent;
    border: none;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    color: #1f2937;
}

.uap-messages-modal .uap-dm-input::placeholder {
    color: #9ca3af;
}

.uap-messages-modal .uap-dm-input::-webkit-scrollbar {
    width: 4px;
}

.uap-messages-modal .uap-dm-input::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.uap-messages-modal .uap-dm-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.uap-messages-modal .uap-dm-input-container:focus-within .uap-dm-bottom-bar {
    opacity: 1;
}

.uap-messages-modal .uap-dm-tools {
    display: flex;
    align-items: center;
    gap: 2px;
}

.uap-messages-modal .uap-dm-counter {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
}

.uap-messages-modal .uap-dm-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.uap-messages-modal .uap-dm-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0 !important;
    background: var(--uap-action-bg, #4f46e5) !important;
    background: linear-gradient(135deg, var(--uap-action-bg, #4f46e5) 0%, var(--uap-action-end, #5b55c7) 100%) !important;
    border: none !important;
    border-radius: 50%;
    color: #fff !important;
    cursor: pointer;
    transition: var(--uap-transition);
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--uap-primary-alpha, rgba(79, 70, 229, 0.25));
}

.uap-messages-modal .uap-dm-send-btn svg {
    width: 18px;
    height: 18px;
}

.uap-messages-modal .uap-dm-send-btn:disabled {
    background: var(--uap-border) !important;
    color: var(--uap-text-light) !important;
    cursor: not-allowed;
    box-shadow: none;
}

.uap-messages-modal .uap-dm-send-btn:not(:disabled):hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px var(--uap-primary-alpha);
}

.uap-messages-modal .uap-dm-send-btn:not(:disabled):active {
    transform: scale(0.95);
}

/* 消息操作菜单（撤回/删除） */
.uap-dm-recall-menu,
.uap-dm-msg-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100000;
    min-width: 80px;
}

.uap-dm-recall-menu button,
.uap-dm-msg-menu button {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: none !important;
    border: none !important;
    text-align: left;
    font-size: 13px;
    color: #374151 !important;
    cursor: pointer;
    white-space: nowrap;
}

.uap-dm-recall-menu button:hover,
.uap-dm-msg-menu button:hover {
    background: #f3f4f6 !important;
}

.uap-dm-msg-menu .uap-dm-menu-delete {
    color: #ef4444 !important;
}

.uap-dm-msg-menu .uap-dm-menu-delete:hover {
    background: #fef2f2 !important;
}

/* 发送按钮加载状态 */
.uap-dm-send-btn.sending {
    position: relative;
    pointer-events: none;
}

.uap-dm-send-btn.sending svg {
    opacity: 0;
}

.uap-dm-send-btn.sending::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: uap-spin 0.8s linear infinite;
}

/* 消息加载状态（撤回/删除中） */
.uap-dm-msg.msg-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.uap-dm-msg.msg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--uap-primary);
    border-radius: 50%;
    animation: uap-spin 0.8s linear infinite;
}

.uap-dm-msg.sent.msg-loading::after {
    left: auto;
    right: 20px;
    margin-left: 0;
}

