/* isdp/web/src/components/thread/MessageContent.css */

.message-content-wrapper {
  width: 100%;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: normal;
  word-break: break-word;
}

/* 段落 */
.message-paragraph {
  margin: 0 0 8px 0;
}

.message-paragraph:last-child {
  margin-bottom: 0;
}

/* 标题 */
.message-h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 16px 0 8px 0;
}

.message-h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 12px 0 6px 0;
}

.message-h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 10px 0 4px 0;
}

/* 行内代码 */
.inline-code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  color: #d73a49;
}

/* 代码块 */
.code-block-wrapper {
  margin: 12px 0;
  position: relative;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #21252b;
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid #333;
}

.code-block-lang {
  font-size: 11px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  color: #5c6370;
  text-transform: lowercase;
}

.code-block-wrapper:hover .code-copy-btn {
  opacity: 1;
}

/* 当有 header 时，圆角只在底部 */
.code-block-wrapper:has(.code-block-header) .code-block {
  border-radius: 0 0 6px 6px;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 12px;
  background: #444;
  border: none;
  border-radius: 4px;
  color: #ccc;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.code-copy-btn:hover {
  background: #555;
  color: #fff;
}

.code-block {
  margin: 0 !important;
  padding: 12px 16px !important;
  background: #282c34 !important;
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #abb2bf;
}

.code-block code {
  background: transparent !important;
  padding: 0 !important;
  font-family: inherit;
  color: inherit;
}

/* 图片 */
.message-image-wrapper {
  margin: 12px 0;
}

.message-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 6px;
}

.message-image-caption {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 链接 */
.message-link {
  color: #0366d6;
  text-decoration: none;
}

.message-link:hover {
  text-decoration: underline;
}

/* 引用块 */
.message-blockquote {
  margin: 8px 0;
  padding: 8px 16px;
  border-left: 3px solid #dfe2e5;
  background: #f9f9f9;
  color: #666;
}

.message-blockquote p {
  margin: 0;
}

/* 列表 */
.message-list {
  margin: 8px 0;
  padding-left: 20px;
}

.message-list li {
  margin: 2px 0;
}

/* 表格 */
.message-table-wrapper {
  margin: 12px 0;
  overflow-x: auto;
}

.message-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.message-table th,
.message-table td {
  padding: 6px 12px;
  border: 1px solid #dfe2e5;
  text-align: left;
}

.message-table th {
  background: #f6f8fa;
  font-weight: 600;
}

/* 分隔线 */
.message-content-wrapper hr {
  margin: 12px 0;
  border: none;
  border-top: 1px solid #e1e4e8;
}

/* 深色主题 */
[data-theme='dark'] .inline-code {
  background: #2d333b;
  color: #f97583;
}

[data-theme='dark'] .code-block {
  background: #1c2128 !important;
}

[data-theme='dark'] .message-blockquote {
  background: #2d333b;
  border-left-color: #444c56;
}

[data-theme='dark'] .message-table th {
  background: #2d333b;
}

[data-theme='dark'] .message-link {
  color: #79b8ff;
}