/* ============================================================
   DeepSeek AI 数据分析悬浮面板 - 独立样式文件
   所有类名使用 dsai- 前缀，避免与业务样式冲突
   圆形毛玻璃 FAB 按钮 + 可展开面板
   ============================================================ */

/* ===== 悬浮按钮 (FAB) — 与主题切换按钮同款 ===== */
.dsai-fab {
  position: fixed;
  bottom: 76px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  z-index: 9999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: linear-gradient(135deg, rgb(255 255 255 / 0.08), rgb(255 255 255 / 0.03));
  border: 1px solid rgb(255 255 255 / 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);

}

.dsai-fab:hover {
  transform: scale(1.08);
  border-color: rgb(255 255 255 / 0.2);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
}

.dsai-fab:active {
  transform: scale(0.95);
  transition: all 0.1s;
}

/* 浅色模式 */
html:not(.dark) .dsai-fab {
  background: rgb(255 255 255 / 0.85);
  border: 1px solid #d1d5db;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.06);
}
html:not(.dark) .dsai-fab:hover {
  border-color: #9ca3af;
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.1);
}

/* FAB 脉冲指示点 */
.dsai-fab-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgb(74 222 128 / 0.6);
  animation: dsai-dot-pulse 2s ease-in-out infinite;
}
@keyframes dsai-dot-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.3); }
}

/* FAB tooltip */
.dsai-fab-tooltip {
  position: absolute;
  right: 58px;
  top: 50%;
  transform: translateY(-50%);
  background: rgb(30 30 40 / 0.95);
  color: #e4e4e7;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  border: 1px solid rgb(255 255 255 / 0.1);
}
.dsai-fab:hover .dsai-fab-tooltip {
  opacity: 1;
}
html:not(.dark) .dsai-fab-tooltip {
  background: rgb(255 255 255 / 0.95);
  color: #374151;
  border: 1px solid #e5e7eb;
}


/* ===== 展开面板 ===== */
.dsai-panel {
  position: fixed;
  bottom: 76px;
  right: 20px;
  width: 420px;
  height: 560px;
  border-radius: 14px;
  z-index: 9998;

  background: linear-gradient(180deg, rgb(18 18 30 / 0.98) 0%, rgb(12 12 22 / 0.99) 100%);
  border: 1px solid rgb(255 255 255 / 0.08);
  box-shadow: 0 8px 40px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(59 130 246 / 0.08);
  backdrop-filter: blur(20px);

  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* 初始隐藏 + 展开动画 */
  opacity: 0;
  transform: scale(0.85) translateY(10px);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}
.dsai-panel.dsai-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  z-index: 9999;
}

/* 浅色模式 */
html:not(.dark) .dsai-panel {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.97) 0%, rgb(248 249 251 / 0.99) 100%);
  border: 1px solid #d1d5db;
  box-shadow: 0 8px 40px rgb(0 0 0 / 0.1), 0 0 0 1px rgb(59 130 246 / 0.1);
  color: #1e293b;
}

/* ===== 拖拽中 ===== */
.dsai-panel.dsai-dragging {
  transition: none;
  opacity: 0.92;
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.6), 0 0 0 1px rgb(59 130 246 / 0.2);
}

/* ===== 头部 ===== */
.dsai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgb(59 130 246 / 0.06), rgb(99 102 241 / 0.03));
}
.dsai-header:active { cursor: grabbing; }
html:not(.dark) .dsai-header {
  border-bottom-color: #e5e7eb;
  background: linear-gradient(135deg, rgb(59 130 246 / 0.04), rgb(99 102 241 / 0.02));
}

