/* ============================================
   AI 3D 悬浮机器人 — 仅保留头部，高科技感设计
   ============================================ */

.ai-robot-container {
  position: fixed;
  z-index: 9999;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.05s ease-out;
  will-change: transform;
}
.ai-robot-container:active { cursor: grabbing; }
.ai-robot-container.dragging { cursor: grabbing; transition: none; }
.ai-robot-container.dragging .ai-robot-head,
.ai-robot-container.dragging .ai-robot-orbit,
.ai-robot-container.dragging .ai-robot-particle {
  animation-play-state: paused !important;
}

/* ---- 舞台 ---- */
.ai-robot-stage {
  width: 72px;
  height: 72px;
  position: relative;
}

/* ---- 头部主体（玻璃质感球体）---- */
.ai-robot-head {
  position: absolute;
  top: 6px; left: 6px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%,
    rgba(120,180,255,0.35) 0%,
    rgba(60,120,230,0.18) 30%,
    rgba(30,60,140,0.45) 70%,
    rgba(10,25,70,0.8) 100%);
  border: 2px solid rgba(100,160,255,0.5);
  box-shadow:
    0 0 24px rgba(70,140,255,0.55),
    0 0 60px rgba(70,140,255,0.2),
    inset 0 0 30px rgba(100,180,255,0.15);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 3;
  animation: ai-head-pulse 2.8s ease-in-out infinite;
  overflow: hidden;
}

/* 头部扫描线 */
.ai-robot-head::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(120,180,255,0.04) 3px,
    rgba(120,180,255,0.04) 4px
  );
  border-radius: 50%;
  animation: ai-scan-line 4s linear infinite;
  pointer-events: none;
}

/* 头部高光 */
.ai-robot-head::after {
  content: '';
  position: absolute;
  top: 10%; left: 18%;
  width: 22%; height: 18%;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(255,255,255,0.7) 0%,
    rgba(255,255,255,0) 100%);
  transform: rotate(-20deg);
  pointer-events: none;
}

/* ---- 轨道环（绕头部旋转）---- */
.ai-robot-orbit {
  position: absolute;
  top: 0; left: 0;
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: rgba(80,180,255,0.5);
  border-right-color: rgba(80,180,255,0.25);
  z-index: 2;
  animation: ai-orbit-spin 3.5s linear infinite;
  pointer-events: none;
}
.ai-robot-orbit--inner {
  width: 54px; height: 54px;
  top: 9px; left: 9px;
  border-top-color: rgba(130,200,255,0.35);
  border-left-color: rgba(130,200,255,0.15);
  border-right-color: transparent;
  animation-duration: 2.4s;
  animation-direction: reverse;
}

/* ---- 天线 ---- */
.ai-robot-antenna {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 2px; height: 10px;
  background: linear-gradient(180deg,
    rgba(100,200,255,0.9) 0%,
    rgba(60,140,240,0.4) 100%);
  border-radius: 1px;
  z-index: 5;
  box-shadow: 0 0 6px rgba(80,160,255,0.6);
}
.ai-robot-antenna-tip {
  position: absolute;
  top: -5px; left: 50%;
  transform: translateX(-50%);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 8px rgba(255,255,255,1),
    0 0 16px rgba(80,180,255,0.9),
    0 0 28px rgba(80,180,255,0.4);
  animation: ai-antenna-glow 1.6s ease-in-out infinite;
}

/* ---- 眼睛 ---- */
.ai-robot-eyes {
  position: absolute;
  top: 22px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  z-index: 4;
}
.ai-robot-eye {
  width: 9px; height: 11px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 10px rgba(255,255,255,1),
    0 0 20px rgba(80,180,255,0.9);
  animation: ai-eye-blink 3.5s ease-in-out infinite;
  position: relative;
}
.ai-robot-eye::after {
  content: '';
  display: block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #0a1929;
  margin: 2.5px auto 0;
}

