/* StaticAI Widget 样式 —— 类名前缀 sai-，避免与宿主站点冲突 */
:root {
  --sai-accent: #4f46e5;
  --sai-bg: #ffffff;
  --sai-bg-soft: #f5f6f8;
  --sai-text: #1c1e21;
  --sai-text-soft: #5f6368;
  --sai-border: #e6e8eb;
  --sai-radius: 16px;
  --sai-shadow: 0 12px 40px rgba(20, 22, 26, 0.16);
  --sai-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC",
    "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

.sai-chat,
.sai-fab,
.sai-panel {
  font-family: var(--sai-font);
  box-sizing: border-box;
  color: var(--sai-text);
}

.sai-chat *,
.sai-panel * { box-sizing: border-box; }

/* ---------- 内联面板 ---------- */
.sai-chat {
  display: flex;
  flex-direction: column;
  height: 480px;
  background: var(--sai-bg);
  border: 1px solid var(--sai-border);
  border-radius: var(--sai-radius);
  overflow: hidden;
}

.sai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--sai-border);
  background: var(--sai-bg);
}

.sai-header .sai-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sai-accent);
  flex: none;
}

.sai-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.sai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--sai-bg-soft);
}

.sai-msg {
  max-width: 82%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  white-space: normal;
  word-break: break-word;
}

.sai-msg p { margin: 0 0 8px; }
.sai-msg p:last-child { margin-bottom: 0; }
.sai-msg ul { margin: 4px 0; padding-left: 18px; }
.sai-msg li { margin: 4px 0; }
.sai-msg strong { font-weight: 600; }

.sai-msg-user {
  align-self: flex-end;
  background: var(--sai-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.sai-msg-bot {
  align-self: flex-start;
  background: var(--sai-bg);
  border: 1px solid var(--sai-border);
  border-bottom-left-radius: 4px;
}

.sai-msg-bot .sai-answer-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--sai-accent);
}

.sai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.sai-chip {
  border: 1px solid var(--sai-border);
  background: var(--sai-bg);
  color: var(--sai-text-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.sai-chip:hover { border-color: var(--sai-accent); color: var(--sai-accent); }

.sai-inputbar {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--sai-border);
  background: var(--sai-bg);
}

.sai-inputbar textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--sai-border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  max-height: 120px;
  background: var(--sai-bg-soft);
}

.sai-inputbar textarea:focus { border-color: var(--sai-accent); background: var(--sai-bg); }

.sai-send {
  flex: none;
  border: none;
  border-radius: 12px;
  background: var(--sai-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 0 18px;
  cursor: pointer;
}

.sai-send:disabled { opacity: 0.5; cursor: not-allowed; }

.sai-status {
  align-self: flex-start;
  color: var(--sai-text-soft);
  font-size: 13px;
  padding: 8px 4px;
}

.sai-thinking {
  color: var(--sai-text-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sai-thinking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sai-accent);
  display: inline-block;
  animation: sai-pulse 1.1s ease-in-out infinite;
}

@keyframes sai-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ---------- 悬浮按钮 + 浮窗（外站嵌入） ---------- */
.sai-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sai-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--sai-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483000;
}

.sai-fab svg { width: 26px; height: 26px; }

.sai-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 360px;
  height: 520px;
  background: var(--sai-bg);
  border-radius: var(--sai-radius);
  box-shadow: var(--sai-shadow);
  overflow: hidden;
  z-index: 2147483000;
  display: none;
  flex-direction: column;
}

.sai-panel.sai-open { display: flex; }

.sai-panel .sai-chat { height: 100%; border: none; border-radius: 0; }
.sai-panel .sai-messages { height: auto; }

.sai-close {
  margin-left: auto;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: var(--sai-text-soft);
  padding: 4px 8px;
}

@media (max-width: 480px) {
  .sai-panel { right: 12px; bottom: 84px; width: calc(100vw - 24px); height: 70vh; }
  .sai-fab { right: 16px; bottom: 16px; }
}
