.chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A183FD 0%, #8B5CF6 50%, #7C3AED 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100000;
  box-shadow: 0 6px 24px rgba(161, 131, 253, 0.45), 0 2px 8px rgba(124, 58, 237, 0.25);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}

.chat-bubble::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(161, 131, 253, 0.35), rgba(139, 92, 246, 0.15));
  z-index: -1;
  animation: bubbleRing 2.5s ease-in-out infinite;
}

@keyframes bubbleRing {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.12); opacity: 0; }
}

.chat-bubble:hover {
  transform: scale(1.12) rotate(-5deg);
  box-shadow: 0 10px 36px rgba(161, 131, 253, 0.55), 0 4px 14px rgba(124, 58, 237, 0.35);
}

.chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
  transition: transform 0.3s ease;
}

.chat-bubble:hover svg {
  transform: translateX(2px);
}

.chat-bubble .chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, #FF4757, #FF3838);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid #fff;
  font-family: 'Jost', sans-serif;
  box-shadow: 0 2px 8px rgba(255, 71, 87, 0.45);
  animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgePop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  height: 540px;
  background: #fff;
  border-radius: 20px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 8px 20px rgba(161, 131, 253, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: none;
  flex-direction: column;
  z-index: 100000;
  overflow: hidden;
  animation: chatSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Jost', sans-serif;
  border: 1px solid rgba(161, 131, 253, 0.08);
}

.chat-window.open {
  display: flex;
}

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header {
  background: linear-gradient(135deg, #A183FD 0%, #8B5CF6 40%, #7C3AED 100%);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.chat-header::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 13px;
  position: relative;
  z-index: 1;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255,255,255,0.2);
}

.chat-avatar svg {
  width: 23px;
  height: 23px;
  fill: #fff;
}

.chat-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chat-header-info span {
  font-size: 11.5px;
  opacity: 0.85;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.chat-close {
  width: 34px;
  height: 34px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.25s ease;
  position: relative;
  z-index: 1;
  line-height: 1;
  font-weight: 300;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.32);
  transform: rotate(90deg);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: linear-gradient(180deg, #FAF8FF 0%, #F5F1FF 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #C4B5FD, #A183FD);
  border-radius: 10px;
}

.msg {
  max-width: 82%;
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: msgIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg.agent {
  align-self: flex-start;
  background: #fff;
  color: #374151;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(161, 131, 253, 0.07);
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #A183FD 0%, #8B5CF6 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(161, 131, 253, 0.3);
}

.msg .msg-time {
  font-size: 10px;
  opacity: 0.55;
  margin-top: 5px;
  text-align: right;
  font-weight: 400;
}

.msg .msg-img {
  max-width: 200px;
  border-radius: 12px;
  cursor: pointer;
  display: block;
  transition: transform 0.25s ease;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
}

.msg .msg-img:hover {
  transform: scale(1.03);
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 18px;
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(161, 131, 253, 0.07);
}

.chat-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A183FD, #8B5CF6);
  animation: typingDot 1.4s infinite ease-in-out;
  opacity: 0.4;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 80%, 100% { opacity: 0.4; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-6px); }
}

.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid rgba(161, 131, 253, 0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}

