/* 站内信浮动入口 + 对话框 */
.msg-float-entry {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 440;
}
.msg-float-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #2549d8;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 73, 216, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.msg-float-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(37, 73, 216, 0.55);
}
.msg-float-btn .msg-float-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e53935;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  display: none;
}
.msg-float-btn.has-unread .msg-float-badge {
  display: block;
}
.msg-float-panel {
  position: fixed;
  right: 24px;
  bottom: 88px;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 120px);
  z-index: 439;
}
.msg-float-panel.open {
  display: flex;
}
.msg-float-panel.msg-float-panel--guest {
  min-height: 420px;
}
.msg-float-panel-hd {
  padding: 14px 16px;
  background: #25283c;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}
.msg-float-panel-hd h6 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-float-panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.msg-float-panel-hd .btn-switch-chat {
  background: none;
  border: none;
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 4px;
  opacity: 0.85;
}
.msg-float-panel-hd .btn-switch-chat:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}
.msg-float-panel-hd .close-panel {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 0 0 4px;
}
.msg-float-switch-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border-bottom: 1px solid #e8eaed;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  z-index: 10;
}
.msg-float-switch-menu.open {
  display: block;
}
.msg-float-switch-menu .switch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
  font-size: 13px;
  color: #25283c;
}
.msg-float-switch-menu .switch-item:last-child {
  border-bottom: none;
}
.msg-float-switch-menu .switch-item:hover {
  background: #f7f8fa;
}
.msg-float-switch-menu .switch-item.cur {
  background: #eef3ff;
  color: #2549d8;
  font-weight: 600;
}
.msg-float-switch-menu .switch-item .switch-unread {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #e53935;
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.msg-float-guest {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  padding: 32px 24px;
  background: #f7f8fa;
  text-align: center;
  box-sizing: border-box;
}
.msg-float-panel--guest .msg-float-guest {
  display: flex !important;
}
.msg-float-panel--guest .msg-float-body {
  display: none !important;
}
.msg-float-guest-inner {
  width: 100%;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.msg-float-guest p {
  margin: 0;
  color: #666;
  font-size: 14px;
  line-height: 1.55;
  text-transform: none;
}
.msg-float-guest .btn-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
}
.msg-float-guest a.btn-msg {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
  line-height: 1.4;
}
.msg-float-guest a.btn-primary-msg {
  background: #2549d8;
  color: #fff;
  border: 1px solid #2549d8;
}
.msg-float-guest a.btn-primary-msg:hover {
  background: #1f3eb8;
  border-color: #1f3eb8;
  color: #fff;
}
.msg-float-guest a.btn-outline-msg {
  background: #fff;
  border: 1px solid #2549d8;
  color: #2549d8;
}
.msg-float-guest a.btn-outline-msg:hover {
  background: #eef3ff;
  color: #2549d8;
}
.msg-float-body {
  display: flex;
  flex-direction: column;
  min-height: 360px;
  max-height: 480px;
}
.msg-float-history {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}
.msg-float-history .li,
.msg-float-history .li.r {
  float: none !important;
  width: fit-content !important;
  max-width: 92%;
  min-width: 0 !important;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 0;
  clear: both;
  box-sizing: border-box;
}
/* 用户发送：右侧 */
.msg-float-history .li {
  align-self: flex-end;
  flex-direction: row-reverse;
}
/* 客服/后台：左侧 */
.msg-float-history .li.r {
  align-self: flex-start;
  flex-direction: row;
}
.msg-float-history .li .avatar {
  width: 28px;
  height: 28px;
  line-height: 28px;
  font-size: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #2549d8;
  color: #fff;
  text-align: center;
}
.msg-float-history .li.r .avatar {
  background: #dde3ea;
  color: #5f6368;
}
.msg-float-history .li.r .csm-avatar-wrap > .avatar,
.msg-float-history .li.r .csm-avatar-wrap > .avatar-trigger {
  background: #2549d8;
  color: #fff;
}
.msg-float-history .csm-avatar-wrap {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.msg-float-history .csm-avatar-wrap > .avatar,
.msg-float-history .csm-avatar-wrap > .avatar-trigger {
  width: 28px;
  height: 28px;
  line-height: 28px;
  font-size: 14px;
  border-radius: 50%;
  text-align: center;
}
.msg-float-history .li.r .csm-hover-card {
  right: auto;
  left: calc(100% + 10px);
}
.msg-float-history .li .msg {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  width: auto;
  padding: 0 !important;
  float: none !important;
  background: transparent;
  box-shadow: none;
  text-align: right;
}
.msg-float-history .li.r .msg {
  text-align: left;
}
.msg-float-history .li .msg .ti {
  float: none !important;
  font-size: 12px;
  font-weight: 600;
  color: #5f6368;
  margin-bottom: 2px;
  text-align: right;
}
.msg-float-history .li.r .msg .ti {
  text-align: left;
}
.msg-float-history .li .msg .time {
  float: none !important;
  font-size: 11px;
  color: #999;
  margin-bottom: 4px;
  text-align: right;
}
.msg-float-history .li.r .msg .time {
  text-align: left;
}
.msg-float-history .li .msg .content {
  float: none !important;
  display: inline-block;
  width: auto;
  max-width: 100%;
  box-sizing: border-box;
  background: #2549d8;
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px 4px 12px 12px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(37, 73, 216, 0.2);
  border: 1px solid #2549d8;
  word-break: break-word;
  text-align: left;
}
.msg-float-history .li.r .msg .content {
  background: #fff;
  color: #25283c;
  border-color: #e8eaed;
  border-radius: 4px 12px 12px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.msg-float-history .li .msg .content .con {
  float: none !important;
  display: block;
  width: auto;
  font-size: 12px;
  line-height: 1.5;
  color: #fff;
  white-space: normal;
  word-wrap: break-word;
  padding: 0;
}
.msg-float-history .li .msg .content .msg-dear {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.4;
}
.msg-float-history .li .msg .content .msg-text {
  display: block;
  line-height: 1.5;
}
.msg-float-history .li .msg .content .msg-thanks {
  display: block;
  margin-top: 6px;
  line-height: 1.4;
  opacity: 0.92;
}
.msg-float-history .li.r .msg .content .con,
.msg-float-history .li.r .msg .content .msg-text,
.msg-float-history .li.r .msg .content .msg-dear,
.msg-float-history .li.r .msg .content .msg-thanks {
  color: #25283c;
}
.msg-float-history .li.r .msg .msg-bubble-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 6px;
  max-width: 100%;
}
.msg-float-history .li.r .msg .msg-bubble-row .content {
  flex: 0 1 auto;
  min-width: 0;
}
.msg-float-history .msg-read-receipt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 4px;
  line-height: 1;
  user-select: none;
}
.msg-float-history .msg-read-receipt .msg-read-icon {
  font-size: 14px;
  line-height: 1;
}
.msg-float-history .msg-read-receipt.is-read .msg-read-icon {
  color: #9aa0a6;
}
.msg-float-history .msg-read-receipt.is-unread .msg-read-icon {
  color: #2549d8;
}
.msg-float-history .li .msg .content img {
  display: block;
  max-width: 160px;
  max-height: 160px;
  border-radius: 8px;
  margin-top: 8px;
  cursor: pointer;
}
.msg-float-history .li .msg .content .attachment_list {
  float: none !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  border-top: none;
  font-size: 12px;
  color: #fff;
  text-decoration: none;
}
.msg-float-history .li.r .msg .content .attachment_list {
  background: rgba(0, 0, 0, 0.04);
  color: #2549d8;
}
.msg-float-compose {
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fff;
  position: relative;
}
.msg-float-compose.drag-over {
  background: #eef3ff;
  outline: 2px dashed #2549d8;
  outline-offset: -4px;
}
.msg-float-drop-hint {
  display: none;
  font-size: 12px;
  color: #2549d8;
  text-align: center;
  padding: 4px 0 6px;
}
.msg-float-compose.drag-over .msg-float-drop-hint {
  display: block;
}
.msg-float-pending {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg-float-pending-item {
  position: relative;
  width: 64px;
  height: 64px;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  background: #f7f8fa;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.msg-float-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.msg-float-file-icon {
  font-size: 24px;
  color: #888;
}
.msg-float-file-name {
  font-size: 10px;
  color: #666;
  padding: 0 4px;
  text-align: center;
  word-break: break-all;
  max-height: 32px;
  overflow: hidden;
}
.msg-float-pending-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.msg-float-more-tip {
  margin: 0;
  padding: 6px 12px;
  text-align: center;
  font-size: 12px;
  background: #f7f8fa;
  border-top: 1px solid #eee;
}
.msg-float-more-tip a {
  color: #2549d8;
  text-decoration: none;
}
.msg-float-empty {
  text-align: center;
  color: #999;
  padding: 20px;
  font-size: 13px;
  margin: 0;
}
.msg-float-compose textarea {
  width: 100%;
  min-height: 60px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px;
  font-size: 13px;
  resize: none;
  box-sizing: border-box;
}
.msg-float-compose .send-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.msg-float-compose .send-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.msg-float-compose .btn-attach {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: #666;
  font-size: 16px;
  padding: 0;
}
.msg-float-compose .btn-attach:hover {
  border-color: #2549d8;
  color: #2549d8;
}
.msg-float-compose .link-full {
  font-size: 12px;
  color: #2549d8;
  text-decoration: none;
}
.msg-float-compose button {
  background: #2549d8;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
}
.msg-float-type-tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.msg-float-type-tag.service {
  background: #e3f2fd;
  color: #1565c0;
}
.msg-float-type-tag.order {
  background: #fff3e0;
  color: #e65100;
}
.msg-float-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0,0,0,0.88);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.msg-float-lightbox.open {
  display: flex;
}
.msg-float-lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.msg-float-lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.msg-float-history .content img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 6px;
}
/* CSM avatar hover card (shared with message index) */
.csm-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}
.csm-avatar-wrap:hover {
  z-index: 1002;
}
.csm-avatar-wrap > .avatar,
.csm-avatar-wrap > .avatar-trigger {
  display: block;
  width: 28px;
  height: 28px;
  line-height: 28px;
  border-radius: 50%;
  font-size: 14px;
  text-align: center;
  background: #2549d8;
  color: #fff;
  cursor: pointer;
}
.csm-avatar-wrap > img.avatar-trigger {
  object-fit: cover;
  line-height: normal;
}
.csm-avatar-wrap > img.avatar-img {
  display: block;
}
.csm-card-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.csm-hover-card {
  display: none;
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  width: 240px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid #e8eaed;
  z-index: 1001;
  pointer-events: none;
}
.csm-avatar-wrap:hover .csm-hover-card {
  display: block;
  pointer-events: auto;
}
.csm-card-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
}
.csm-card-info {
  flex: 1;
  min-width: 0;
}
.csm-card-info .csm-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #2549d8;
  line-height: 1.3;
}
.csm-card-info .csm-title {
  display: block;
  font-size: 11px;
  color: #9aa0a6;
  margin-top: 2px;
  line-height: 1.3;
}
.csm-card-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eef3ff;
  font-size: 20px;
  color: #2549d8;
  flex-shrink: 0;
}
.csm-card-divider {
  height: 1px;
  background: #e8eaed;
  margin: 0 14px;
}
.csm-card-body {
  padding: 8px 14px 12px;
  font-size: 12px;
  color: #5f6368;
  line-height: 1.6;
}
.csm-card-body .csm-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.csm-card-body .csm-row:last-child {
  margin-bottom: 0;
}
.csm-card-body .csm-label {
  font-weight: 600;
  color: #25283c;
  min-width: 16px;
}
.csm-card-body .csm-email {
  flex: 1;
  min-width: 0;
  word-break: break-all;
  text-transform: uppercase;
  font-size: 11px;
}
.csm-copy-email {
  background: none;
  border: none;
  color: #9aa0a6;
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
  pointer-events: auto;
}
.csm-copy-email:hover {
  color: #2549d8;
}
/* 与返回顶部按钮上下对齐、错开间距（message 在下，back-to-top 在上） */
.back-to-top {
  right: 24px;
  bottom: 96px;
  line-height: 1;
}
@media (max-width: 768px) {
  .msg-float-entry {
    right: 16px;
    bottom: 20px;
  }
  .msg-float-panel {
    right: 16px;
    bottom: 84px;
    width: calc(100vw - 32px);
  }
  .back-to-top {
    right: 16px;
    bottom: 88px;
  }
}
