/*  Chat Components Styles */

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color, #e5e5e5);
  background: var(--background-color, #ffffff);
  min-height: 56px;
}

.chat-header-left {
  flex: 1;
}

.chat-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color, #333);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Chat Window Styles */
.chat-window {
  display: flex;
  flex-direction: column;
  background: #fff;
  height: 100%;
}
.chat-content {
  max-width: 100%;
  overflow: auto;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.chat-welcome {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-content {
  text-align: center;
  color: #8c8c8c;
}

.welcome-content h3 {
  color: #262626;
  margin-bottom: 8px;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

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

/* 用户消息靠右显示 */
.user-message {
  flex-direction: row-reverse;
  justify-content: flex-start;
  margin-left: auto;
}

/* 助手消息保持左侧显示 */
.assistant-message {
  margin-right: auto;
}

.message-avatar {
  flex-shrink: 0;
}

.message-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  width: auto;
  max-width: 100%;
}

/* 允许消息内容区域的文本选择 */
.message-card,
.message-reasoning-card {
  user-select: text !important;
}

.message-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: calc(100% - 44px);
  width: 100%;
}

.message-avatar {
  flex-shrink: 0;
}

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

.message-time {
  font-size: 12px;
  margin: 0 8px;
}

.message-card {
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  max-width: 100%;
}

.user-message .message-content {
  align-items: flex-end;
}

.user-message .message-content.message-content-editing {
  align-items: initial;
}

.user-message .message-card {
  background: #e6f7ff;
  border-color: #91d5ff;
}

.assistant-message .message-content {
  align-items: flex-start;
}

.assistant-message .message-content.message-content-editing {
  align-items: initial;
}

.assistant-message .message-card {
  background: #fff;
  border-color: #d9d9d9;
}

.chat-window-error {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ff4d4f;
  font-size: 16px;
}

/* Message Actions */
.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* 用户消息头部样式调整 */
.user-message .message-header {
  flex-direction: row-reverse;
}

.message-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-model-selector {
  font-size: 12px;
  min-width: 80px;
}

.message-model-selector .ant-select-selector {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 4px;
  height: auto;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.45);
}

.message-model-selector:hover .ant-select-selector {
  color: rgba(0, 0, 0, 0.65);
  background: rgba(0, 0, 0, 0.04) !important;
}

.message-model-selector .ant-select-arrow {
  font-size: 10px;
  color: rgba(0, 0, 0, 0.25);
}

.message-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  margin-top: 8px;
  padding: 0 8px;
}

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

.message-actions.visible {
  opacity: 1;
}

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

.message-action-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-action-buttons .ant-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.message-action-buttons .ant-btn:hover {
  background-color: rgba(0, 0, 0, 0.06);
}

.message-action-buttons .ant-btn.bookmarked {
  color: #faad14;
}

.message-action-buttons .ant-btn.bookmarked:hover {
  color: #d48806;
  background-color: rgba(250, 173, 20, 0.1);
}

/* Bookmarked Message Highlighting */
.message-item.bookmarked .message-card {
  border: 1px solid #faad14 !important;
  box-shadow: 0 2px 8px rgba(250, 173, 20, 0.15) !important;
}

.message-item.bookmarked .message-reasoning-card {
  border: 1px solid #faad14 !important;
  box-shadow: 0 1px 4px rgba(250, 173, 20, 0.1) !important;
}

/* Message Edit Container */
.message-edit-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-edit-actions {
  display: flex;
  justify-content: flex-end;
}

/* Message Collapse Button */
.message-collapse-btn {
  opacity: 0.5;
  transition: all 0.2s ease;
  margin-left: 4px;
}

.message-collapse-btn:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.06);
}

/* Message Collapsed State */
.message-collapsed {
  border: 1px dashed #d9d9d9 !important;
  background-color: #fafafa !important;
}

.message-collapsed .ant-typography {
  color: rgba(0, 0, 0, 0.45);
}

.message-collapsed .ant-card-body {
  overflow: hidden;
}