.chat-input-area textarea {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 9px 18px;
  font-size: 13px;
  font-family: 'Jost', sans-serif;
  resize: none;
  outline: none;
  max-height: 80px;
  min-height: 36px;
  line-height: 1.4;
  transition: all 0.3s ease;
  background: linear-gradient(135deg, #F8F4FF, #F3EEFF);
  color: #333;
  box-shadow: inset 0 1px 2px rgba(161, 131, 253, 0.06), 0 1px 2px rgba(0,0,0,0.03);
}

.chat-input-area textarea:focus {
  background: #fff;
  box-shadow:
    inset 0 1px 2px rgba(161, 131, 253, 0.06),
    0 0 0 2px rgba(161, 131, 253, 0.18),
    0 2px 6px rgba(161, 131, 253, 0.08);
}

.chat-input-area textarea::placeholder {
  color: #B0A2D6;
  letter-spacing: 0.01em;
}

.chat-input-area .btn-send {
  width: 36px;
  height: 36px;
  border: none;
  background: linear-gradient(135deg, #A183FD 0%, #8B5CF6 100%);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(161, 131, 253, 0.38);
  position: relative;
  overflow: hidden;
}

.chat-input-area .btn-send::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.chat-input-area .btn-send:hover {
  transform: scale(1.12) translateY(-1px);
  box-shadow: 0 5px 18px rgba(161, 131, 253, 0.48);
}

.chat-input-area .btn-send:hover::before {
  opacity: 1;
}

.chat-input-area .btn-send:active {
  transform: scale(0.95) translateY(0);
  box-shadow: 0 2px 8px rgba(161, 131, 253, 0.3);
}

.chat-input-area .btn-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
  position: relative;
  z-index: 1;
}

.chat-input-area .btn-image {
  width: 32px;
  height: 32px;
  border: none;
  background: linear-gradient(135deg, #F3EEFF, #EDE7FF);
  color: #A183FD;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(161, 131, 253, 0.08), 0 1px 3px rgba(0,0,0,0.04);
}

.chat-input-area .btn-image:hover {
  background: linear-gradient(135deg, #E8E0FF, #DDD4FF);
  transform: scale(1.12) rotate(-5deg);
  box-shadow: 0 2px 8px rgba(161, 131, 253, 0.2);
}

.chat-input-area .btn-image:active {
  transform: scale(0.95) rotate(0);
}

.chat-input-area .btn-image svg {
  width: 17px;
  height: 17px;
  fill: #A183FD;
}

#chat-image-input {
  display: none;
}

@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 16px);
    height: calc(100vh - 130px);
    bottom: 90px;
    right: 8px;
    border-radius: 18px;
  }

  .chat-bubble {
    bottom: 20px;
    right: 16px;
    width: 54px;
    height: 54px;
  }

  .chat-bubble svg {
    width: 24px;
    height: 24px;
  }

  .chat-messages {
    padding: 14px 12px;
  }

  .chat-input-area {
    padding: 10px 12px;
    gap: 6px;
  }

  .chat-input-area .btn-send,
  .chat-input-area .btn-image {
    width: 34px;
    height: 34px;
  }
}

/* ========== QR Code Widget Styles ========== */
.qr-bubble {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #A183FD 0%, #8B5CF6 50%, #7C3AED 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99999;
  box-shadow: 0 6px 24px rgba(161, 131, 253, 0.45), 0 2px 8px rgba(124, 58, 237, 0.25);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}

.qr-bubble::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(161, 131, 253, 0.35), rgba(139, 92, 246, 0.15));
  z-index: -1;
  animation: bubbleRing 2.5s ease-in-out infinite;
}

.qr-bubble:hover {
  transform: scale(1.12) translateY(-2px);
  box-shadow: 0 10px 32px rgba(161, 131, 253, 0.55), 0 4px 12px rgba(124, 58, 237, 0.35);
}

.qr-bubble svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

/* QR Popup - 固定显示在左下角 */
.qr-popup {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 300px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(124, 58, 237, 0.3), 0 4px 16px rgba(0, 0, 0, 0.08);
  z-index: 100000;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

/* 隐藏触发按钮（因为弹窗已固定显示） */
.qr-bubble {
  display: none !important;
}

/* 隐藏关闭按钮（弹窗不可关闭，始终显示） */
.qr-close {
  display: none !important;
}

.qr-popup-header {
  display: flex;
  align-items: center;
  justify-content: center; /* 标题居中 */
  padding: 18px 20px;
  background: linear-gradient(135deg, #A183FD 0%, #9B7CFD 50%, #c49bfd 100%);
  color: #fff;
}

.qr-popup-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Jost', sans-serif;
}

.qr-popup-title svg {
  fill: #fff;
}

/* 关闭按钮已禁用 - 弹窗始终显示不可关闭 */

.qr-content {
  padding: 24px 20px 20px;
  text-align: center;
}

.qr-image-wrapper {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  border: 2px solid #f0e6ff;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faf8ff;
  padding: 10px;
}

.qr-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.qr-placeholder {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.qr-tip {
  font-size: 13px;
  color: #888;
  line-height: 1.6;
  margin: 0;
  font-family: 'Jost', sans-serif;
}

@media screen and (max-width: 480px) {
  .qr-popup {
    width: calc(100vw - 40px);
    right: 20px;
    bottom: 160px;
  }

  .qr-bubble {
    bottom: 90px;
    right: 20px;
    width: 52px;
    height: 52px;
  }
}

/* ========== Chat File/Image Message Styles ========== */
.msg .file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f0f4ff;
  border-radius: 10px;
  color: #A183FD !important;
  text-decoration: none;
  font-size: 13px;
  margin-top: 6px;
  transition: background 0.2s;
}
.msg .file-link:hover {
  background: #e8eeff;
}

.msg .file-name {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 4px;
  word-break: break-all;
}