/* ============================================================
   Live Chat 右侧浮动客服组件（中英双语，按域名自动切换）
   - .cn  → 中文接待
   - .com → 英文接待
   依赖：/static/js/livechat.js
   ============================================================ */

.sr-livechat {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9998;
  font-size: 14px;
  font-family: inherit;
}

.sr-livechat-box {
  background: #fff;
  border-radius: 8px 0 0 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
  overflow: hidden;
  width: 44px;
  transition: width .3s cubic-bezier(.25, .8, .25, 1);
}

.sr-livechat-box:hover,
.sr-livechat-box:focus-within {
  width: 200px;
}

.sr-livechat-box ul {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

.sr-livechat-box ul li {
  position: relative;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  white-space: nowrap;
  transition: background .2s ease;
}

.sr-livechat-box ul li:hover {
  background: #fff6ef;
}

.sr-livechat-box ul li a,
.sr-livechat-box ul li button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: 14px;
  color: #fff;
  background: #f47920;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  transition: background .2s ease, transform .2s ease;
  font-family: inherit;
  padding: 0;
}

.sr-livechat-box ul li:hover a,
.sr-livechat-box ul li:hover button {
  transform: scale(1.08);
}

.sr-livechat-box ul li a svg,
.sr-livechat-box ul li button svg {
  width: 15px;
  height: 15px;
  fill: #fff;
  display: block;
}

