body,
html {
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.chat {
  padding-top: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#root {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* 用户信息区域样式 */
.user-info {
  margin-bottom: 15px;
  padding: 10px 0;
  border-bottom: 1px solid #e1e1e1;
}

.username-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.username-display {
  cursor: pointer;
  color: #1eaedb;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.username-display:hover {
  background-color: #f8f9fa;
}

.new-username-button {
  background: none;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.new-username-button:hover {
  background-color: #f0f0f0;
  border-color: #1eaedb;
  transform: rotate(180deg);
}

.username-input {
  width: auto;
  min-width: 200px;
  margin: 0;
  padding: 5px 10px;
  font-weight: 600;
  border: 2px solid #33c3f0;
}

/* 消息容器样式 */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  margin-bottom: 15px;
  max-height: calc(100vh - 200px);
  background-color: #f5f7fa;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 消息包装器 */
.message-wrapper {
  display: flex;
  width: 100%;
  margin-bottom: 12px;
  align-items: flex-end;
  gap: 8px;
}

/* 其他用户消息 - 左对齐 */
.message-wrapper.other-user {
  justify-content: flex-start;
  flex-direction: row;
}

/* 当前用户消息 - 右对齐 */
.message-wrapper.current-user {
  justify-content: flex-end;
  flex-direction: row-reverse;
}

/* 确保消息气泡在正确的位置 */
.message-wrapper.other-user .message-bubble {
  margin-left: 0;
  margin-right: auto;
}

.message-wrapper.current-user .message-bubble {
  margin-left: auto;
  margin-right: 0;
}

/* 用户头像样式 */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 消息气泡 */
.message-bubble {
  max-width: 60%;
  width: auto;
  position: relative;
  animation: messageSlideIn 0.3s ease-out;
}

/* 其他用户的气泡样式 */
.other-user .message-bubble {
  background-color: #ffffff;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e1e8ed;
}

/* 当前用户的气泡样式 */
.current-user .message-bubble {
  background-color: #7CB342;
  color: white;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 1px 3px rgba(124, 179, 66, 0.3);
}

/* 消息头部（用户名和时间） */
.message-header {
  padding: 6px 12px 2px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.message-header .username {
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

.message-header .timestamp {
  font-size: 10px;
  color: #999;
  cursor: help;
}

/* 消息内容 */
.message-content {
  padding: 8px 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.message-text {
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  margin: 0;
}

/* 当前用户消息的文本颜色 */
.current-user .message-text {
  color: white;
}

/* 消息底部（当前用户的时间戳） */
.message-footer {
  padding: 2px 12px 6px 12px;
  text-align: right;
}

.current-user .message-footer .timestamp {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  cursor: help;
}

/* 消息操作按钮 */
.message-actions {
  padding: 2px 12px 6px 12px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.message-bubble:hover .message-actions {
  opacity: 1;
}

/* 当前用户消息的操作按钮右对齐 */
.current-user .message-actions {
  justify-content: flex-end;
}

.reply-button, .recall-button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 11px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
}

.reply-button:hover {
  background: rgba(255, 255, 255, 1);
  color: #000000;
  border-color: #000000;
  transform: translateY(-1px);
}

.recall-button {
  background: rgba(255, 245, 245, 0.9);
  border-color: rgba(254, 215, 215, 0.8);
  color: #c53030;
}

.recall-button:hover {
  background: rgba(254, 215, 215, 1);
  color: #9b2c2c;
  transform: translateY(-1px);
}

/* 当前用户消息的按钮样式 */
.current-user .reply-button, .current-user .recall-button {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
}

.current-user .reply-button:hover {
  background: rgba(255, 255, 255, 0.3);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

.current-user .recall-button {
  background: rgba(255, 182, 193, 0.3);
  border-color: rgba(255, 182, 193, 0.5);
  color: #ffb6c1;
}

.current-user .recall-button:hover {
  background: rgba(255, 182, 193, 0.5);
  color: #ff69b4;
}

/* 右键菜单样式 */
.context-menu {
  background: white;
  border: 1px solid #e1e8ed;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 4px 0;
  min-width: 120px;
  font-size: 14px;
}

.context-menu-item {
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: #333;
}

.context-menu-item:hover {
  background-color: #f5f8fa;
}

.context-menu-item:active {
  background-color: #e1e8ed;
}

/* 消息滑入动画 */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 撤回消息样式 */
.message-wrapper.recalled {
  opacity: 0.7;
}

.message-wrapper.recalled .message-bubble {
  background: transparent !important;
  box-shadow: none !important;
  border: 1px dashed #d0d0d0;
}

.recalled-message {
  padding: 6px 12px;
  background: transparent;
  border-radius: 8px;
  color: #999;
  font-style: italic;
  text-align: center;
  font-size: 12px;
  min-width: auto;
}

.current-user .recalled-message {
  background: transparent;
  color: #999;
}

.recalled-text {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.recalled-text::before {
  content: "🚫";
  font-size: 10px;
  opacity: 0.7;
}

/* 引用回复样式 */
.reply-reference {
  margin-bottom: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.05);
  border-left: 3px solid #000000;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
}

.current-user .reply-reference {
  background: rgba(255, 255, 255, 0.15);
  border-left-color: rgba(255, 255, 255, 0.6);
  color: rgba(255, 255, 255, 0.9);
}

.reply-indicator {
  font-weight: 600;
  color: #000000;
  margin-bottom: 4px;
}

.current-user .reply-indicator {
  color: rgba(255, 255, 255, 0.9);
}

.reply-content {
  color: #657786;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-user .reply-content {
  color: rgba(255, 255, 255, 0.8);
}

/* 引用消息样式 */
.reply-reference {
  background-color: #f8f9fa;
  border-left: 3px solid #007bff;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
  font-size: 13px;
}

.reply-indicator {
  color: #007bff;
  font-weight: 500;
  margin-bottom: 4px;
}

.reply-content {
  color: #666;
  font-style: italic;
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

/* 引用回复预览样式 */
.reply-preview {
  background-color: #e3f2fd;
  border: 1px solid #2196f3;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  position: relative;
}

.reply-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 500;
  color: #1976d2;
  font-size: 14px;
}

.cancel-reply {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.cancel-reply:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

.reply-preview-content {
  color: #555;
  font-size: 13px;
  font-style: italic;
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.message .remove {
  position: absolute;
  width: 22px;
  height: 20px;
  left: -60px;
  /* display: "block", */
  display: none;
  padding: 0;
  line-height: 18px;
  border: "none";
}

/* 表单样式 */
.send-message {
  padding: 0;
}

.my-input-text {
  margin-bottom: 0;
}

.my-input-text::placeholder {
  color: #ccc;
}

/* 滚动条样式 */
.messages-container::-webkit-scrollbar {
  width: 8px;
}

.messages-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}

/* 聊天室操作按钮样式 */
.chat-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.new-chat-button,
.share-chat-button {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #1eaedb;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
}

.new-chat-button {
  background-color: #1eaedb;
  color: white;
}

.new-chat-button:hover {
  background-color: #0fa0ce;
  border-color: #0fa0ce;
}

.share-chat-button {
  background-color: white;
  color: #1eaedb;
}

.share-chat-button:hover {
  background-color: #1eaedb;
  color: white;
}

/* 高亮消息样式 */
.highlight-message {
  animation: highlight 2s ease-in-out;
}

@keyframes highlight {
  0% {
    background-color: rgba(255, 235, 59, 0.3);
    transform: scale(1.02);
  }
  50% {
    background-color: rgba(255, 235, 59, 0.5);
  }
  100% {
    background-color: transparent;
    transform: scale(1);
  }
}

/* 响应式设计 */
@media (max-width: 550px) {
  .messages-container {
    max-height: calc(100vh - 180px);
    padding: 10px;
    gap: 8px;
  }

  .username-input {
    min-width: 150px;
  }

  .chat-actions {
    flex-direction: column;
    gap: 5px;
  }

  .new-chat-button,
  .share-chat-button {
    padding: 6px 12px;
    font-size: 12px;
    width: 100%;
  }

  /* 移动端头像样式 */
  .avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  /* 移动端气泡消息样式 */
  .message-bubble {
    max-width: 75%;
    min-width: fit-content;
  }

  .message-content {
    padding: 6px 10px;
  }

  .message-text {
    font-size: 13px;
    line-height: 1.4;
  }

  /* 移动端右键菜单样式 */
  .context-menu {
    min-width: 100px;
    font-size: 13px;
  }

  .context-menu-item {
    padding: 10px 14px;
  }

  .reply-reference {
    padding: 6px 8px;
    font-size: 11px;
    margin-bottom: 6px;
  }

  .recalled-message {
    padding: 4px 8px;
    font-size: 11px;
  }

  .recalled-text {
    font-size: 11px;
  }

  .recalled-text::before {
    font-size: 9px;
  }

  /* 移动端气泡圆角调整 */
  .other-user .message-bubble {
    border-radius: 16px 16px 16px 3px;
  }

  .current-user .message-bubble {
    border-radius: 16px 16px 3px 16px;
  }
}
