* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}

.logo {
    height: 40px;
}

.user-section {
    padding: 10px;
    margin-right: 20px;
}

.user-section input {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 14px;
}

.message-input {
    margin-bottom: 30px;
    position: relative;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* 左侧控制区 */
.left-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 右侧控制区 */
.right-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 调整文本区域的内边距，为左侧按钮留出空间 */
.message-input textarea {
    padding-left: 40px;
    width: 100%;
    min-height: 60px;
    max-height: calc(90vh - 40px);
    height: auto;
    padding: 12px;
    padding-bottom: 40px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    resize: none;
    overflow-y: auto;
}

.message-input textarea::-webkit-scrollbar {
    width: 8px;
}

.message-input textarea::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.message-input textarea::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.message-input textarea::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

#send-message {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 6px 12px;
    background-color: #718096;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#send-message:hover {
    background-color: #4a5568;
}

.messages-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.message[data-username="cathy"] {
    background-color: #f0fff4;  /* 淡绿色 */
}

.message[data-username="baidong"] {
    background-color: #fff5f5;  /* 淡粉色 */
}

.message:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.message[data-username="cathy"]:hover {
    background-color: #e6ffec;  /* 稍深的淡绿色 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.message[data-username="baidong"]:hover {
    background-color: #ffe6e6;  /* 稍深的淡粉色 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.message-header,
.reply-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 6px !important;
    width: 100% !important;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 5px; /* 减小间距 */
}

.header-right {
    display: flex !important;
    gap: 8px !important;
    margin-left: auto !important; /* 确保靠右 */
}

.message-author {
    font-weight: 600;
    color: #001242;
    background-color: #e2e8f0;
    padding: 2px 8px;
    border-radius: 4px;
}

.message-time {
    color: #718096;
    font-size: 0.9em;
    margin-left: 5px; /* 添加左侧间距 */
}

.message-content {
    white-space: pre-wrap;
    max-height: 50px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    cursor: pointer;
    -webkit-touch-callout: text;
    -webkit-user-select: text;
    user-select: text;
}

.message-content.expanded {
    max-height: none !important;
}

.message-content.auto-height {
    max-height: none;
    cursor: pointer;
}

.message-expand-button {
    display: none !important;
}

.message-has-more .message-expand-button {
    display: inline-block;  /* 当消息过长时显示 */
}

.message-expand-button:hover {
    color: #2d3748;
}

.hidden {
    display: none;
}

.error {
    color: #e53e3e;
    margin-top: 5px;
}

.message-checkbox {
    display: none;
    padding-top: 20px;
}

.show-checkboxes .message-checkbox {
    display: block;
}

.message-content-wrapper {
    flex-grow: 1;
    padding-bottom: 35px;
    position: relative;
    padding-right: 40px;  /* 减小右侧内边距 */
}

.message-controls {
    margin-bottom: 20px;
}

/* 强制隐藏所有操作按钮，包括回复按钮 */
.message-actions,
.reply-actions,
.reply-button {
    display: none !important; /* 完全隐藏 */
    gap: 8px;
    transition: none; /* 移除过渡效果 */
}

/* 只在鼠标悬停时显示按钮 */
.message:hover .message-actions,
.message:hover .reply-button,
.reply-message:hover .reply-actions {
    display: flex !important; /* 强制显示 */
}

/* 确保按钮样式正确 */
.message-actions button,
.reply-actions button,
.reply-button {
    background: none !important;
    border: none !important;
    padding: 4px 8px !important;
    cursor: pointer !important;
    color: #718096 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
}

.message-actions .edit-button:hover,
.reply-button:hover {
    color: #4299e1;
}

.message-actions .delete-button:hover,
.reply-actions .delete-button:hover {
    color: #e53e3e;
}

.message-actions i,
.reply-actions i,
.reply-button i {
    font-size: 14px;
}

.delete-button, .batch-delete-button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.delete-button:hover, .batch-delete-button:hover {
    background: none;
}

