/*
 * Custom styles for 经济金融AI智能体设计 textbook
 * Based on lianxhcn/research_with_AI styling
 */

/* Base font size */
html {
  font-size: 15px;
}

body {
  font-size: 1rem;
}

/* Title Block */
.quarto-meta-block {
  display: grid;
  grid-template-columns: 50% 50%;
}

.quarto-meta {
  margin-bottom: 1.4em;
}

.quarto-meta-padded {
  padding-top: .4em;
}

.quarto-meta p.quarto-meta-title {
  text-transform: uppercase;
  font-size: 0.8em;
}

.quarto-meta p {
  margin-top: 0;
  margin-bottom: 0;
}

.quarto-frontmatter {
  font-size: 0.9em !important;
  line-height: 0.9em !important;
}

pre.quarto-frontmatter-container {
  border: solid var(--vscode-panel-border) 1px;
  width: calc(100% - 1.1em);
  padding: 0.5em 0 0.5em 0.5em!important;
  margin-right: 0.6em;
}

.quarto-abstract {
  padding-top: 0.5em;
}

/* Decorated Divs */
pre {
  padding: 0.5em;
  border: solid var(--vscode-panel-border) 1px;
  width: calc(100% - 1.6em)
}

.quarto-div {
  border: solid 1px var(--vscode-panel-border);
  border-radius: 3px;
  background-color: #EEEEEE11;
  color: var(--vscode-foreground);
  padding: 1em;
  margin-bottom: 1em;
  box-sizing: border-box;
  width: calc(100% - 0.6em);
}

.quarto-attribute-decorator + h1,
.quarto-attribute-decorator + h2,
.quarto-attribute-decorator + h3,
.quarto-attribute-decorator + h4,
.quarto-attribute-decorator + h5,
.quarto-attribute-decorator + h6,
.quarto-attribute-decorator + pre {
  margin-top: 0 !important;
}

.quarto-attribute-decorator.quarto-heading-attribute-decorator {
  transform: translateY(2em);
}

.quarto-attribute-decorator {
  margin-top: var(--jp-content-heading-margin-top);
  padding-right: 1em;
  display: flex;
  justify-content: right;
  background-color: transparent;
  font-size: 0.7em;
  transform: translateY(1em);
}

.quarto-attribute-decorator .quarto-attribute-decorator-content {
  border: solid var(--vscode-panel-border) 1px;
  background-color: var(--theme-input-background);
  border-radius: 20px;
  margin-right: 1.5em;
  padding-bottom: 2px;
  padding-left: 7px;
  padding-right: 7px;
  white-space: nowrap;
}

/* 控制章节标题与上下元素的间距 */
h1.title,
h1.anchored {
  margin-top: 0.8em;
  margin-bottom: 0.7em;
}

/* Code Blocks */
.jp-RenderedHTMLCommon pre,
.jp-RenderedHTMLCommon > pre {
  margin-left: .1em;
  margin-right: 0;
  padding: 0.2em;
  border: solid 1px var(--vscode-panel-border);
  border-radius: 3px;
}

/* Tables */
.quarto-rendered-md.jp-RenderedHTMLCommon table {
  margin-left: inherit;
  margin-right: inherit;
}

/* Callouts - 提示框、警示框等 */
.callout {
  margin-top: 1em;
  margin-bottom: 1em;
  border-radius: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
  width: 100%;
  border-left: 6px solid #ccc;
  background-color: #f9f9f9;
  padding: 0;
  overflow: hidden;
}

.callout-header {
  display: flex;
  align-items: center;
  padding: 0.6em 1em;
  font-weight: bold;
  font-size: 1rem;
}

.callout-body {
  padding: 0.8em 1em;
  line-height: 1.6;
}

/* Callout 类型样式 */
div.callout-important {
  border-left-color: #d9534f;
}
div.callout-important .callout-header {
  background-color: #f7dddc;
  color: #a94442;
}

div.callout-note {
  border-left-color: #4582ec;
}
div.callout-note .callout-header {
  background-color: #dae6fb;
  color: #305fdd;
}

