/* ===== 西格尔涂料 AI 智能客服 widget ===== */
:root {
  --xb-primary: #1f6feb;
  --xb-primary-dark: #1858c4;
  --xb-bg: #ffffff;
  --xb-bg-soft: #f5f7fb;
  --xb-text: #1a1a1a;
  --xb-text-soft: #6b7280;
  --xb-border: #e5e7eb;
  --xb-bubble-user: #1f6feb;
  --xb-bubble-ai: #f0f4ff;
  --xb-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  --xb-radius: 14px;
}

.xb-btn {
  position: fixed;
  right: 18px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--xb-primary), #4f9bff);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(31, 111, 235, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  z-index: 1080;
  transition: transform 0.2s, box-shadow 0.2s;
}
.xb-btn:hover { transform: scale(1.06); box-shadow: 0 10px 30px rgba(31, 111, 235, 0.55); }
.xb-btn .badge {
  position: absolute; top: -2px; right: -2px;
  background: #ff4d4f; color: #fff;
  font-size: 11px; min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  border: 2px solid #fff;
  box-sizing: border-box;
}
.xb-btn .stats {
  position: absolute;
  bottom: -28px; right: 0;
  background: rgba(31, 111, 235, 0.95);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  font-weight: 500;
  display: none;
}
.xb-btn:hover .stats { display: inline !important; }
.xb-btn.hidden { display: none; }

.xb-panel {
  position: fixed;
  right: 18px;
  bottom: 96px;
  width: 360px;
  max-width: calc(100vw - 24px);
  height: 540px;
  max-height: calc(100vh - 130px);
  background: var(--xb-bg);
  border-radius: var(--xb-radius);
  box-shadow: var(--xb-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1080;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
.xb-panel.open { display: flex; }

.xb-header {
  background: linear-gradient(135deg, var(--xb-primary), #4f9bff);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.xb-header .avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.xb-header .meta { flex: 1; line-height: 1.3; }
.xb-header .meta .name { font-weight: 600; font-size: 15px; }
.xb-header .meta .status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 4px; }
.xb-header .meta .status::before {
  content: ""; width: 7px; height: 7px; background: #5dff8a; border-radius: 50%;
  box-shadow: 0 0 4px rgba(93,255,138,0.7);
}
.xb-header .close {
  background: transparent; border: 0; color: #fff;
  font-size: 22px; cursor: pointer; opacity: 0.85;
  width: 28px; height: 28px; line-height: 1; padding: 0;
}
.xb-header .close:hover { opacity: 1; }

.xb-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: var(--xb-bg-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.xb-body::-webkit-scrollbar { width: 6px; }
.xb-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.xb-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.xb-msg .av {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.xb-msg .bub {
  padding: 9px 12px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.xb-msg.ai { align-self: flex-start; }
.xb-msg.ai .av { background: linear-gradient(135deg, var(--xb-primary), #4f9bff); color: #fff; }
.xb-msg.ai .bub { background: var(--xb-bubble-ai); color: var(--xb-text); border-bottom-left-radius: 4px; }
.xb-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.xb-msg.user .av { background: #fde68a; color: #92400e; }
.xb-msg.user .bub { background: var(--xb-bubble-user); color: #fff; border-bottom-right-radius: 4px; }

.xb-typing {
  display: inline-flex; gap: 3px; padding: 4px 0;
}
.xb-typing span {
  width: 6px; height: 6px; background: #94a3b8; border-radius: 50%;
  animation: xb-typing 1.2s infinite;
}
.xb-typing span:nth-child(2) { animation-delay: 0.15s; }
.xb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes xb-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.xb-quick {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 14px 10px;
  background: var(--xb-bg-soft);
}
.xb-quick button {
  background: #fff;
  border: 1px solid var(--xb-border);
  color: var(--xb-primary);
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.xb-quick button:hover {
  background: var(--xb-primary);
  color: #fff;
  border-color: var(--xb-primary);
}

.xb-footer {
  border-top: 1px solid var(--xb-border);
  background: #fff;
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.xb-footer textarea {
  flex: 1;
  border: 1px solid var(--xb-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
  outline: none;
  max-height: 96px;
  min-height: 38px;
  line-height: 1.4;
  transition: border-color 0.15s;
}
.xb-footer textarea:focus { border-color: var(--xb-primary); }
.xb-footer button.send {
  background: var(--xb-primary);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  height: 38px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.xb-footer button.send:hover:not(:disabled) { background: var(--xb-primary-dark); }
.xb-footer button.send:disabled { background: #cbd5e1; cursor: not-allowed; }

.xb-handoff-card {
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px;
  margin-top: 6px;
  font-size: 13px;
}
.xb-handoff-card .title {
  font-weight: 600;
  color: #b45309;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.xb-handoff-card input,
.xb-handoff-card select {
  width: 100%;
  border: 1px solid var(--xb-border);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  margin-bottom: 6px;
  box-sizing: border-box;
  outline: none;
  font-family: inherit;
}
.xb-handoff-card input:focus,
.xb-handoff-card select:focus { border-color: var(--xb-primary); }
.xb-handoff-card button {
  background: #b45309;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  font-weight: 500;
}
.xb-handoff-card button:hover { background: #92400e; }
.xb-handoff-card .alt {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #fde68a;
  font-size: 12px;
  color: var(--xb-text-soft);
}

@media (max-width: 480px) {
  .xb-panel { right: 8px; bottom: 80px; width: calc(100vw - 16px); height: 70vh; }
  .xb-btn { right: 12px; bottom: 16px; }
}

@media print {
  .xb-btn, .xb-panel { display: none !important; }
}