.thread-view-wrapper {
  display: flex;
  height: 100%;
  background: var(--gradient-bg, var(--bg-base));
  margin: -16px;
  position: relative;
}

/* 微妙的网格背景纹理 */
.thread-view-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 25px 25px, var(--border-light) 1px, transparent 1px);
  background-size: 50px 50px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

/* 确保内容在纹理之上 */
.thread-view-wrapper > * {
  position: relative;
  z-index: 1;
}

.file-sidebar {
  width: 280px;
  min-width: 280px;
  height: 100%;
  border-right: 1px solid var(--border-color);
  background: var(--bg-container);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* 文件树上方的工作目录显示 */
.file-sidebar-path {
  padding: 8px 12px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-sidebar-path .path-label {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.file-sidebar-path .path-value {
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}

.file-sidebar .file-tree-wrapper {
  flex: 1;
  overflow: hidden;
}

/* 右侧边栏 - 沙箱/产物 */
.right-sidebar {
  width: 50%;
  min-width: 400px;
  max-width: 800px;
  height: 100%;
  border-left: 1px solid var(--border-color);
  background: var(--bg-container);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* 产物侧边栏 - 固定宽度 350px */
.artifacts-sidebar {
  width: 350px;
  min-width: 300px;
  max-width: 450px;
  height: 100%;
  border-left: 1px solid var(--border-color);
  background: var(--bg-container);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.artifacts-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-sidebar);
  font-weight: 500;
  flex-shrink: 0;
}

.artifacts-sidebar-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.right-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-sidebar);
  flex-shrink: 0;
}

.right-sidebar-tabs {
  display: flex;
  gap: 8px;
}

.right-sidebar-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thread-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-width: 0;
}

/* 干预控制条 */
.intervention-bar {
  padding: 10px 20px;
  background: var(--bg-container);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}

/* 消息区域 */
.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  padding-right: 32px;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative; /* 为指示器提供定位基准 */
}

/* 自定义滚动条 */
.thread-messages::-webkit-scrollbar {
  width: 6px;
}

.thread-messages::-webkit-scrollbar-track {
  background: transparent;
}

.thread-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.thread-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* 深色模式滚动条 */
[data-theme='dark'] .thread-messages::-webkit-scrollbar-track {
  background: transparent;
}

[data-theme='dark'] .thread-messages::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

[data-theme='dark'] .thread-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* 空状态 */
.thread-messages .ant-empty {
  margin: 0;
}

/* 消息样式增强 */
.message-container {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
  width: 100%;
}

/* 用户消息 - 右边 (微信风格) */
.message-container-user {
  flex-direction: row;
  justify-content: flex-end;
}

/* Agent消息 - 左边 */
.message-container-agent {
  flex-direction: row;
  justify-content: flex-start;
}

.message {
  display: flex;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--bg-container);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 2px 6px rgba(0, 0, 0, 0.02);
  transition: all 0.25s ease;
  max-width: 75%;
  border: 1px solid var(--border-light);
}

.message:hover {
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04);
  transform: translateY(-2px);
  border-color: var(--color-primary-opacity-20);
}

/* Avatar positioning */
.message-avatar {
  flex-shrink: 0;
  margin: 0 12px;
}

.message-avatar .ant-avatar {
  width: 40px;
  height: 40px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Agent消息 - 左边，简洁风格 */
.message-agent {
  background: var(--bg-container);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.message-agent:hover {
  border-color: var(--color-primary-opacity-30);
}

/* 用户消息 - 右边分布，内容左对齐 */
.message-user {
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-opacity-20);
  border-radius: 16px;
  border-bottom-right-radius: 4px;
}

.message-user .message-role {
  color: var(--text-primary);
}

.message-user .message-time {
  color: var(--text-secondary);
}

.message-user .message-body {
  text-align: left;
}

.message-system {
  background: var(--bg-sidebar);
  border: 1px dashed var(--border-color);
  padding: 8px;
  max-width: 100%;
  margin-bottom: 16px;
}

.message-system .system-message-content {
  width: 100%;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* 用户消息的header左对齐 */
.message-user .message-header {
  justify-content: flex-start;
  gap: 12px;
}

.message-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.message-action-btn {
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 2px 6px;
  margin-left: 4px;
}

.message:hover .message-action-btn {
  opacity: 1;
}

.message-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* 流式消息的终止按钮始终可见 */
.message.streaming .message-action-btn {
  opacity: 1;
}

/* 流式消息样式 - 保持颜色一致 */
.message.streaming {
  /* 不改变颜色，只添加终止按钮可见性 */
}

.message-role {
  font-weight: 600;
  color: var(--color-primary);
  font-size: 14px;
}

.message-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 12px;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
}

/* @mention 下拉列表 */
.mention-dropdown {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  background: var(--bg-container);
  max-height: 300px;
  overflow: hidden;
}

.mention-dropdown .ant-card-body {
  padding: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.mention-dropdown .ant-list-item {
  border-radius: 4px;
  margin-bottom: 4px !important;
}

/* @mention 列表项悬停样式 - 支持深色主题 */
.mention-list-item:hover {
  background: var(--color-primary-opacity-10) !important;
}

/* 产物卡片在消息中 */
.artifact-card-in-message,
.review-card-in-message {
  border-radius: 8px;
  cursor: pointer;
}

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

/* 输入区域 */
.thread-input {
  display: flex;
  gap: 12px;
  padding: 16px 24px 20px;
  border-top: none;
  background: var(--bg-container);
  flex-shrink: 0;
  position: relative;
}

/* 输入区域上方的渐变遮罩 */
.thread-input::before {
  content: '';
  position: absolute;
  top: -24px;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(to bottom, transparent, var(--bg-container));
  pointer-events: none;
}

.thread-input .ant-input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  font-size: 14px;
  transition: all 0.25s ease;
  background: var(--bg-sidebar);
}

.thread-input .ant-input:hover {
  border-color: var(--color-primary-opacity-40);
}

.thread-input .ant-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-opacity-10);
  background: var(--bg-container);
}