/* 各渠道品牌色 */
.sr-livechat-box .sr-ic-chat     { background: #f47920; }
.sr-livechat-box .sr-ic-phone    { background: #f47920; }
.sr-livechat-box .sr-ic-mail     { background: #ea4335; }
.sr-livechat-box .sr-ic-whatsapp { background: #25d366; }
.sr-livechat-box .sr-ic-wechat   { background: #07c160; }
.sr-livechat-box .sr-ic-facebook { background: #3b5998; }
.sr-livechat-box .sr-ic-twitter  { background: #000000; }
.sr-livechat-box .sr-ic-youtube  { background: #ff0000; }
.sr-livechat-box .sr-ic-linkedin { background: #0077b5; }
.sr-livechat-box .sr-ic-instagram{ background: linear-gradient(45deg,#f09433 0%,#e6683c 25%,#dc2743 50%,#cc2366 75%,#bc1888 100%); }

/* 国内渠道品牌色（中文站） */
.sr-livechat-box .sr-ic-qq      { background: #12b7f5; }
.sr-livechat-box .sr-ic-douyin  { background: #111111; }
.sr-livechat-box .sr-ic-xhs     { background: #ff2442; }
.sr-livechat-box .sr-ic-weibo   { background: #e6162d; }

/* 微信二维码浮层 */
.sr-wx-pop {
  position: fixed;
  z-index: 100002;
  width: 168px;
  padding: 14px 14px 12px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
  text-align: center;
  animation: sr-wx-in .18s ease-out;
}
@keyframes sr-wx-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.sr-wx-pop .sr-wx-title { font-size: 14px; color: #222; font-weight: 600; margin-bottom: 10px; }
.sr-wx-pop img { width: 140px; height: 140px; display: block; margin: 0 auto; }
.sr-wx-pop .sr-wx-id {
  font-size: 17px; color: #07c160; font-weight: 700; letter-spacing: .5px;
  padding: 12px 0 4px; word-break: break-all;
}
.sr-wx-pop .sr-wx-idalt { font-size: 12px; color: #666; margin-top: 8px; word-break: break-all; }
.sr-wx-pop .sr-wx-tip { font-size: 11.5px; color: #999; margin: 8px 0 10px; }
.sr-wx-pop .sr-wx-copy {
  width: 100%; border: 0; border-radius: 6px; cursor: pointer;
  background: #07c160; color: #fff; font-size: 13px; padding: 8px 0;
  font-family: inherit; line-height: 1.3;
}
.sr-wx-pop .sr-wx-copy:hover { background: #06ad56; }

.sr-livechat-box ul li span.sr-lc-label {
  color: #2c3e50;
  font-size: 13px;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity .2s ease, transform .2s ease;
}

.sr-livechat-box:hover ul li span.sr-lc-label,
.sr-livechat-box:focus-within ul li span.sr-lc-label {
  opacity: 1;
  transform: translateX(0);
  transition-delay: .1s;
}

.sr-livechat-box:not(:hover):not(:focus-within) ul li span.sr-lc-label {
  transition-delay: 0s;
}

/* 访客还没打开过聊天窗时，客服图标呼吸跳动吸引注意 */
.sr-livechat:not(.sr-seen) .sr-ic-chat {
  animation: srBeat 1.8s ease-in-out infinite;
}
@keyframes srBeat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.14); }
}
@media (prefers-reduced-motion: reduce) {
  .sr-livechat:not(.sr-seen) .sr-ic-chat { animation: none; }
}

/* 未读红点 */
.sr-unread {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #ff3b30;
  color: #fff;
  border-radius: 8px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 0 0 2px #fff;
  display: none;
}

.sr-unread.show { display: block; }

/* ============================================================
   聊天面板
   ============================================================ */
.sr-chat-panel {
  position: fixed;
  right: 16px;
  bottom: 24px;
  width: 360px;
  height: 540px;
  max-height: calc(100vh - 48px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  transform: translateY(20px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.34, 1.56, .64, 1);
  font-family: inherit;
}

.sr-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sr-chat-header {
  background: linear-gradient(135deg, #f47920 0%, #ffa04d 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sr-chat-header .sr-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  color: #f47920;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
}

.sr-chat-header .sr-avatar svg { width: 22px; height: 22px; fill: #f47920; }

.sr-chat-header .sr-info { flex: 1; min-width: 0; }

.sr-chat-header .sr-name {
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-chat-header .sr-status {
  font-size: 12px;
  opacity: .95;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sr-chat-header .sr-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5fff7a;
  box-shadow: 0 0 0 2px rgba(95, 255, 122, .35);
  animation: srPulse 1.8s ease-in-out infinite;
}

@keyframes srPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(95, 255, 122, .35); }
  50%      { box-shadow: 0 0 0 5px rgba(95, 255, 122, .12); }
}

.sr-chat-header .sr-close {
  background: rgba(255, 255, 255, .18);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease;
  padding: 0;
  flex-shrink: 0;
}

.sr-chat-header .sr-close svg { width: 14px; height: 14px; fill: #fff; }
.sr-chat-header .sr-close:hover { background: rgba(255, 255, 255, .34); }

.sr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f9fc;
  scroll-behavior: smooth;
}

.sr-chat-messages::-webkit-scrollbar { width: 6px; }
.sr-chat-messages::-webkit-scrollbar-thumb { background: #cdd5e0; border-radius: 3px; }

.sr-msg {
  display: flex;
  margin-bottom: 12px;
  gap: 8px;
  animation: srMsgIn .3s ease;
}

@keyframes srMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sr-msg .sr-ba {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f47920;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.sr-msg .sr-ba svg { width: 16px; height: 16px; fill: #fff; }
.sr-msg.user .sr-ba { background: #4a90e2; }

.sr-msg .sr-bubble {
  background: #fff;
  padding: 9px 12px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  max-width: 240px;
  line-height: 1.6;
  font-size: 14px;
  color: #2c3e50;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  word-break: break-word;
  white-space: pre-wrap;
}

.sr-msg.user { flex-direction: row-reverse; }

.sr-msg.user .sr-bubble {
  background: #4a90e2;
  color: #fff;
  border-radius: 12px;
  border-top-right-radius: 4px;
}

.sr-msg .sr-time {
  font-size: 10px;
  color: #95a5a6;
  margin-top: 4px;
  padding: 0 4px;
}

.sr-msg.user .sr-time { text-align: right; }

.sr-typing { display: flex; gap: 4px; padding: 12px 14px; }

.sr-typing i {
  width: 7px;
  height: 7px;
  background: #95a5a6;
  border-radius: 50%;
  animation: srBounce 1.2s infinite;
}

.sr-typing i:nth-child(2) { animation-delay: .2s; }
.sr-typing i:nth-child(3) { animation-delay: .4s; }

@keyframes srBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

.sr-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 12px;
  padding-left: 38px;
}

.sr-quick button {
  background: #fff;
  border: 1px solid #d6e4eb;
  color: #f47920;
  padding: 6px 11px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s ease, border-color .2s ease;
}

.sr-quick button:hover {
  background: #fff6ef;
  border-color: #f47920;
}

.sr-chat-input {
  border-top: 1px solid #e3e8ef;
  padding: 12px;
  display: flex;
  gap: 8px;
  background: #fff;
}

.sr-chat-input input {
  flex: 1;
  min-width: 0;
  border: 1px solid #d6e4eb;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color .2s ease;
}

.sr-chat-input input:focus { border-color: #f47920; }

.sr-chat-input button.sr-send {
  background: #f47920;
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s ease, transform .15s ease;
}

.sr-chat-input button.sr-send svg { width: 16px; height: 16px; fill: #fff; }
.sr-chat-input button.sr-send:hover { background: #ff8c34; transform: scale(1.05); }
.sr-chat-input button.sr-send:disabled { background: #bdc3c7; cursor: not-allowed; transform: none; }

.sr-chat-foot {
  font-size: 11px;
  color: #98a6b5;
  text-align: center;
  padding: 0 12px 8px;
  background: #fff;
}

/* 移动端 */
@media (max-width: 640px) {
  .sr-livechat { top: auto; bottom: 22vw; transform: none; }
  .sr-chat-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 20vw;
    height: 58vh;
    max-height: 58vh;
    border-radius: 12px;
  }
  .sr-chat-header { padding: 12px; }
}
