/*
 * Markdown themes + chrome styles for AIChatView.
 * The apboa theme is adapted from:
 * https://gitee.com/studioustiger/apboa/raw/master/ui/src/styles/markdown.scss
 */

/* ----- Chrome (title / user bubble / composer) ----- */

.ht-ui-aichat-title {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: #30333a;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  user-select: text;
}

.ht-ui-aichat-user-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 14px 22px;
  border-radius: 16px;
  background: #eef4ff;
  color: #30333a;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.42;
}

.ht-ui-aichat-composer .ht_ui_textarea {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif !important;
  font-size: 12px !important;
  line-height: 1.42 !important;
}

.ht-ui-aichat-history-item {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  color: #30333a;
  font: 13px/38px Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  cursor: pointer;
  user-select: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 120ms ease;
}

.ht-ui-aichat-history-item:hover {
  background: #eef0f4;
}

.ht-ui-aichat-history-item.selected,
.ht-ui-aichat-history-item.selected:hover {
  background: #e3edff;
  color: #1476ff;
  font-weight: 600;
}

.ht-ui-aichat-history-item.selected:hover {
  background: #dbe6ff;
}

.ht-ui-aichat-attachment-list {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 12px;
  line-height: 1.35;
  color: #4b5563;
  white-space: nowrap;
}

.ht-ui-aichat-attachment {
  display: inline-flex;
  align-items: center;
  max-width: 180px;
  margin: 0 8px 6px 0;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  vertical-align: top;
}

.ht-ui-aichat-attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.ht-ui-aichat-attachment-remove {
  margin-left: 8px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.ht-ui-aichat-attachment-remove:hover {
  color: #ef4444;
}

/* ----- Markdown root ----- */

.ht-ui-aichat-md {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: normal;
}

.ht-ui-aichat-md-theme-apboa {
  color: #2b2d33;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.7;
}

.ht-ui-aichat-md-theme-apboa .md-heading {
  position: relative;
  margin: 1em 0 0.6em;
  font-weight: 600;
  line-height: 1.35;
}

.ht-ui-aichat-md-theme-apboa .md-h1 {
  font-size: 1.6em;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.3em;
}

.ht-ui-aichat-md-theme-apboa .md-h2 {
  font-size: 1.35em;
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 0.25em;
}

.ht-ui-aichat-md-theme-apboa .md-h3 { font-size: 1.15em; }
.ht-ui-aichat-md-theme-apboa .md-h4 { font-size: 1.05em; }
.ht-ui-aichat-md-theme-apboa .md-h5 { font-size: 1em; }
.ht-ui-aichat-md-theme-apboa .md-h6 { font-size: 0.95em; color: #666; }

.ht-ui-aichat-md-theme-apboa p {
  margin: 0 0 0.75em;
}

.ht-ui-aichat-md-theme-apboa p:last-child {
  margin-bottom: 0;
}

.ht-ui-aichat-md-theme-apboa strong {
  color: #1a1a1a;
  font-weight: 700;
}

.ht-ui-aichat-md-theme-apboa em {
  color: #444;
  font-style: italic;
}

.ht-ui-aichat-md-theme-apboa .md-code-block {
  position: relative;
  margin: 0.8em 0;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  overflow: hidden;
  background-color: #f8f9fa;
}

.ht-ui-aichat-md-theme-apboa .md-code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: none;
}

.ht-ui-aichat-md-theme-apboa .md-code-block pre code {
  padding: 0;
  background: none;
  color: #24292e;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 0.88em;
  line-height: 1.6;
}

.ht-ui-aichat-md-theme-apboa .md-inline-code {
  padding: 0.15em 0.45em;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.06);
  color: #d63384;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.88em;
  word-break: break-word;
}

.ht-ui-aichat-md-theme-apboa .md-blockquote {
  margin: 0.8em 0;
  padding: 0.6em 1em;
  border-left: 4px solid #0f74ff;
  border-radius: 0 6px 6px 0;
  background-color: rgba(15, 116, 255, 0.04);
  color: #555;
}

.ht-ui-aichat-md-theme-apboa .md-blockquote p:last-child {
  margin-bottom: 0;
}

.ht-ui-aichat-md-theme-apboa .md-table-wrapper {
  margin: 0.8em 0;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  overflow-x: auto;
}

.ht-ui-aichat-md-theme-apboa .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}

.ht-ui-aichat-md-theme-apboa .md-table th {
  padding: 10px 14px;
  border-bottom: 1px solid #e8e8e8;
  background-color: #fafafa;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.ht-ui-aichat-md-theme-apboa .md-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f0f0f0;
}

.ht-ui-aichat-md-theme-apboa .md-table tbody tr:hover {
  background-color: rgba(15, 116, 255, 0.03);
}

.ht-ui-aichat-md-theme-apboa .md-table tbody tr:last-child td {
  border-bottom: none;
}

.ht-ui-aichat-md-theme-apboa ul,
.ht-ui-aichat-md-theme-apboa ol {
  margin: 0.5em 0;
  padding-left: 1.6em;
}

.ht-ui-aichat-md-theme-apboa li {
  margin: 0.25em 0;
}

.ht-ui-aichat-md-theme-apboa ul { list-style-type: disc; }
.ht-ui-aichat-md-theme-apboa ul ul { list-style-type: circle; }
.ht-ui-aichat-md-theme-apboa ul ul ul { list-style-type: square; }
.ht-ui-aichat-md-theme-apboa ol { list-style-type: decimal; }

