/* AI悬浮球助手 - 参照腾讯云KiKi风格 */
.ai-ops-widget {
  position: fixed;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1a1a2e;
}

.ai-ops-widget * { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== 悬浮球 ===== */
.ai-ops-ball {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
  user-select: none;
  -webkit-user-select: none;
}

.ai-ops-ball:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(37, 99, 235, 0.45);
}

.ai-ops-ball:active { transform: scale(0.95); }

.ai-ops-ball.dragging {
  transform: scale(1.04);
  transition: none;
}

.ai-ops-ball-icon {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  pointer-events: none;
  color: #fff;
}

.ai-ops-ball-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.3);
  animation: ai-ops-ring 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ai-ops-ring {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.35); opacity: 0; }
}

/* ===== 面板外壳 ===== */
.ai-ops-panel {
  position: fixed;
  width: 420px;
  height: 600px;
  min-width: 340px;
  min-height: 420px;
  max-width: 90vw;
  max-height: 90vh;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.ai-ops-widget--open .ai-ops-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ai-ops-panel.dragging {
  transition: none;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.15);
}

/* ===== 头部 ===== */
.ai-ops-header {
  padding: 14px 18px;
  background: #f8f9fb;
  border-bottom: 1px solid #eef0f3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
}

.ai-ops-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-ops-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.ai-ops-header-info h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0;
  line-height: 1.3;
}

.ai-ops-header-info .ai-ops-status {
  font-size: 11px;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-ops-header-info .ai-ops-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
}

.ai-ops-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ai-ops-header button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.ai-ops-header button:hover {
  background: #e2e8f0;
  color: #475569;
}

/* ===== 快捷按钮 ===== */
.ai-ops-quick {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.ai-ops-quick::-webkit-scrollbar { display: none; }

.ai-ops-quick-btn {
  padding: 5px 12px;
  background: #f8f9fb;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: #64748b;
  white-space: nowrap;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-ops-quick-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}

/* ===== 消息区域 ===== */
.ai-ops-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: #fff;
  scroll-behavior: smooth;
}

.ai-ops-messages::-webkit-scrollbar { width: 5px; }
.ai-ops-messages::-webkit-scrollbar-track { background: transparent; }
.ai-ops-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }
.ai-ops-messages::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

.ai-ops-msg {
  margin-bottom: 16px;
  display: flex;
  animation: ai-ops-fadeIn 0.2s ease;
}

@keyframes ai-ops-fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-ops-msg-user { justify-content: flex-end; }
.ai-ops-msg-ai { justify-content: flex-start; }

.ai-ops-msg-ai .ai-ops-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-right: 8px;
  margin-top: 2px;
}

.ai-ops-msg-ai .ai-ops-msg-content {
  max-width: 80%;
}

.ai-ops-bubble {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.ai-ops-msg-user .ai-ops-bubble {
  background: #2563eb;
  color: #fff;
  border-bottom-right-radius: 3px;
  max-width: 75%;
}

.ai-ops-msg-ai .ai-ops-bubble {
  background: #f8f9fb;
  color: #1a1a2e;
  border-bottom-left-radius: 3px;
}

.ai-ops-msg-ai .ai-ops-bubble a {
  color: #3b82f6;
  text-decoration: none;
}

.ai-ops-msg-ai .ai-ops-bubble a:hover { text-decoration: underline; }

/* ===== 加载动画 ===== */
.ai-ops-loading {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
}

.ai-ops-loading span {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #94a3b8;
  border-radius: 50%;
  animation: ai-ops-bounce 1.2s ease-in-out infinite;
}

.ai-ops-loading span:nth-child(2) { animation-delay: 0.15s; }
.ai-ops-loading span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-ops-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== 输入区域 ===== */
.ai-ops-input {
  padding: 12px 18px 14px;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  background: #fff;
}

.ai-ops-input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f8f9fb;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-ops-input-box:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.06);
  background: #fff;
}

.ai-ops-input textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  font-size: 13.5px;
  resize: none;
  height: 22px;
  max-height: 80px;
  font-family: inherit;
  outline: none;
  color: #1a1a2e;
  line-height: 1.5;
}

.ai-ops-input textarea::placeholder { color: #94a3b8; }

.ai-ops-send-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.ai-ops-send-btn:hover { background: #2d2d4a; }
.ai-ops-send-btn:active { transform: scale(0.95); }
.ai-ops-send-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

.ai-ops-send-btn svg { width: 14px; height: 14px; }

.ai-ops-disclaimer {
  margin-top: 8px;
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
}

/* ===== 缩放手柄（8个方向） ===== */
.ai-ops-resize {
  position: absolute;
  z-index: 10;
}

.ai-ops-resize--tl { top: 0; left: 0; width: 12px; height: 12px; cursor: nw-resize; }
.ai-ops-resize--t  { top: 0; left: 12px; right: 12px; height: 6px; cursor: n-resize; }
.ai-ops-resize--tr { top: 0; right: 0; width: 12px; height: 12px; cursor: ne-resize; }
.ai-ops-resize--r  { top: 12px; right: 0; bottom: 12px; width: 6px; cursor: e-resize; }
.ai-ops-resize--br { bottom: 0; right: 0; width: 12px; height: 12px; cursor: se-resize; }
.ai-ops-resize--b  { bottom: 0; left: 12px; right: 12px; height: 6px; cursor: s-resize; }
.ai-ops-resize--bl { bottom: 0; left: 0; width: 12px; height: 12px; cursor: sw-resize; }
.ai-ops-resize--l  { top: 12px; left: 0; bottom: 12px; width: 6px; cursor: w-resize; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .ai-ops-ball {
    right: 16px;
    bottom: 16px;
    width: 48px;
    height: 48px;
  }

  .ai-ops-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 60px);
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  .ai-ops-panel {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    right: 0 !important;
    bottom: 0 !important;
    top: 0 !important;
    left: 0 !important;
  }
}