/* Message Preview */
.message-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-preview-text {
  font-style: italic;
  line-height: 1.5;
  word-break: break-word;
}

.message-preview-reasoning {
  font-size: 12px;
  opacity: 0.8;
  display: flex;
  align-items: center;
}

/* Always show collapse button on hover */
.message-item:hover .message-collapse-btn {
  opacity: 1;
}

/* Chat Input Area */
.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
}

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

/* TextArea 自适应高度 */
.chat-input-container textarea.ant-input {
  overflow-y: auto !important;
}

/* Model Selector */
.ant-select .ant-select-selector {
  border-radius: 6px;
}

.ant-select-dropdown .ant-select-item-option-content {
  padding: 8px 0;
}

/* 分支导航器样式 */
.branch-navigator {
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
}

.branch-nav-btn {
  padding: 0 4px;
  height: 20px;
  min-width: 20px;
  border-radius: 4px;
  color: #666;
  transition: all 0.2s;
}

.branch-nav-btn:hover:not(:disabled) {
  color: #1890ff;
  background-color: #f0f8ff;
}

.branch-nav-btn:disabled {
  color: #d9d9d9;
  cursor: not-allowed;
}

.branch-info {
  font-size: 12px;
  color: #999;
  margin: 0 4px;
  user-select: none;
}

.message-branch-nav {
  opacity: 0.7;
  transition: opacity 0.2s;
}

.message-item:hover .message-branch-nav {
  opacity: 1;
}

/* 消息内容文本选择样式 */
.message-card .ant-typography {
  user-select: text !important;
  cursor: text;
}

.message-card .ant-typography::selection {
  background-color: #1890ff;
  color: white;
}

.message-reasoning-card .ant-typography {
  user-select: text !important;
  cursor: text;
}

.message-reasoning-card .ant-typography::selection {
  background-color: #52c41a;
  color: white;
}

/* Welcome Message Styles */
.chat-welcome {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.welcome-content {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.welcome-content .ant-typography-title {
  margin-bottom: 16px !important;
}

.welcome-content .ant-typography {
  margin-bottom: 0 !important;
}

/* No Model Configuration State */
.welcome-content .config-steps {
  background: #fff7e6;
  border: 1px solid #ffd591;
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  margin: 16px 0;
}

.welcome-content .config-steps ol {
  margin: 8px 0 0 0;
  padding-left: 20px;
  color: #ad6800;
}

.welcome-content .config-steps ol li {
  margin-bottom: 4px;
  line-height: 1.5;
}

/* Message Search Styles */
.message-search-container {
  position: absolute;
  top: 0;
  right: 16px;
  z-index: 1000;
  background: #fff;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-top: 16px;
}

.message-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  min-width: 280px;
}

.message-search-input {
  flex: 1;
}

.message-search-navigation {
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-results-info {
  font-size: 12px;
  min-width: 40px;
  text-align: center;
  white-space: nowrap;
}

/* Search Highlight Styles */
.search-highlight {
  background-color: #ffeb3b !important;
  color: #000 !important;
  padding: 0 2px !important;
  border-radius: 2px !important;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.search-highlight.current-match {
  background-color: #ff6b35 !important;
  color: #fff !important;
  font-weight: 500;
  box-shadow: 0 0 0 1px rgba(255, 107, 53, 0.3);
}

/* Ensure search highlights work in markdown content */
.markdown-body .search-highlight {
  background-color: #ffeb3b !important;
  color: #000 !important;
}

.markdown-body .search-highlight.current-match {
  background-color: #ff6b35 !important;
  color: #fff !important;
}

/* 确保搜索高亮在各种上下文中都能正确显示 */
.ant-typography .search-highlight,
.ant-card .search-highlight,
pre .search-highlight,
code .search-highlight {
  background-color: #ffeb3b !important;
  color: #000 !important;
  padding: 0 2px !important;
  border-radius: 2px !important;
}

.ant-typography .search-highlight.current-match,
.ant-card .search-highlight.current-match,
pre .search-highlight.current-match,
code .search-highlight.current-match {
  background-color: #ff6b35 !important;
  color: #fff !important;
}
