/* ============================================================
   懂AI · AI小助手 悬浮窗样式
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

/* ─── 悬浮触发按钮 ─── */
#dongai-fab {
  position: fixed;
  right: 28px;
  bottom: 36px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  box-shadow: 0 4px 20px rgba(37,99,235,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  z-index: 99998;
  border: none;
  outline: none;
}
#dongai-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(37,99,235,.55);
}
#dongai-fab svg {
  width: 22px; height: 22px;
  fill: #fff;
  flex-shrink: 0;
}
#dongai-fab .dongai-fab-label {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,.2);
  font-family: -apple-system, "PingFang SC", sans-serif;
}

/* 脉冲动画 */
#dongai-fab::after {
  content: '';
  position: absolute;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: rgba(37,99,235,.3);
  animation: dongai-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes dongai-pulse {
  0%   { transform: scale(1);   opacity: .7; }
  100% { transform: scale(1.85); opacity: 0;  }
}

/* ─── 对话面板 ─── */
#dongai-panel {
  position: fixed;
  right: 28px;
  bottom: 118px;
  width: 380px;
  max-height: 590px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  transition: opacity .25s, transform .25s;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #1e293b;
}
#dongai-panel.dongai-hidden {
  opacity: 0;
  transform: translateY(14px) scale(.97);
  pointer-events: none;
}