.message-select {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.batch-mode-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.cancel-button {
    padding: 8px 16px;
    background-color: #718096;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.cancel-button:hover {
    background-color: #4a5568;
}

.undo-button {
    padding: 8px 16px;
    background-color: #4299e1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.undo-button:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}

.undo-button:not(:disabled):hover {
    background-color: #3182ce;
}

.settings-button {
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: #4a5568;
    font-size: 20px;
}

.settings-button:hover {
    color: #2d3748;
}

.settings-dropdown {
    position: relative;
}

.settings-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-width: 200px;
    z-index: 1000;
    display: none;
}

.settings-menu.show {
    display: block;
}

.settings-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #4a5568;
    transition: background-color 0.2s;
}

.settings-menu-item:hover {
    background-color: #f7fafc;
}

.settings-menu-item.danger {
    color: #e53e3e;
}

.settings-menu-item.danger:hover {
    background-color: #fff5f5;
}

.settings-divider {
    height: 1px;
    background-color: #e2e8f0;
    margin: 8px 0;
}

.settings-menu-item i {
    width: 20px;
    text-align: center;
}

.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.settings-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    min-width: 300px;
}

.settings-content h3 {
    margin-bottom: 20px;
    color: #2d3748;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.setting-description {
    margin-top: 8px;
    font-size: 12px;
    color: #718096;
    line-height: 1.4;
}

.setting-description p {
    margin-bottom: 4px;
}

.close-button {
    padding: 8px 16px;
    background-color: #4a5568;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
}

.close-button:hover {
    background-color: #2d3748;
}