/* 发送按钮 */
.thread-input .ant-btn-primary {
  height: auto;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 500;
  box-shadow: 0 2px 8px var(--color-primary-opacity-30);
  transition: all 0.25s ease;
}

.thread-input .ant-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--color-primary-opacity-40);
}

/* 运行中 Agent - 使用主题色 */
.active-agents {
  padding: 8px 16px;
  background: linear-gradient(90deg, var(--color-primary-light) 0%, var(--color-primary-bg) 100%);
  border-top: 1px solid var(--color-primary-border);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.active-agents span {
  font-weight: 600;
  color: var(--color-primary);
}

/* 产物卡片样式 */
.artifact-card-item {
  transition: all 0.3s ease;
  cursor: pointer;
  padding: 12px !important;
}

.artifact-card-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background: var(--bg-sidebar);
}

.artifact-panel .ant-collapse-header {
  font-weight: 600 !important;
}

/* 审查报告样式 */
.review-report .ant-collapse-header {
  font-weight: 600 !important;
}

.review-report .ant-alert {
  border-radius: 8px;
}

/* 系统消息样式 */
.system-message .ant-alert {
  border-radius: 8px;
  margin-bottom: 12px !important;
}

/* 进度条样式 - 使用主题色 */
.enhanced-progress .ant-steps-item-process .ant-steps-item-icon {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.enhanced-progress .ant-steps-item-finish .ant-steps-item-icon {
  border-color: var(--color-primary);
}

.enhanced-progress .ant-steps-item-icon {
  transition: all 0.3s ease;
}

/* 检查点弹窗样式 */
.ant-modal-content .ant-alert {
  margin-bottom: 16px;
}

/* 动画效果 */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  animation: slideIn 0.3s ease;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .file-sidebar {
    display: none;
  }

  .thread-view {
    height: 100%;
  }

  .intervention-bar {
    padding: 8px;
  }

  .thread-input {
    padding: 12px;
  }

  .message {
    padding: 12px;
    max-width: 85%;
  }

  .message-avatar .ant-avatar {
    width: 32px;
    height: 32px;
  }

  .message-avatar {
    margin: 0 8px;
  }
}

/* 流式消息光标动画 - 使用主题色 */
.streaming-cursor {
  display: inline-block;
  color: var(--color-primary);
  animation: blink 1s infinite;
  font-weight: bold;
}

@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  51%, 100% {
    opacity: 0;
  }
}

/* ========== 拖拽调整条样式 ========== */

.resize-handle {
  width: 6px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s ease;
  z-index: 10;
}

.resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: var(--border-color);
  border-radius: 1px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.resize-handle:hover {
  background: var(--color-primary-opacity-10);
}

.resize-handle:hover::after {
  opacity: 1;
  background: var(--color-primary);
}

.resize-handle.resizing {
  background: var(--color-primary-opacity-20);
}

.resize-handle.resizing::after {
  opacity: 1;
  background: var(--color-primary);
}

/* 拖拽遮罩层 - 防止iframe捕获鼠标事件 */
.resize-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: transparent;
  cursor: col-resize;
}

/* ========== 深色主题优化 ========== */

[data-theme='dark'] .thread-view-wrapper::before {
  opacity: 0.3;
}

[data-theme='dark'] .message-agent {
  background: var(--bg-container);
  border-color: var(--border-color);
}

[data-theme='dark'] .message-agent:hover {
  border-color: var(--color-primary-opacity-40);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme='dark'] .message-user {
  background: var(--color-primary-opacity-10);
  border-color: var(--color-primary-opacity-20);
}

[data-theme='dark'] .message-user:hover {
  border-color: var(--color-primary-opacity-30);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme='dark'] .thread-input {
  background: var(--bg-container);
}

[data-theme='dark'] .thread-input::before {
  background: linear-gradient(to bottom, transparent, var(--bg-container));
}

[data-theme='dark'] .thread-input .ant-input {
  background: var(--bg-elevated);
  border-color: var(--border-color);
}

[data-theme='dark'] .thread-input .ant-input:hover {
  border-color: var(--color-primary-opacity-40);
}

[data-theme='dark'] .thread-input .ant-input:focus {
  background: var(--bg-container);
  border-color: var(--color-primary);
}

/* ========== 流式消息优化 ========== */

/* 流式消息不应用动画，避免闪烁 */
.message.streaming {
  animation: none;
}

/* 空状态优化 */
.thread-messages > div:only-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

/* ========== 消息滚动指示器样式 ========== */

/* 消息滚动指示器容器 */
.message-scroll-indicators {
  position: absolute;
  right: 8px;
  top: 10px; /* 避免覆盖顶部按钮区域 */
  width: 24px;
  height: calc(100% - 20px); /* 上下留出空间 */
  pointer-events: auto;
  z-index: 10;
}

.indicator-item {
  position: absolute;
  right: 4px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.indicator-item .ant-avatar {
  border: 1px solid var(--border-color);
  background: var(--bg-container);
}

/* 深色模式适配 - Avatar 背景 */
[data-theme='dark'] .indicator-item .ant-avatar {
  background: var(--bg-container);
  border-color: var(--border-color);
}