/* ---- 粒子环绕 ---- */
.ai-robot-particles {
  position: absolute;
  top: 0; left: 0;
  width: 72px; height: 72px;
  z-index: 1;
  pointer-events: none;
}
.ai-robot-particle {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(100,180,255,0.7);
  box-shadow: 0 0 6px rgba(100,180,255,0.6);
  animation: ai-particle-float 2.5s ease-in-out infinite;
}
.ai-robot-particle:nth-child(1) { top: 2px; left: 50%; animation-delay: 0s; }
.ai-robot-particle:nth-child(2) { top: 50%; right: 2px; animation-delay: 0.6s; }
.ai-robot-particle:nth-child(3) { bottom: 2px; left: 50%; animation-delay: 1.2s; }
.ai-robot-particle:nth-child(4) { top: 50%; left: 2px; animation-delay: 1.8s; }

/* ============================================
   动画 Keyframes
   ============================================ */

@keyframes ai-head-pulse {
  0%, 100% {
    box-shadow:
      0 0 24px rgba(70,140,255,0.55),
      0 0 60px rgba(70,140,255,0.2),
      inset 0 0 30px rgba(100,180,255,0.15);
    transform: translateY(0);
  }
  50% {
    box-shadow:
      0 0 36px rgba(70,140,255,0.75),
      0 0 80px rgba(70,140,255,0.35),
      inset 0 0 40px rgba(100,180,255,0.25);
    transform: translateY(-4px);
  }
}

@keyframes ai-orbit-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes ai-scan-line {
  0% { transform: translateY(-8%); }
  100% { transform: translateY(8%); }
}

@keyframes ai-antenna-glow {
  0%, 100% {
    box-shadow:
      0 0 8px rgba(255,255,255,1),
      0 0 16px rgba(80,180,255,0.9),
      0 0 28px rgba(80,180,255,0.4);
    transform: translateX(-50%) scale(1);
  }
  50% {
    box-shadow:
      0 0 4px rgba(255,255,255,0.7),
      0 0 10px rgba(80,180,255,0.5),
      0 0 18px rgba(80,180,255,0.2);
    transform: translateX(-50%) scale(0.7);
  }
}

@keyframes ai-eye-blink {
  0%, 94%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(0.08); }
}

@keyframes ai-particle-float {
  0%, 100% { opacity: 0.3; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(1.3); }
}

/* ============================================
   聊天对话框 — IM 即时通讯风格（固定浅色，不受后台暗色主题影响）
   注意：.ai-chat-dialog 就是 .el-dialog 本身，不能用后代选择器
   ============================================ */

.el-dialog.ai-chat-dialog {
  border-radius: 16px !important;
  overflow: hidden;
  background: #ffffff !important;
  --el-bg-color: #ffffff;
  --el-bg-color-overlay: #ffffff;
  --el-text-color-primary: #303133;
  --el-text-color-regular: #606266;
  --el-text-color-secondary: #909399;
  --el-border-color: #dcdfe6;
  --el-border-color-light: #e4e7ed;
  --el-border-color-lighter: #ebeef5;
  --el-fill-color-blank: #ffffff;
  --el-fill-color-light: #f5f7fa;
  color-scheme: light;
}
.el-dialog.ai-chat-dialog .el-dialog__header {
  padding: 14px 20px;
  border-bottom: 1px solid #ebeef5;
  margin: 0;
  display: flex;
  align-items: center;
  background: #ffffff !important;
  color: #303133;
}
.el-dialog.ai-chat-dialog .el-dialog__title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
}
.ai-chat-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.ai-chat-dialog-header__title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
}
.ai-chat-dialog-header__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ai-chat-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  color: #606266;
  font-size: 16px;
  transition: all 0.2s;
}
.ai-chat-header-icon:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #303133;
}
.ai-chat-header-icon--close:hover {
  background: rgba(245, 108, 108, 0.12);
  color: #f56c6c;
}
.el-dialog.ai-chat-dialog .el-dialog__body {
  padding: 0;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  background: #f0f2f5 !important;
  color: #303133;
}