.ht-ui-aichat-md-theme-apboa .md-hr {
  height: 1px;
  margin: 1.5em 0;
  border: none;
  background: linear-gradient(to right, transparent, #ddd, transparent);
}

.ht-ui-aichat-md-theme-apboa .md-link {
  color: #0f74ff;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.ht-ui-aichat-md-theme-apboa .md-link:hover {
  border-bottom-color: #0f74ff;
}

.ht-ui-aichat-md-theme-compact {
  color: #2b2d33;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.62;
}

.ht-ui-aichat-md-theme-compact p { margin: 0 0 12px; }

.ht-ui-aichat-md-theme-compact .md-heading {
  margin: 20px 0 10px;
  color: #202124;
  font-weight: 800;
  line-height: 1.32;
}

.ht-ui-aichat-md-theme-compact .md-h1 {
  margin-top: 0;
  font-size: 18px;
  text-align: center;
}

.ht-ui-aichat-md-theme-compact .md-h2 { font-size: 16px; }
.ht-ui-aichat-md-theme-compact .md-h3 { font-size: 14px; }

.ht-ui-aichat-md-theme-compact ul,
.ht-ui-aichat-md-theme-compact ol {
  margin: 0 0 14px 24px;
  padding: 0;
}

.ht-ui-aichat-md-theme-compact li {
  margin: 4px 0;
  padding-left: 4px;
}

.ht-ui-aichat-md-theme-compact .md-inline-code {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 7px;
  border-radius: 5px;
  background: #f1f1f1;
  color: #e62f8b;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 0.9em;
  line-height: 1.32;
}

.ht-ui-aichat-md-theme-compact .md-code-block {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border: 1px solid #ebedf0;
  border-radius: 8px;
  overflow: auto;
  background: #f7f8fa;
}

.ht-ui-aichat-md-theme-compact .md-code-block pre {
  margin: 0;
}

.ht-ui-aichat-md-theme-compact .md-code-block code {
  display: block;
  margin: 0;
  padding: 0;
  background: transparent;
  color: #24272e;
  font-size: 12px;
  line-height: 1.55;
}

.ht-ui-aichat-md-theme-compact .md-blockquote {
  margin: 14px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid #d9e3f7;
  color: #5c6470;
}

.ht-ui-aichat-md-theme-compact .md-table-wrapper {
  margin: 14px 0 16px;
  overflow-x: auto;
}

.ht-ui-aichat-md-theme-compact .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ht-ui-aichat-md-theme-compact .md-table th,
.ht-ui-aichat-md-theme-compact .md-table td {
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  text-align: left;
}

.ht-ui-aichat-md-theme-compact .md-table th {
  background: #f7f8fa;
  font-weight: 700;
}

/* ----- Containers (:::tip / info / warning / danger / note) ----- */

.ht-ui-aichat-md .md-container {
  margin: 0.9em 0;
  padding: 12px 16px 12px 18px;
  border-left: 4px solid;
  border-radius: 0 8px 8px 0;
  background: rgba(15, 116, 255, 0.04);
}

.ht-ui-aichat-md .md-container-title {
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 0.95em;
}

.ht-ui-aichat-md .md-container-content > :first-child { margin-top: 0; }
.ht-ui-aichat-md .md-container-content > :last-child  { margin-bottom: 0; }

.ht-ui-aichat-md .md-container-tip     { border-color: #0f74ff; background: rgba(15, 116, 255, 0.06); }
.ht-ui-aichat-md .md-container-tip     .md-container-title { color: #0f74ff; }

.ht-ui-aichat-md .md-container-info    { border-color: #149edd; background: rgba(20, 158, 221, 0.06); }
.ht-ui-aichat-md .md-container-info    .md-container-title { color: #0f7fb3; }

.ht-ui-aichat-md .md-container-warning { border-color: #f59e0b; background: rgba(245, 158, 11, 0.08); }
.ht-ui-aichat-md .md-container-warning .md-container-title { color: #b97509; }

.ht-ui-aichat-md .md-container-danger  { border-color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.ht-ui-aichat-md .md-container-danger  .md-container-title { color: #c93030; }

.ht-ui-aichat-md .md-container-note    { border-color: #6b7280; background: rgba(107, 114, 128, 0.06); }
.ht-ui-aichat-md .md-container-note    .md-container-title { color: #4b5563; }

/* ----- Math (KaTeX wrappers) ----- */

.ht-ui-aichat-md .md-math-inline { display: inline; }

.ht-ui-aichat-md .md-math-block {
  display: block;
  margin: 0.9em 0;
  text-align: center;
  overflow-x: auto;
}

/* ----- Image ----- */

.ht-ui-aichat-md .md-image {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* ----- Code highlighting fallback (no extra rules — github.css from highlight.js handles .hljs) ----- */

@media (max-width: 900px) {
  .ht-ui-aichat-title { font-size: 15px; }
  .ht-ui-aichat-user-bubble { padding: 12px 16px; font-size: 12px; }

  .ht-ui-aichat-md-theme-apboa,
  .ht-ui-aichat-md-theme-compact {
    font-size: 12px;
  }

  .ht-ui-aichat-md-theme-apboa ul,
  .ht-ui-aichat-md-theme-apboa ol {
    padding-left: 1.2em;
  }

  .ht-ui-aichat-md-theme-compact .md-h2 {
    font-size: 15px;
  }
}