div.callout-warning {
  border-left-color: #f0ad4e;
}
div.callout-warning .callout-header {
  background-color: #fcefdc;
  color: #8a6d3b;
}

div.callout-tip {
  border-left-color: #02b875;
}
div.callout-tip .callout-header {
  background-color: #ccf1e3;
  color: #1e7e34;
}

div.callout-caution {
  border-left-color: #fd7e14;
}
div.callout-caution .callout-header {
  background-color: #ffe5d0;
  color: #995700;
}

/* 自定义提示词对话框 */
div.callout-prompt {
  border-left-color: #881a86;
}
div.callout-prompt .callout-header {
  background-color: #ece6ee;
  color: #ba17c9;
}

/* Shortcodes */
span.shortcode {
  font-family: var(--jp-code-font-family);
  line-height: var(--jp-code-line-height);
  background: var(--vscode-textPreformat-background);
  color: var(--vscode-textPreformat-foreground);
  padding-left: 1px;
  padding-right: 1px;
  white-space: pre-wrap;
}

/* Footnotes */
hr.footnotes-sep {
  width: calc(100% - 0.6em);
}

/* 控制代码块与输出结果之间的垂直间距 */
div.cell > div.cell-output,
div.cell > div.cell-output-display,
div.cell-output-stdout {
  margin-top: 0.1em !important;
  margin-bottom: 0.1em !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.cell-output-stdout pre {
  font-size: 0.95em;
  line-height: 1.3;
  margin: 0;
  padding: 0;
}

/* Mermaid 图只显示渲染结果，不显示 Quarto 自动附带的源码面板 */
.cell:has(.cell-output-display svg) > .code-copy-outer-scaffold {
  display: none;
}

/* ========================================
   自定义代码块：opencode / agent / skill
   ======================================== */

/* --- 共享基础样式 --- */
.custom-code-block {
  position: relative;
  margin: 1.2em 0;
  border-left: 4px solid #ccc;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.custom-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4em 0.8em;
  border-bottom: 1px solid #e5e5e5;
}

.custom-code-label {
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-family: system-ui, -apple-system, sans-serif;
}

.custom-code-copy {
  font-size: 0.72em;
  padding: 0.2em 0.6em;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-family: system-ui, -apple-system, sans-serif;
  transition: all 0.2s ease;
}

.custom-code-copy.copied {
  background: #059669 !important;
  color: #fff !important;
  border-color: #059669 !important;
}

.custom-code-block pre {
  margin: 0 !important;
  padding: 0.8em 1em !important;
  border: none !important;
  border-radius: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
}

.custom-code-block pre code {
  font-size: 0.95em;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* --- Claude Code 提示词 (橙色) --- */
.opencode-block {
  border-left-color: #e07a3a;
  border: 1px solid #f5c5a0;
  border-left: 4px solid #e07a3a;
}
.opencode-block .custom-code-header {
  background: linear-gradient(135deg, #fff0e5 0%, #fde4d0 100%);
  border-bottom-color: #f5c5a0;
}
.opencode-block .custom-code-label { color: #c45a1a; }
.opencode-block .custom-code-copy {
  color: #c45a1a;
  border-color: #f0b890;
}
.opencode-block .custom-code-copy:hover {
  background: #e07a3a;
  color: #fff;
  border-color: #e07a3a;
}
.opencode-block pre { background: #fff8f2 !important; }
.opencode-block pre code { color: #6b3410; }

/* --- Agent 配置 (蓝色) --- */
.agent-block {
  border-left-color: #2563eb;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
}
.agent-block .custom-code-header {
  background: linear-gradient(135deg, #e0eeff 0%, #d0e2ff 100%);
  border-bottom-color: #bfdbfe;
}
.agent-block .custom-code-label { color: #1d4ed8; }
.agent-block .custom-code-copy {
  color: #1d4ed8;
  border-color: #93c5fd;
}
.agent-block .custom-code-copy:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.agent-block pre { background: #f0f5ff !important; }
.agent-block pre code { color: #1e3a5f; }

/* --- Skill 定义 (绿色) --- */
.skill-block {
  border-left-color: #059669;
  border: 1px solid #a7f3d0;
  border-left: 4px solid #059669;
}
.skill-block .custom-code-header {
  background: linear-gradient(135deg, #d1fae5 0%, #c4f0da 100%);
  border-bottom-color: #a7f3d0;
}
.skill-block .custom-code-label { color: #047857; }
.skill-block .custom-code-copy {
  color: #047857;
  border-color: #6ee7b7;
}
.skill-block .custom-code-copy:hover {
  background: #059669;
  color: #fff;
  border-color: #059669;
}
.skill-block pre { background: #f0fdf4 !important; }
.skill-block pre code { color: #14532d; }

/* --- OpenClaw 管家消息 (紫色 + 全圆角 + 虚线边) --- */
.openclaw-block {
  border: 1px dashed #c4b5fd;
  border-left: 5px dashed #7c3aed;
  border-radius: 10px;
}
.openclaw-block .custom-code-header {
  background: linear-gradient(135deg, #f3efff 0%, #e4dafd 100%);
  border-bottom: 1px dashed #c4b5fd;
}
.openclaw-block .custom-code-label { color: #5b21b6; }
.openclaw-block .custom-code-copy {
  color: #5b21b6;
  border-color: #c4b5fd;
}
.openclaw-block .custom-code-copy:hover {
  background: #7c3aed;
  color: #fff;
  border-color: #7c3aed;
}
.openclaw-block pre { background: #faf7ff !important; }
.openclaw-block pre code { color: #3b0764; }

/* ========================================
   终端窗口样式：bash
   ======================================== */

.terminal-block {
  position: relative;
  margin: 1.2em 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid #1a1a2e;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6em 0.8em;
  background: #2d2d3d;
  border-bottom: 1px solid #1a1a2e;
}

.terminal-dots {
  display: flex;
  gap: 7px;
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-dot.red { background: #ff5f57; }
.terminal-dot.yellow { background: #febc2e; }
.terminal-dot.green { background: #28c840; }

.terminal-copy {
  font-size: 0.72em;
  padding: 0.2em 0.6em;
  border: 1px solid #555;
  border-radius: 4px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  font-family: system-ui, -apple-system, sans-serif;
  transition: all 0.2s ease;
}

.terminal-copy:hover {
  background: #555;
  color: #fff;
  border-color: #777;
}

.terminal-copy.copied {
  background: #059669 !important;
  color: #fff !important;
  border-color: #059669 !important;
}

.terminal-block pre {
  margin: 0 !important;
  padding: 1em 1.2em !important;
  border: none !important;
  border-radius: 0 !important;
  width: 100% !important;
  box-sizing: border-box;
  background: #1e1e2e !important;
}

.terminal-block pre code {
  font-size: 0.95em;
  line-height: 1.6;
  color: #cdd6f4;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ========================================
   微信对话样式：wechat
   ======================================== */

.wechat-chat {
  margin: 1.2em 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  border: 1px solid #d6d6d6;
  max-width: 420px;
  font-family: -apple-system, "SF Pro SC", "SF Pro Text", "Helvetica Neue", "PingFang SC", sans-serif;
}

.wechat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6em 1em;
  background: #ededed;
  border-bottom: 1px solid #d6d6d6;
}

.wechat-topbar-back {
  font-size: 1.3em;
  color: #07c160;
  font-weight: 300;
}

.wechat-topbar-title {
  font-size: 0.95em;
  font-weight: 600;
  color: #191919;
}

.wechat-topbar-more {
  font-size: 1.2em;
  color: #191919;
  letter-spacing: 2px;
}

.wechat-body {
  background: #ededed;
  padding: 0.8em 0.6em;
  display: flex;
  flex-direction: column;
  gap: 0.7em;
  min-height: 60px;
}

.wechat-msg {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  max-width: 88%;
}

.wechat-msg-left {
  align-self: flex-start;
  flex-direction: row;
}

.wechat-msg-right {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.wechat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.wechat-bubble {
  position: relative;
  padding: 0.55em 0.75em;
  border-radius: 6px;
  font-size: 0.88em;
  line-height: 1.55;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.wechat-msg-left .wechat-bubble {
  background: #fff;
  color: #191919;
}

.wechat-msg-left .wechat-bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 10px;
  border: 6px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}

.wechat-msg-right .wechat-bubble {
  background: #95ec69;
  color: #191919;
}

.wechat-msg-right .wechat-bubble::before {
  content: "";
  position: absolute;
  right: -6px;
  top: 10px;
  border: 6px solid transparent;
  border-left-color: #95ec69;
  border-right: 0;
}

/* --- 深色模式 --- */
@media (prefers-color-scheme: dark) {
  .custom-code-copy.copied {
    background: #059669 !important;
  }
  /* Claude Code 深色 */
  .opencode-block { border-color: #6b3a1e; border-left-color: #f09860; }
  .opencode-block .custom-code-header { background: linear-gradient(135deg, #3a2010 0%, #2a1508 100%); border-bottom-color: #6b3a1e; }
  .opencode-block .custom-code-label { color: #f0b890; }
  .opencode-block .custom-code-copy { background: #2a1508; color: #f0b890; border-color: #6b3a1e; }
  .opencode-block .custom-code-copy:hover { background: #e07a3a; color: #fff; }
  .opencode-block pre { background: #1a0e05 !important; }
  .opencode-block pre code { color: #fde4d0; }

  /* Agent 深色 */
  .agent-block { border-color: #1e3a5f; border-left-color: #60a5fa; }
  .agent-block .custom-code-header { background: linear-gradient(135deg, #1e2d4a 0%, #0f1d33 100%); border-bottom-color: #1e3a5f; }
  .agent-block .custom-code-label { color: #93c5fd; }
  .agent-block .custom-code-copy { background: #0f1d33; color: #93c5fd; border-color: #1e3a5f; }
  .agent-block .custom-code-copy:hover { background: #3b82f6; color: #fff; }
  .agent-block pre { background: #0b1529 !important; }
  .agent-block pre code { color: #bfdbfe; }

  /* Skill 深色 */
  .skill-block { border-color: #064e3b; border-left-color: #34d399; }
  .skill-block .custom-code-header { background: linear-gradient(135deg, #0d3025 0%, #06201a 100%); border-bottom-color: #064e3b; }
  .skill-block .custom-code-label { color: #6ee7b7; }
  .skill-block .custom-code-copy { background: #06201a; color: #6ee7b7; border-color: #064e3b; }
  .skill-block .custom-code-copy:hover { background: #10b981; color: #fff; }
  .skill-block pre { background: #041410 !important; }
  .skill-block pre code { color: #a7f3d0; }

  /* OpenClaw 深色 */
  .openclaw-block { border: 1px dashed #4c1d95; border-left: 5px dashed #a78bfa; }
  .openclaw-block .custom-code-header { background: linear-gradient(135deg, #2e1065 0%, #1e1038 100%); border-bottom: 1px dashed #4c1d95; }
  .openclaw-block .custom-code-label { color: #c4b5fd; }
  .openclaw-block .custom-code-copy { background: #1e1038; color: #c4b5fd; border-color: #4c1d95; }
  .openclaw-block .custom-code-copy:hover { background: #7c3aed; color: #fff; }
  .openclaw-block pre { background: #140826 !important; }
  .openclaw-block pre code { color: #e9d5ff; }

  /* WeChat 深色 */
  .wechat-chat { border-color: #333; }
  .wechat-topbar { background: #2c2c2c; border-bottom-color: #333; }
  .wechat-topbar-back { color: #07c160; }
  .wechat-topbar-title { color: #e0e0e0; }
  .wechat-topbar-more { color: #e0e0e0; }
  .wechat-body { background: #1e1e1e; }
  .wechat-avatar { background: #333; }
  .wechat-msg-left .wechat-bubble { background: #2c2c2c; color: #e0e0e0; }
  .wechat-msg-left .wechat-bubble::before { border-right-color: #2c2c2c; }
  .wechat-msg-right .wechat-bubble { background: #2a6e2a; color: #e0e0e0; }
  .wechat-msg-right .wechat-bubble::before { border-left-color: #2a6e2a; }
}