/* 对话框 body 内部包裹层（承载动态高度） */
.ai-chat-body-inner {
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 320px;
  overflow: hidden;
  background: #f0f2f5;
}
/* 全屏模式：构建完整的 flex 撑满链 */
.el-dialog.ai-chat-dialog.is-fullscreen {
  display: flex;
  flex-direction: column;
  border-radius: 0 !important;
}
.el-dialog.ai-chat-dialog.is-fullscreen .el-dialog__header {
  flex-shrink: 0;
}
.el-dialog.ai-chat-dialog.is-fullscreen .el-dialog__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.el-dialog.ai-chat-dialog.is-fullscreen .ai-chat-body-inner {
  height: 100% !important;
  width: 100% !important;
  max-width: 100% !important;
}
/* 全屏时隐藏缩放手柄 */
.el-dialog.ai-chat-dialog.is-fullscreen .ai-chat-resize-handle {
  display: none;
}

/* 缩放手柄 */
.ai-chat-resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px;
  user-select: none;
  z-index: 10;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.ai-chat-resize-handle:hover {
  opacity: 1;
}

/* 缩放中禁止选中文字 */
.ai-chat-dialog--resizing,
.ai-chat-dialog--resizing * {
  user-select: none !important;
}

/* 对话框 header 扩展区（模型选择器放这里） */
.ai-chat-header-ext {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-size: 12px;
  color: #909399;
}
.ai-chat-header-ext .el-select {
  width: 180px;
}
.ai-chat-header-ext .el-select .el-input__inner {
  font-size: 12px;
  height: 30px;
}

/* ---- 模型选择器工具栏 ---- */
.ai-chat-model-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: #ffffff !important;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
  flex-shrink: 0;
  color: #606266;
}
.ai-chat-model-bar__label {
  color: #909399;
  white-space: nowrap;
}

/* 消息列表 — 强制浅色，覆盖系统暗色 / EP dark / 旧缓存样式 */
.ai-chat-messages,
.el-dialog.ai-chat-dialog .ai-chat-messages,
.ai-chat-dialog .ai-chat-messages,
.ai-chat-body-inner .ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  background-color: #f0f2f5 !important;
  background-image: linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px) !important;
  background-size: 100% 32px !important;
  color: #303133 !important;
}

/* 兜底：无论 class 挂在 overlay 还是 dialog 上，都锁浅色 */
.ai-chat-dialog,
.ai-chat-dialog .el-dialog,
.ai-chat-dialog .el-dialog__body,
.ai-chat-dialog .ai-chat-body-inner,
.el-overlay-dialog.ai-chat-dialog .el-dialog__body {
  background-color: #f0f2f5 !important;
  color-scheme: light !important;
}
.ai-chat-dialog .el-dialog__header,
.ai-chat-dialog .ai-chat-model-bar,
.ai-chat-dialog .ai-chat-input-area,
.el-dialog.ai-chat-dialog .el-dialog__header,
.el-dialog.ai-chat-dialog .ai-chat-model-bar,
.el-dialog.ai-chat-dialog .ai-chat-input-area {
  background-color: #ffffff !important;
}

/* ---- 消息气泡 ---- */
.ai-chat-msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: ai-msg-fadein 0.35s ease-out;
}
.ai-chat-msg-row--user {
  flex-direction: row-reverse;
}