/* 顶部标题栏 */
.dongai-header {
  padding: 15px 16px 13px;
  background: linear-gradient(135deg, #1e40af 0%, #0891b2 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.dongai-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.dongai-header-info { flex: 1; min-width: 0; }
.dongai-header-name {
  font-size: 14px; font-weight: 700; color: #fff; line-height: 1.3;
}
.dongai-header-status {
  font-size: 11px; color: rgba(255,255,255,.78);
  display: flex; align-items: center; gap: 4px;
  margin-top: 2px;
}
.dongai-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: dongai-blink 1.8s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes dongai-blink {
  0%,100% { opacity:1; } 50% { opacity:.35; }
}
.dongai-close-btn {
  width: 28px; height: 28px;
  border: none; background: rgba(255,255,255,.15);
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; line-height: 1;
  transition: background .15s;
  flex-shrink: 0;
}
.dongai-close-btn:hover { background: rgba(255,255,255,.3); }

/* 快捷按钮区 */
.dongai-quick {
  padding: 10px 12px;
  background: #f8faff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.dongai-quick-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1.5px solid #c7d2fe;
  background: #fff;
  color: #4338ca;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}
.dongai-quick-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}
.dongai-quick-btn.dongai-active {
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-color: transparent;
  color: #fff;
}
.dongai-quick-btn svg { width: 12px; height: 12px; flex-shrink: 0; }

/* 消息列表 */
.dongai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.dongai-messages::-webkit-scrollbar { width: 4px; }
.dongai-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* 消息气泡 */
.dongai-msg { display: flex; gap: 7px; align-items: flex-start; }
.dongai-msg.dongai-user { flex-direction: row-reverse; }

.dongai-msg-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.dongai-msg-avatar.dongai-ai-av {
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  font-size: 11px;
}
.dongai-msg-avatar.dongai-user-av {
  background: #e0e7ff;
  color: #4338ca;
  font-size: 11px;
}

.dongai-bubble {
  max-width: 84%;
  padding: 9px 13px;
  border-radius: 15px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}
.dongai-msg.dongai-ai .dongai-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.dongai-msg.dongai-user .dongai-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.dongai-bubble a { color: #2563eb; }
.dongai-msg.dongai-user .dongai-bubble a { color: #bfdbfe; }

/* 时间戳 */
.dongai-msg-meta {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 2px;
}

/* 总结结果卡片 */
.dongai-summary-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 100%);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  color: #1e293b;
  line-height: 1.7;
}
.dongai-summary-card .dongai-card-title {
  font-size: 10.5px;
  font-weight: 700;
  color: #2563eb;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dongai-summary-card ul { padding-left: 16px; margin: 0; }
.dongai-summary-card li { margin-bottom: 5px; color: #334155; }

/* 思考中动画 */
.dongai-thinking {
  display: flex; gap: 4px; align-items: center;
  padding: 3px 0;
}
.dongai-thinking span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: dongai-dot .9s ease-in-out infinite;
}
.dongai-thinking span:nth-child(2) { animation-delay: .15s; }
.dongai-thinking span:nth-child(3) { animation-delay: .30s; }
@keyframes dongai-dot {
  0%,80%,100%{ transform:scale(.65); opacity:.45; }
  40%{ transform:scale(1); opacity:1; }
}

/* ─── 流式输出光标 ─── */
.dongai-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #2563eb;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: dongai-blink .7s step-end infinite;
}
@keyframes dongai-blink {
  0%,100%{ opacity:1; }
  50%{ opacity:0; }
}

/* ─── 消息体容器 ─── */
.dongai-msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ─── 思考框（固定高度，内部滚动）─── */
.dongai-think-box {
  border: 1px solid #c7d7f8;
  border-radius: 10px;
  background: #f0f5ff;
  overflow: hidden;
  font-size: 12px;
  color: #64748b;
  max-width: 90%;
  flex-shrink: 0;
}
.dongai-think-box.dongai-think-hidden {
  display: none;
}
.dongai-think-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  cursor: pointer;
  background: #dbeafe;
  user-select: none;
  transition: background .15s;
}
.dongai-think-header:hover {
  background: #bfdbfe;
}
.dongai-think-icon {
  font-size: 13px;
  line-height: 1;
}
.dongai-think-label {
  flex: 1;
  font-size: 11.5px;
  font-weight: 600;
  color: #1d4ed8;
  letter-spacing: 0.2px;
}
.dongai-think-toggle {
  font-size: 10px;
  color: #6b7280;
  line-height: 1;
  padding: 1px 3px;
}
/* 思考内容区：固定高度，内部滚动 */
.dongai-think-body {
  height: 150px !important;  /* 强制固定高度，禁止随内容增长 */
  min-height: 150px !important;
  max-height: 150px !important;
  overflow-y: auto !important;
  overflow-x: hidden;
  padding: 8px 10px;
  line-height: 1.65;
  color: #475569;
  font-size: 12px;
  word-break: break-word;
  border-top: 1px solid #c7d7f8;
  box-sizing: border-box;
}
/* 折叠状态：高度收起 */
.dongai-think-body.dongai-think-collapsed {
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  overflow: hidden !important;
  border-top: none !important;
}
.dongai-think-body::-webkit-scrollbar { width: 3px; }
.dongai-think-body::-webkit-scrollbar-thumb { background: #93c5fd; border-radius: 3px; }

/* ─── 正式回答区域 ─── */
.dongai-answer-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 90%;
}
.dongai-answer-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #2563eb;
  padding: 0 2px 4px 2px;
  display: none;  /* 默认隐藏，有内容时由JS控制显示 */
}
.dongai-answer-bubble {
  padding: 9px 13px;
  border-radius: 15px;
  border-bottom-left-radius: 4px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
  background: #f1f5f9;
  color: #1e293b;
}
/* 思考框存在时，回答有顶部标签区分 */
.dongai-think-box:not(.dongai-think-hidden) ~ .dongai-answer-wrap .dongai-answer-label {
  display: block;
}
.dongai-answer-bubble:empty {
  display: none;
}
.dongai-answer-bubble a { color: #2563eb; }

/* 使用次数栏 */
.dongai-usage {
  padding: 5px 12px 7px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border-top: 1px solid #f1f5f9;
}
.dongai-usage-text {
  font-size: 11px;
  color: #94a3b8;
  flex: 1;
}
.dongai-usage-text strong { color: #f59e0b; }
.dongai-upgrade-link {
  font-size: 11px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  padding: 2px 8px;
  background: #eff6ff;
  border-radius: 8px;
  white-space: nowrap;
  transition: background .15s;
}
.dongai-upgrade-link:hover { background: #dbeafe; }

/* 输入区 */
.dongai-input-area {
  padding: 9px 12px 11px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  gap: 7px;
  align-items: flex-end;
  flex-shrink: 0;
}
.dongai-textarea-wrap {
  flex: 1;
  background: #f1f5f9;
  border: 1.5px solid transparent;
  border-radius: 14px;
  padding: 8px 11px;
  transition: border-color .15s, background .15s;
  display: flex;
  align-items: flex-end;
}
.dongai-textarea-wrap:focus-within {
  border-color: #2563eb;
  background: #fff;
}
.dongai-textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: #1e293b;
  resize: none;
  max-height: 80px;
  font-family: inherit;
  line-height: 1.5;
  min-height: 20px;
}
.dongai-textarea::placeholder { color: #94a3b8; }
.dongai-send-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0;
}
.dongai-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 3px 12px rgba(37,99,235,.4);
}
.dongai-send-btn:disabled {
  opacity: .5;
  cursor: default;
  transform: none;
}
.dongai-send-btn svg { width: 15px; height: 15px; fill: #fff; }

/* 响应式 */
@media (max-width: 480px) {
  #dongai-panel { right: 10px; width: calc(100vw - 20px); bottom: 100px; }
  #dongai-fab   { right: 16px; bottom: 24px; }
}
