/* ================= 全局问数挂件（NLQ Widget）=================
   独立模块样式，不改 components.css（降低回归风险）。
   配色与「AI 助手 → 自然语言查数」卡片一致（#0e3f8f → #1e63c4 深蓝渐变），
   保证同一功能在两个入口长得一样，用户不用重新认。
   z-index 45：低于 .modal(50)，弹窗打开时挂件自动被遮住，不会挡操作。
   ============================================================ */

.nlq-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, #0e3f8f, #1e63c4);
  box-shadow: 0 8px 24px rgba(14, 63, 143, .38);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.nlq-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 30px rgba(14, 63, 143, .46); }
.nlq-fab:active { transform: translateY(0) scale(.98); }
.nlq-fab.is-open { background: linear-gradient(135deg, #13314f, #1d4a70); }

/* 浮球上的上下文小角标：当前有具体对象时显示，提示「问的是这一条」 */
.nlq-fab-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #ffb020;
  border: 2px solid #fff;
  display: none;
}
.nlq-fab.has-ctx .nlq-fab-dot { display: block; }

.nlq-panel {
  position: fixed;
  right: 24px;
  bottom: 88px;
  width: 440px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 132px));
  z-index: 45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(165deg, #0b2f6b 0%, #134a92 55%, #0e3f8f 100%);
  box-shadow: 0 18px 50px rgba(9, 32, 74, .42);
  animation: nlqPanelIn .18s ease;
}
.nlq-panel[hidden] { display: none; }
@keyframes nlqPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.nlq-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .16);
}
.nlq-head-title { font-size: 14px; font-weight: 700; letter-spacing: .2px; }
.nlq-head-sub { font-size: 11px; opacity: .7; margin-left: 2px; }
.nlq-head-spacer { flex: 1; }
.nlq-icon-btn {
  width: 26px; height: 26px;
  border: 0; border-radius: 7px;
  background: rgba(255, 255, 255, .14);
  color: #fff; font-size: 15px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.nlq-icon-btn:hover { background: rgba(255, 255, 255, .26); }

/* 上下文条：明确告诉用户「这句话会被引用到哪条记录」，避免答非所问 */
.nlq-ctx-bar {
  flex: none;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12px;
  background: rgba(255, 176, 32, .16);
  border-bottom: 1px solid rgba(255, 176, 32, .3);
  color: #ffe6b8;
}
.nlq-ctx-bar.show { display: flex; }
.nlq-ctx-bar b { color: #fff; font-weight: 600; }
.nlq-ctx-clear {
  margin-left: auto;
  border: 0; background: transparent;
  color: #ffe6b8; opacity: .8;
  font-size: 11px; cursor: pointer; padding: 0 2px;
}
.nlq-ctx-clear:hover { opacity: 1; text-decoration: underline; }

.nlq-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .28) transparent;
}
.nlq-msgs::-webkit-scrollbar { width: 6px; }
.nlq-msgs::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .26); border-radius: 3px; }

.nlq-msg { display: flex; flex-direction: column; max-width: 100%; }
.nlq-msg-u { align-items: flex-end; }
.nlq-msg-a { align-items: stretch; }

.nlq-bub {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 12px 12px 3px 12px;
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}
.nlq-msg-u .nlq-bub { background: #ffb020; color: #3a2400; font-weight: 600; }

.nlq-bub-a {
  max-width: 100%;
  padding: 11px 13px;
  border-radius: 12px 12px 12px 3px;
  font-size: 13px;
  line-height: 1.65;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
  white-space: normal;
}
.nlq-bub-a.err { background: rgba(255, 120, 120, .16); border-color: rgba(255, 140, 140, .34); }
.nlq-bub-a .nlq-think { opacity: .85; margin-bottom: 8px; }
.nlq-bub-a .nlq-summary {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .14);
  font-size: 13px;
}
.nlq-bub-a details { margin-top: 10px; }
.nlq-bub-a summary { cursor: pointer; font-size: 11px; opacity: .78; }
.nlq-bub-a pre {
  margin: 6px 0 0;
  padding: 9px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .3);
  font-size: 11px;
  overflow: auto;
  white-space: pre-wrap;
  color: #cfe3ff;
}

/* 加载中的三点动画 */
.nlq-typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.nlq-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255, 255, 255, .75);
  animation: nlqBlink 1.1s infinite ease-in-out;
}
.nlq-typing i:nth-child(2) { animation-delay: .16s; }
.nlq-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes nlqBlink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* 空态：首次打开给三条可点的示例，降低「不知道能问什么」的门槛 */
.nlq-empty { opacity: .82; font-size: 12.5px; line-height: 1.8; }
.nlq-empty b { display: block; font-size: 13px; margin-bottom: 4px; opacity: 1; }

.nlq-chips {
  flex: none;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 14px 8px;
}
.nlq-chip {
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .08);
  color: #e7f0ff;
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .14s, border-color .14s;
}
.nlq-chip:hover { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .46); }

.nlq-input-row {
  flex: none;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .12);
}
.nlq-input {
  flex: 1;
  resize: none;
  max-height: 96px;
  min-height: 38px;
  padding: 9px 11px;
  border: 0;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
  outline: none;
  color: #1b2a41;
  background: #fff;
}
.nlq-input::placeholder { color: #93a3b8; }
.nlq-send {
  flex: none;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #ffb020;
  color: #3a2400;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.nlq-send:disabled { opacity: .55; cursor: not-allowed; }

/* ===== 时间口径追问（2026-10-18）=====
   「工单数量是多少」这种问法缺时间范围，直接查全量会被当成数据错。
   给出可点的区间，比让用户自己组织语言快，也不会再触发第二次理解偏差。 */
.nlq-time-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.nlq-time-tip {
  font-size: 12px;
  margin: -2px 0 8px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 176, 32, .14);
  border-left: 2px solid rgba(255, 176, 32, .6);
  color: #ffe6b8;
}

/* ===== 结果工具条：导出 Excel / 存为报表 / 打印 PDF ===== */
.nlq-tools { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.nlq-tool {
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .1);
  color: #eaf2ff;
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .14s, border-color .14s;
}
.nlq-tool:hover { background: rgba(255, 255, 255, .22); border-color: rgba(255, 255, 255, .5); }

/* ===== 我的报表（保存过的问句，一键重跑）===== */
.nlq-saved {
  flex: none;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 0 14px 8px;
}
.nlq-saved-lbl { font-size: 11.5px; opacity: .8; }
.nlq-chip.saved { border-color: rgba(255, 176, 32, .5); background: rgba(255, 176, 32, .14); color: #ffe6b8; }

/* ===== 后台「问数日志」页概览条（跟随主题色，不写死深浅）===== */
.nlq-log-stat {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: baseline;
  font-size: 13px;
  padding: 4px 0 12px;
  opacity: .88;
}
.nlq-log-stat b { font-size: 15px; font-weight: 700; }

/* 移动端：铺满可视区，避免小屏被挤成一条缝 */
@media (max-width: 620px) {
  .nlq-fab { right: 16px; bottom: 16px; width: 48px; height: 48px; font-size: 20px; }
  .nlq-panel {
    right: 0; bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    border-radius: 0;
    animation: none;
  }
  .nlq-msgs { padding: 12px; }
  .nlq-input-row { padding: 8px 12px 10px; }
}