/* 头像 */
.ai-chat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.ai-chat-avatar--assistant {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.ai-chat-avatar--user {
  background: linear-gradient(135deg, #588FEA 0%, #3568c4 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(88,143,234,0.3);
}

/* 气泡体 */
.ai-chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  position: relative;
}
.ai-chat-bubble--user {
  background: linear-gradient(135deg, #588FEA, #3568c4);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-chat-bubble--assistant {
  background: #ffffff !important;
  color: #303133 !important;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.ai-chat-bubble--error {
  background: #fff2f0;
  color: #ff4d4f;
  border: 1px solid #ffccc7;
  max-width: 90%;
  text-align: center;
  border-radius: 10px;
}
.ai-chat-bubble--loading {
  background: #ffffff !important;
  color: #999;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-bottom-left-radius: 4px;
}

/* 消息时间戳 */
.ai-chat-time {
  font-size: 11px;
  color: #b0b0b0;
  margin-top: 2px;
  text-align: right;
}
.ai-chat-msg-row--assistant .ai-chat-time {
  text-align: left;
}

/* loading 动画点 */
.ai-chat-loading-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.ai-chat-loading-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #bbb;
  animation: ai-dot-bounce 1.4s ease-in-out infinite both;
}
.ai-chat-loading-dots span:nth-child(1) { animation-delay: 0s; }
.ai-chat-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
@keyframes ai-msg-fadein {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 表格容器 */
.ai-chat-table-wrap {
  margin-top: 10px;
  max-height: 260px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.06);
  background: #fff;
}
.ai-chat-table-wrap .el-table {
  font-size: 13px;
}

/* 图表容器 — 高度由 JS 动态控制，CSS 提供兜底 */
.ai-chart-wrap {
  margin-top: 10px;
  width: 100%;
  min-height: 200px;
  max-height: 480px;
  height: 260px;
  border-radius: 8px;
  overflow: hidden;
  transition: height 0.1s ease;
  background: #fff;
}

/* Token / 费用用量小字 */
.ai-chat-token-info {
  font-size: 11px;
  color: #909399;
  margin-top: 6px;
  line-height: 1.5;
  border-top: 1px dashed #ebeef5;
  padding-top: 6px;
}
.ai-chat-token-info__cost {
  color: #e6a23c;
  margin-left: 2px;
}
.ai-chat-bubble--user .ai-chat-token-info {
  color: rgba(255,255,255,0.6);
  border-top-color: rgba(255,255,255,0.25);
}

/* 空状态 */
.ai-chat-empty {
  text-align: center;
  color: #bbb;
  padding: 60px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ai-chat-empty-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: 0.7;
  animation: ai-head-pulse 3s ease-in-out infinite;
}
.ai-chat-empty-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #999;
}
.ai-chat-empty-desc {
  font-size: 12px;
  color: #ccc;
  line-height: 1.6;
}

/* ---- 输入区 ---- */
.ai-chat-input-area {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #ebeef5;
  background: #ffffff !important;
  align-items: flex-end;
  flex-shrink: 0;
}
.ai-chat-input-area .el-textarea {
  flex: 1;
}
.ai-chat-input-area .el-textarea__inner {
  resize: vertical !important;
  min-height: 38px;
  max-height: 160px;
  border-radius: 10px;
  line-height: 1.5;
  font-size: 14px;
  padding: 8px 12px;
  background: #ffffff !important;
  color: #303133 !important;
  box-shadow: 0 0 0 1px #dcdfe6 inset;
}
.ai-chat-send-btn {
  flex-shrink: 0;
  height: 38px;
  border-radius: 10px;
  min-width: 60px;
  font-weight: 500;
}

/* ============================================
   移动端适配
   ============================================ */
@media (max-width: 640px) {
  .ai-robot-stage {
    width: 56px; height: 56px;
  }
  .ai-robot-head {
    width: 46px; height: 46px;
    top: 5px; left: 5px;
  }
  .ai-robot-orbit {
    width: 56px; height: 56px;
  }
  .ai-robot-orbit--inner {
    width: 42px; height: 42px;
    top: 7px; left: 7px;
  }
  .ai-robot-eyes {
    top: 17px; gap: 10px;
  }
  .ai-robot-eye {
    width: 7px; height: 9px;
  }
  .ai-robot-particles { width: 56px; height: 56px; }

  .el-dialog.ai-chat-dialog {
    width: 96% !important;
    margin: 1vh auto !important;
    border-radius: 12px !important;
  }
  .el-dialog.ai-chat-dialog .el-dialog__body {
    min-height: calc(100vh - 120px);
  }
  .ai-chat-bubble {
    max-width: 85%;
    font-size: 13px;
  }
  .ai-chat-header-ext .el-select {
    width: 130px;
  }
}