/* 头部标题 */
.dsai-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: #e2e8f0;
  pointer-events: none;
}
.dsai-header-title .dsai-logo {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dsai-header-title .dsai-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  background: rgb(59 130 246 / 0.15); color: #93c5fd; font-weight: 500;
}
html:not(.dark) .dsai-header-title { color: #1e293b; }
html:not(.dark) .dsai-header-title .dsai-badge { background: rgb(59 130 246 / 0.1); color: #2563eb; }

/* 头部按钮组 */
.dsai-header-actions { display: flex; align-items: center; gap: 4px; }
.dsai-header-actions button {
  width: 28px; height: 28px; border: none; background: transparent;
  color: #71717a; border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.2s;
}
.dsai-header-actions button:hover { background: rgb(255 255 255 / 0.08); color: #d4d4d8; }
.dsai-header-actions .dsai-btn-close:hover { background: rgb(248 113 113 / 0.15); color: #fca5a5; }
html:not(.dark) .dsai-header-actions button { color: #9ca3af; }
html:not(.dark) .dsai-header-actions button:hover { background: rgb(0 0 0 / 0.05); color: #374151; }
html:not(.dark) .dsai-header-actions .dsai-btn-close:hover { background: rgb(248 113 113 / 0.1); color: #ef4444; }

/* ===== 对话区域 ===== */
.dsai-body {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
}
.dsai-body::-webkit-scrollbar { width: 4px; }
.dsai-body::-webkit-scrollbar-track { background: transparent; }
.dsai-body::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 0.06); border-radius: 2px; }
.dsai-body::-webkit-scrollbar-thumb:hover { background: rgb(255 255 255 / 0.12); }

/* ===== 消息气泡 ===== */
.dsai-msg { display: flex; gap: 8px; animation: dsai-fade-in 0.3s ease; max-width: 100%; }
@keyframes dsai-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dsai-msg-avatar {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.dsai-msg-user .dsai-msg-avatar { background: linear-gradient(135deg, #3b82f6, #6366f1); color: #fff; }
.dsai-msg-assistant .dsai-msg-avatar { background: linear-gradient(135deg, #4f46e5, #2dd4bf); color: #fff; }
.dsai-msg-content {
  flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.6;
  color: #d4d4d8; padding: 8px 12px; border-radius: 10px; word-break: break-word;
}
.dsai-msg-user .dsai-msg-content { background: rgb(59 130 246 / 0.1); border: 1px solid rgb(59 130 246 / 0.12); border-top-right-radius: 3px; }
.dsai-msg-assistant .dsai-msg-content { background: rgb(255 255 255 / 0.03); border: 1px solid rgb(255 255 255 / 0.05); border-top-left-radius: 3px; }
html:not(.dark) .dsai-msg-content { color: #334155; }
html:not(.dark) .dsai-msg-user .dsai-msg-content { background: rgb(59 130 246 / 0.06); border-color: rgb(59 130 246 / 0.15); }
html:not(.dark) .dsai-msg-assistant .dsai-msg-content { background: #f8f9fb; border-color: #e5e7eb; }

/* 消息内容 markdown */
.dsai-msg-content p { margin: 0 0 6px 0; }
.dsai-msg-content p:last-child { margin-bottom: 0; }
.dsai-msg-content strong { color: #e2e8f0; font-weight: 600; }
.dsai-msg-content code { background: rgb(255 255 255 / 0.06); padding: 1px 5px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: #93c5fd; }
.dsai-msg-content pre { background: rgb(0 0 0 / 0.25); border: 1px solid rgb(255 255 255 / 0.04); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 11px; margin: 6px 0; }
.dsai-msg-content pre code { background: none; padding: 0; color: #d4d4d8; }
.dsai-msg-content ul, .dsai-msg-content ol { margin: 4px 0; padding-left: 18px; }
.dsai-msg-content li { margin-bottom: 2px; }
.dsai-msg-content table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 11px; }
.dsai-msg-content th, .dsai-msg-content td { padding: 5px 8px; border: 1px solid rgb(255 255 255 / 0.06); text-align: left; }
.dsai-msg-content th { background: rgb(255 255 255 / 0.04); font-weight: 600; color: #a1a1aa; }
html:not(.dark) .dsai-msg-content strong { color: #1e293b; }
html:not(.dark) .dsai-msg-content code { background: rgb(0 0 0 / 0.04); color: #2563eb; }
html:not(.dark) .dsai-msg-content pre { background: #f1f5f9; border-color: #e2e8f0; }
html:not(.dark) .dsai-msg-content pre code { color: #334155; }
html:not(.dark) .dsai-msg-content th, html:not(.dark) .dsai-msg-content td { border-color: #e5e7eb; }
html:not(.dark) .dsai-msg-content th { background: #f1f5f9; color: #64748b; }

/* ===== 打字动画 ===== */
.dsai-typing { display: flex; gap: 4px; padding: 4px 0; align-items: center; }
.dsai-typing span { width: 5px; height: 5px; border-radius: 50%; background: #71717a; animation: dsai-typing-dot 1.4s infinite ease-in-out; }
.dsai-typing span:nth-child(2) { animation-delay: 0.2s; }
.dsai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dsai-typing-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ===== 输入区域 ===== */
.dsai-input-area { padding: 10px 14px; border-top: 1px solid rgb(255 255 255 / 0.06); flex-shrink: 0; background: rgb(255 255 255 / 0.01); }
html:not(.dark) .dsai-input-area { border-top-color: #e5e7eb; background: #fafbfc; }
.dsai-input-row { display: flex; gap: 8px; align-items: flex-end; }
.dsai-input-row textarea {
  flex: 1; resize: none; padding: 8px 12px; border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 10px; background: rgb(255 255 255 / 0.03); color: #d4d4d8;
  font-family: inherit; font-size: 12.5px; line-height: 1.5; outline: none;
  min-height: 38px; max-height: 100px; transition: all 0.25s;
}
.dsai-input-row textarea::placeholder { color: #52525b; }
.dsai-input-row textarea:focus { border-color: rgb(59 130 246 / 0.4); background: rgb(255 255 255 / 0.05); box-shadow: 0 0 0 3px rgb(59 130 246 / 0.06); }
html:not(.dark) .dsai-input-row textarea { background: #fff; border-color: #d1d5db; color: #1e293b; }
html:not(.dark) .dsai-input-row textarea:focus { border-color: #3b82f6; background: #fff; box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1); }
html:not(.dark) .dsai-input-row textarea::placeholder { color: #9ca3af; }
.dsai-input-row .dsai-btn-send {
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #3b82f6); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.25s; box-shadow: 0 2px 8px rgb(59 130 246 / 0.2);
}
.dsai-input-row .dsai-btn-send:hover { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 4px 16px rgb(59 130 246 / 0.35); transform: translateY(-1px); }
.dsai-input-row .dsai-btn-send:active { transform: scale(0.95); }
.dsai-input-row .dsai-btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.dsai-input-row .dsai-btn-send svg { width: 16px; height: 16px; }

/* ===== 设置面板 ===== */
.dsai-settings { padding: 10px 14px; border-top: 1px solid rgb(255 255 255 / 0.06); background: rgb(255 255 255 / 0.015); flex-shrink: 0; display: none; }
.dsai-settings.dsai-visible { display: block; }
.dsai-settings-row { display: flex; gap: 6px; align-items: center; }
.dsai-settings-row input { flex: 1; padding: 6px 10px; border: 1px solid rgb(255 255 255 / 0.08); border-radius: 7px; background: rgb(255 255 255 / 0.03); color: #d4d4d8; font-size: 11.5px; outline: none; font-family: 'JetBrains Mono', monospace; }
.dsai-settings-row input:focus { border-color: rgb(59 130 246 / 0.4); }
.dsai-settings-row input::placeholder { color: #52525b; }
.dsai-settings-row .dsai-btn-set { padding: 6px 12px; border: 1px solid rgb(59 130 246 / 0.3); border-radius: 7px; background: rgb(59 130 246 / 0.1); color: #93c5fd; font-size: 11.5px; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
.dsai-settings-row .dsai-btn-set:hover { background: rgb(59 130 246 / 0.2); color: #bfdbfe; }
html:not(.dark) .dsai-settings { border-top-color: #e5e7eb; background: #f8f9fb; }
html:not(.dark) .dsai-settings-row input { background: #fff; border-color: #d1d5db; color: #1e293b; }

/* ===== 欢迎提示 ===== */
.dsai-welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; padding: 20px; text-align: center;
  color: #52525b; font-size: 12.5px; line-height: 1.6;
}
.dsai-welcome .dsai-welcome-icon { width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, rgb(79 70 229 / 0.15), rgb(59 130 246 / 0.1)); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.dsai-welcome .dsai-welcome-title { font-size: 15px; font-weight: 600; color: #a1a1aa; }
.dsai-welcome .dsai-welcome-hints { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.dsai-welcome .dsai-welcome-hint { padding: 5px 10px; border: 1px solid rgb(255 255 255 / 0.06); border-radius: 6px; font-size: 11px; color: #71717a; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.dsai-welcome .dsai-welcome-hint:hover { border-color: rgb(59 130 246 / 0.25); color: #93c5fd; background: rgb(59 130 246 / 0.06); }
html:not(.dark) .dsai-welcome { color: #9ca3af; }
html:not(.dark) .dsai-welcome .dsai-welcome-title { color: #64748b; }
html:not(.dark) .dsai-welcome .dsai-welcome-hint { border-color: #e5e7eb; color: #94a3b8; }
html:not(.dark) .dsai-welcome .dsai-welcome-hint:hover { border-color: #93c5fd; color: #2563eb; background: #eff6ff; }

/* ===== 错误提示 ===== */
.dsai-error { padding: 10px 14px; margin: 6px 0; border-radius: 8px; background: rgb(248 113 113 / 0.06); border: 1px solid rgb(248 113 113 / 0.12); color: #fca5a5; font-size: 12px; text-align: center; }
html:not(.dark) .dsai-error { background: #fef2f2; border-color: #fecaca; color: #dc2626; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .dsai-panel { width: calc(100vw - 20px); right: 10px; left: 10px; bottom: 66px; height: 480px; border-radius: 12px; }
  .dsai-fab { right: 10px; bottom: 66px; }
}
