/* ═══════════════ 对话页样式（chat + _sidebar + _messages）═══════════════ */

/* ---- 全屏布局：抵消外层 padding，铺满导航栏下方整个视口 ----
   左侧不再满铺(margin-left:0)，让侧栏左边回到 24px 内容边距、与顶部导航 logo 对齐；
   右侧/上下仍满铺(对话区灰底与页面同色，满铺不可见) ---- */
.chat-layout {
  display: flex;
  margin: -68px -24px -20px 0;
  height: 100vh;
  padding-top: 48px;
  box-sizing: border-box;
}

/* ---- 布局 ---- */
.chat-sidebar {
  width: 220px; border-right: 1px solid #e8ecf1; background: #fff;
  padding: 14px; display: flex; flex-direction: column; flex-shrink: 0;
  height: 100%; box-sizing: border-box; overflow: hidden;
}
.chat-main { flex: 1; display: flex; flex-direction: column; background: #f8f9fb; min-height: 0; }
.chat-topbar { padding: 10px 20px; border-bottom: 1px solid #e8ecf1; background: #fff; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.chat-input-bar { padding: 12px 20px; border-top: 1px solid #e8ecf1; background: #fff; flex-shrink: 0; }
.chat-input {
  font-family: inherit; flex: 1; padding: 10px 16px; border-radius: 24px;
  border: 1.5px solid #e8ecf1; font-size: 13px; outline: none; background: #f8f9fb;
}
.chat-messages { flex: 1; min-height: 0; overflow: auto; padding: 20px; }

/* ---- 浮动推荐问题 ---- */
.chat-suggest-bar {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 8px 20px; border-top: 1px solid #eef1f5; background: #fff;
}
.chat-suggest-scroll {
  display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chat-suggest-scroll::-webkit-scrollbar { display: none; }
/* 出现 / 消失渐变动画 */
.suggest-fade-enter-active, .suggest-fade-leave-active {
  transition: opacity .28s ease, transform .28s ease;
}
.suggest-fade-enter, .suggest-fade-leave-to {
  opacity: 0; transform: translateY(8px);
}
/* 单个推荐胶囊：限宽 + 省略号（hover 由原生 title 显示全文） */
.chat-suggest-pill {
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex-shrink: 0; box-sizing: border-box;
}
/* “更多”按钮 */
.msg-suggest-more { color: #6b7280; background: #f3f4f6; border-color: #e5e7eb; }
/* “更多”弹层 */
.chat-suggest-more-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 300px; overflow-y: auto; min-width: 200px; max-width: 340px; padding: 4px;
}
.chat-suggest-more-item {
  padding: 8px 12px; border-radius: 8px; font-size: 12.5px; color: #374151;
  cursor: pointer; white-space: normal; line-height: 1.55; transition: background .15s, color .15s;
}
.chat-suggest-more-item:hover { background: #eef4ff; color: #2563eb; }

/* ---- 侧栏 ---- */
.sidebar-title { font-size: 12px; font-weight: 500; color: #6b7280; }
.sidebar-ast-list { max-height: 260px; overflow-y: auto; flex-shrink: 0; }
/* 未选择助理时，助理列表撑满侧栏剩余空间；选中后恢复固定高度，给对话记录留空间 */
.sidebar-ast-list-full { max-height: none; flex: 1; min-height: 0; }
.sidebar-conv-list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 3px; }
/* 侧栏滚动条：细、淡，悬停时加深（替代系统默认的粗灰滚动条） */
.sidebar-ast-list, .sidebar-conv-list { scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sidebar-ast-list:hover, .sidebar-conv-list:hover { scrollbar-color: rgba(100, 116, 139, .35) transparent; }
.sidebar-ast-list::-webkit-scrollbar, .sidebar-conv-list::-webkit-scrollbar { width: 6px; height: 6px; }
.sidebar-ast-list::-webkit-scrollbar-track, .sidebar-conv-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-ast-list::-webkit-scrollbar-thumb, .sidebar-conv-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.sidebar-ast-list:hover::-webkit-scrollbar-thumb, .sidebar-conv-list:hover::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, .35); }
.sidebar-ast-list::-webkit-scrollbar-thumb:hover, .sidebar-conv-list::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, .55); }
.sidebar-ast-list { margin-right: -6px; padding-right: 2px; }

/* 选择助理项：hover 高亮 + 选中态 */
.chat-ast-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  background: transparent; border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease;
}
.chat-ast-item:not(.chat-ast-item-active):hover { background: #f3f4f6; }
.chat-ast-item-active { background: #eff4ff; border-color: #2563eb; }

/* 欢迎态助理快捷入口：hover 上浮高亮 */
.chat-welcome-ast {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid #e5e7eb;
  background: #fff; font-size: 13px; color: #1f2329; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.chat-welcome-ast:hover {
  transform: translateY(-2px); border-color: #2563eb;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .15);
}
/* 头像(emoji)与名称垂直居中对齐：各自 flex 居中 + 紧凑行高，避免按字体基线一高一低 */
.chat-welcome-ast > span { display: inline-flex; align-items: center; line-height: 1; }

/* 对话记录项：hover 高亮 + 选中态；删除按钮默认隐藏，行 hover 才显示 */
.chat-conv-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px; border-radius: 7px; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease;
}
.chat-conv-item:not(.chat-conv-item-active):hover { background: #f3f4f6; }
.chat-conv-item-active { background: #eff4ff; border-color: #2563eb; }

/* 删除按钮：默认透明（隐藏），行 hover 时淡入，自身 hover 变红 */
.chat-conv-del {
  color: #9ca3af; cursor: pointer;
  opacity: 0; transition: opacity .15s ease, color .15s ease;
}
.chat-conv-item:hover .chat-conv-del { opacity: 1; }
.chat-conv-del:hover { color: #dc2626; }

/* ---- 消息流 ---- */
.msg-avatar {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.msg-bubble {
  border-radius: 4px 12px 12px 12px; padding: 10px 14px;
  font-size: 13px; border: 1px solid #e8ecf1;
}
.msg-chart-box { margin-top: 8px; border-radius: 8px; border: 1px solid #e8ecf1; background: #fff; padding: 12px; }
.msg-sql {
  margin-top: 6px; padding: 10px; border-radius: 8px; background: #1e293b;
  font-family: monospace; font-size: 11px; color: #94a3b8; line-height: 1.7; white-space: pre-wrap;
}
.msg-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
/* update-begin---author:claude ---date:20261020  for：【jimureport#4819】智能问数前端显示 Token 消耗----------- */
.msg-usage { margin-top: 6px; font-size: 11px; color: #9ca3af; line-height: 1.5; cursor: default; }
/* update-end---author:claude ---date:20261020  for：【jimureport#4819】智能问数前端显示 Token 消耗----------- */
.msg-user-actions { display: flex; visibility: hidden; gap: 4px; margin-top: 4px; justify-content: flex-end; }
.msg-content:hover .msg-user-actions { visibility: visible; }
.msg-user-act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  color: #9ca3af; transition: all .15s;
}
.msg-user-act:hover { color: #2563eb; background: #eff4ff; }
.msg-suggest {
  padding: 5px 12px; border-radius: 16px; border: 1px solid #e8ecf1;
  font-size: 11px; color: #2563eb; background: #fff; cursor: pointer;
}

/* 问数过程：等待时在气泡里逐步显示，完成后折叠在消息文字下方 */
.msg-steps { margin-top: 6px; font-size: 12px; color: #6b7280; }
.msg-steps-head { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.msg-steps-head:hover { color: #2563eb; }
.msg-steps-fail, .msg-steps-fail:hover { color: #dc2626; }
.msg-steps-body { margin-top: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid #e8ecf1; background: #fff; }
.msg-step { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 24px; }
.msg-step-name { color: #111827; white-space: nowrap; }
.msg-step-cost { color: #6b7280; white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg-step-note { color: #9ca3af; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-step-more { margin-left: auto; color: #2563eb; cursor: pointer; white-space: nowrap; }
.msg-step-detail { margin: 0 0 6px 20px; }
.msg-step-error {
  padding: 8px 10px; border-radius: 8px; background: #fef2f2; color: #dc2626;
  font-family: monospace; font-size: 11px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}

/* 分析口径编辑器(指标/分组下拉)：size="small" 不缩字号，这里把下拉值+选项压到 12px，与 11px 标签协调
   iView 给 .ivu-select-item 设了 14px!important，必须用 !important + 更高优先级盖住 */
.msg-dsl-editor .ivu-select-selected-value,
.msg-dsl-editor .ivu-select-placeholder { font-size: 12px !important; }
.msg-dsl-editor .ivu-select-dropdown .ivu-select-item { font-size: 12px !important; padding: 5px 12px; }

/* ---- 报告抽屉 ---- */
.report-drawer {
  position: absolute; top: 0; right: 0; bottom: 0; height: 100%; width: 480px; max-width: 92%;
  background: #fff; box-shadow: -8px 0 28px rgba(0,0,0,.15); overflow: auto;
  padding: 24px; display: flex; flex-direction: column; box-sizing: border-box;
}
.report-item { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid #f3f4f6; }
/* 「生成报告」抽屉：保存为智能报表确认区 */
.sv-box { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; padding: 14px; border-radius: 10px; border: 1px solid #c7d7fe; background: #f5f8ff; }
.sv-t { font-size: 14px; font-weight: 700; color: #1f2329; }
.sv-d { font-size: 12px; line-height: 1.7; color: #6b7280; }
.sv-styles { grid-template-columns: repeat(4, 1fr); }
.sv-err { font-size: 12px; color: #dc2626; line-height: 1.6; }
.sv-box .btn-row { justify-content: flex-end; margin: 0; }

/* ═══════════════ 问数结果加入智能报表弹窗（chat/_add_report.ftl）═══════════════
   弹窗挂在 body 下，颜色全部显式给定，不依赖外层（含智能报表深色主题类）继承，深浅主题下都可读 */
.atr-q {
  margin-bottom: 12px; padding: 8px 12px; border-radius: 8px; background: #f8f9fb; border: 1px solid #e8ecf1;
  font-size: 12px; color: #6b7280; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.atr-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; margin-bottom: 12px; }
.atr-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid #e8ecf1; background: #fff; color: #111827; font-size: 13px; transition: border-color .15s, background .15s;
}
.atr-item:hover { border-color: #93b4f8; }
.atr-item.atr-on { border-color: #2563eb; background: #eff4ff; }
.atr-radio { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #cbd5e1; flex-shrink: 0; box-sizing: border-box; background: #fff; }
.atr-on .atr-radio { border: 4px solid #2563eb; }
.atr-item-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atr-tag { flex-shrink: 0; font-size: 11px; color: #6b7280; background: #f3f4f6; border-radius: 4px; padding: 1px 7px; }
.atr-hint { font-size: 12px; color: #6b7280; padding: 8px 2px; }
.atr-hint-err { color: #dc2626; }
.atr-title-row { margin-bottom: 12px; }
.atr-error {
  margin-bottom: 4px; padding: 8px 12px; border-radius: 8px; background: #fef2f2; border: 1px solid #fecaca;
  color: #b91c1c; font-size: 12px; line-height: 1.6; word-break: break-all;
}
.atr-btns { margin-top: 14px; }
.atr-done { text-align: center; padding: 16px 0 4px; }
.atr-done-title { margin-top: 10px; font-size: 15px; font-weight: 700; color: #111827; word-break: break-all; }
.atr-done-sub { margin-top: 6px; font-size: 12px; color: #6b7280; line-height: 1.7; }
.atr-done-btns { margin-top: 20px; justify-content: center; }
@media (max-width: 640px) {
  .atr-modal .ivu-modal { width: auto !important; margin: 0 12px; }
  .atr-list { max-height: 220px; }
}
@media print { .atr-modal { display: none !important; } }

/* ═══════════════ 根据问数对话生成智能报表弹窗（chat/_gen_report.ftl）═══════════════
   同 atr 弹窗：挂在 body 下，颜色显式给定，深浅主题下都可读 */
.rg-info { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; padding: 8px 12px; border-radius: 8px; background: #f8f9fb; border: 1px solid #e8ecf1; }
.rg-ast { font-size: 13px; font-weight: 600; color: #111827; }
.rg-info-t { font-size: 12px; color: #6b7280; line-height: 1.6; }
.rg-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.rg-label-row .form-label-dark { margin-bottom: 0; }
.rg-src { font-size: 11px; color: #6b7280; background: #f3f4f6; border-radius: 4px; padding: 1px 8px; }
.rg-src-ai { color: #2563eb; background: #eff4ff; }
.rg-loading {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 122px; border-radius: 8px;
  border: 1px dashed #cbd5e1; background: #f8f9fb; color: #6b7280; font-size: 13px;
}
.rg-style-label { margin-top: 14px; }
.rg-styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rg-style {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #e8ecf1; background: #fff; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.rg-style:hover { border-color: #93b4f8; }
.rg-style.rg-on { border-color: #2563eb; background: #eff4ff; }
.rg-style-n { font-size: 13px; font-weight: 600; color: #111827; }
.rg-style-d { margin-top: 2px; font-size: 11px; color: #6b7280; line-height: 1.5; }
.rg-error { margin-top: 12px; }
.rg-warn { margin-top: 12px; font-size: 12px; line-height: 1.5; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 6px 10px; }
.rg-btns { margin-top: 16px; }
@media (max-width: 640px) {
  .rg-modal .ivu-modal { width: auto !important; margin: 0 12px; }
  .rg-styles { grid-template-columns: repeat(2, 1fr); }
}
@media print { .rg-modal { display: none !important; } }

/* 选择助理：「自动创建」折叠分组头 */
.chat-ast-auto-head { display: flex; align-items: center; gap: 4px; margin: 6px 0 2px; padding: 6px 8px; font-size: 12px; color: #8a94a6; cursor: pointer; user-select: none; border-top: 1px dashed #e8ecf1; }
.chat-ast-auto-head:hover { color: #2563eb; }