.delete-icon,
.edit-icon,
.reply-icon {
    position: static;  /* 取消绝对定位 */
    opacity: 1;
    visibility: visible;
    font-size: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.delete-icon {
    color: #e53e3e;
}

.edit-icon,
.reply-icon {
    color: #4299e1;
}

/* 悬停效果 */
@media (hover: hover) {
    .message:hover .message-actions {
        opacity: 1;
        visibility: visible;
    }
}

/* 按钮悬停效果 */
.reply-icon:hover,
.edit-icon:hover {
    color: #3182ce;
    transform: scale(1.1);
}

.delete-icon:hover {
    color: #c53030;
    transform: scale(1.1);
}

.select-all-button {
    padding: 8px 16px;
    background-color: #4a5568;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.select-all-button:hover {
    background-color: #2d3748;
}

/* 添加内联编辑相关样式 */
.inline-edit-area {
    width: 100%;
    min-height: 100px;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    resize: vertical;
}

.inline-edit-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.save-edit-button, .cancel-edit-button {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.save-edit-button {
    background-color: #4299e1;
    color: white;
}

.save-edit-button:hover {
    background-color: #3182ce;
}

.cancel-edit-button {
    background-color: #718096;
    color: white;
}

/* 添加回复相关样式 */
.message-replies {
    margin-top: 10px;
    padding-left: 20px;
}

.reply-message {
    position: relative;
    margin-left: 20px;
    margin-top: 10px;
    padding: 10px;
    background-color: #f8fafc;
    border-radius: 6px;
    border-left: 2px solid #e2e8f0;
}

/* 修改回复消息中的操作按钮样式 */
.reply-actions {
    display: flex;
    gap: 8px;
    opacity: 1; /* 始终显示，不要隐藏 */
    visibility: visible; /* 始终可见 */
    position: static; /* 确保没有定位问题 */
}

.reply-actions button {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    color: #718096;
    transition: color 0.2s;
}

.reply-actions .delete-button:hover {
    color: #e53e3e;
}

/* 添加 AI 回复加载样式 */
.ai-reply-loading {
    margin-top: 10px;
    padding: 10px;
    background-color: #f8fafc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 1 !important; /* 强制显示 */
    visibility: visible !important; /* 强制显示 */
}

.loading-text {
    color: #4a5568;
    font-size: 0.9em;
    display: inline-block; /* 确保文本显示 */
}

.loading-dots {
    display: flex;
    gap: 4px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #718096;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
    display: inline-block; /* 确保点显示 */
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 添加 AI 回复错误样式 */
.ai-reply-error {
    margin-top: 10px;
    padding: 10px;
    background-color: #fff5f5;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.error-text {
    color: #e53e3e;
    font-size: 0.9em;
}

/* 回复区域的样式 */
.replies {
    margin-top: 10px;
    padding-left: 20px;
}

/* 回复输入框的样式 */
.reply-input {
    margin-top: 10px;
    padding: 10px;
    background-color: #f8fafc;
    border-radius: 6px;
}

.reply-input textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    resize: vertical;
}

.reply-controls {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.reply-controls button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.send-reply {
    background-color: #4299e1;
    color: white;
}

.cancel-reply {
    background-color: #718096;
    color: white;
}

/* 添加刷新按钮样式 */
.refresh-button {
    padding: 8px 16px;
    background-color: #718096;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.refresh-button:hover {
    background-color: #4a5568;
}

.refresh-button i {
    font-size: 14px;
}

/* 修改消息底部和操作按钮的样式 */
.message-footer {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* 统一所有操作按钮的样式 */
.message-actions,
.reply-actions {
    display: flex;
    gap: 8px;
    opacity: 1; /* 始终显示，不要隐藏 */
    visibility: visible; /* 始终可见 */
    position: static; /* 确保没有定位问题 */
}

.message-actions button,
.reply-actions button,
.reply-button {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    color: #718096;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

/* 修改按钮显示逻辑 */
.message:hover .message-actions,
.message:hover .reply-button,
.reply-message:hover .reply-actions {
    opacity: 1;
    visibility: visible;
}

/* 统一按钮悬停效果 */
.message-actions .edit-button:hover,
.reply-button:hover {
    color: #4299e1;
}

.message-actions .delete-button:hover,
.reply-actions .delete-button:hover {
    color: #e53e3e;
}

/* 统一图标大小 */
.message-actions i,
.reply-actions i,
.reply-button i {
    font-size: 14px;
}

/* 移除旧的定位样式 */
.message-actions,
.reply-actions {
    position: static;
    right: auto;
    top: auto;
}

/* 添加加载动画样式 */
.loading-spinner {
    border: 2px solid #f3f3f3; /* Light grey */
    border-top: 2px solid #3498db; /* Blue */
    border-radius: 50%;
    width: 12px;
    height: 12px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 8px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 添加消息输入控制区样式 */
.message-input-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 上传图片按钮样式 */
.upload-image-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    background-color: #f1f5f9;
    cursor: pointer;
    transition: background-color 0.2s;
}

.upload-image-button:hover {
    background-color: #e2e8f0;
}

.upload-image-button i {
    color: #64748b;
    font-size: 16px;
}

/* 图片预览容器样式 */
.image-preview-container {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.image-preview {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 4px;
    overflow: hidden;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
}

/* 消息中的图片样式 */
.message-image {
    margin-top: 10px;
    max-width: 100%;
    position: relative;
    z-index: 2; /* 确保图片显示在上层 */
    overflow: visible; /* 确保图片不会被裁剪 */
}

/* 确保图片容器不受父元素高度限制 */
.message-content .message-image {
    max-height: none !important;
    overflow: visible !important;
}

/* 确保图片本身完整显示 */
.message-image img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 4px;
    cursor: pointer;
    display: block; /* 确保图片是块级元素 */
}

/* 强制展开包含图片的消息内容 */
.message-content:has(.message-image) {
    max-height: none !important;
    overflow: visible !important;
}

/* 全屏图片查看样式 */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.full-image-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.full-image-container img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 4px;
}

.close-image {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 为包含图片的消息内容设置样式 */
.message-content.has-images {
    max-height: none !important;
}