/* ============================================================
   OpenIM 在线客服聊天面板样式
   与站点主色 #1769ff 保持一致
   ============================================================ */

/* 聊天面板打开时隐藏右侧浮动弹窗（在线联系说明等） */
body.openim-chat-open .floating-contact-popover {
  display: none !important;
}
body.openim-chat-open .floating-contact-item.is-popover-open {
  pointer-events: none;
}

.openim-chat-panel {
  position: fixed;
  z-index: 9999;
  right: 24px;
  bottom: 24px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(26, 68, 132, 0.28);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

.openim-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ---- Header ---- */
.openim-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(145deg, #1769ff, #2e8df7);
  color: #fff;
  flex-shrink: 0;
}

.openim-chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.openim-chat-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 16px;
  font-weight: 800;
}

.openim-chat-title strong {
  display: block;
  font-size: 15px;
  line-height: 1.3;
}

.openim-chat-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.85;
}

.openim-chat-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ccc;
}

.openim-chat-status[data-state="online"]::before { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.openim-chat-status[data-state="connecting"]::before { background: #fbbf24; animation: openim-pulse 1.2s infinite; }
.openim-chat-status[data-state="offline"]::before { background: #f87171; }

@keyframes openim-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.openim-chat-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.openim-chat-close:hover { background: rgba(255, 255, 255, 0.3); }

/* ---- Messages ---- */
.openim-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f5f8fc;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.openim-chat-messages::-webkit-scrollbar { width: 5px; }
.openim-chat-messages::-webkit-scrollbar-thumb { background: #c5d6ec; border-radius: 3px; }

.openim-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: 100%;
  animation: openim-msg-in 0.25s ease;
}

@keyframes openim-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.openim-msg-sent { flex-direction: row; justify-content: flex-end; }
.openim-msg-received { flex-direction: row; justify-content: flex-start; }

.openim-msg-content {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 40px);
}

.openim-msg-sent .openim-msg-content { align-items: flex-end; }
.openim-msg-received .openim-msg-content { align-items: flex-start; }

/* 消息头像 */
.openim-msg-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.openim-msg-avatar-sent {
  background: linear-gradient(145deg, #1769ff, #2e8df7);
  color: #fff;
  display: grid;
  place-items: center;
}

.openim-msg-avatar-sent svg {
  display: block;
}

.openim-msg-avatar-received {
  background: #fff;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.openim-msg-avatar-received img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.openim-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.openim-msg-sent .openim-msg-bubble {
  background: linear-gradient(145deg, #1769ff, #2e8df7);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.openim-msg-received .openim-msg-bubble {
  background: #fff;
  color: #18385f;
  border: 1px solid #e0eaf6;
  border-bottom-left-radius: 4px;
}

.openim-msg-time {
  margin-top: 4px;
  font-size: 10px;
  color: #9aabc0;
}

.openim-msg-system {
  align-self: center;
  max-width: 90%;
  text-align: center;
  font-size: 11px;
  color: #8290a3;
  padding: 6px 14px;
  background: rgba(130, 144, 163, 0.1);
  border-radius: 10px;
}

/* ---- Footer / Input ---- */
.openim-chat-footer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e8eef6;
  flex-shrink: 0;
}

.openim-chat-footer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 12px;
  border: 1px solid #d8e5f4;
  border-radius: 10px;
  outline: none;
  resize: none;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
  color: #18385f;
  background: #f7faff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.openim-chat-footer textarea:focus {
  border-color: #1769ff;
  box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.12);
}

.openim-chat-footer button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(145deg, #1769ff, #2e8df7);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.openim-chat-footer button:hover { opacity: 0.9; }
.openim-chat-footer button:active { transform: scale(0.97); }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .openim-chat-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 80dvh;
    max-height: 80dvh;
    border-radius: 18px 18px 0 0;
  }
}



/* ---- 图片消息 ---- */
.openim-msg-image {
  max-width: 220px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  background: #e8eef6;
  line-height: 0;
  transition: opacity 0.2s;
}

.openim-msg-image:hover {
  opacity: 0.9;
}

.openim-msg-image img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: cover;
  border-radius: 12px;
}

/* 发送方图片气泡圆角 */
.openim-msg-sent .openim-msg-image {
  border-bottom-right-radius: 4px;
}
.openim-msg-sent .openim-msg-image img {
  border-bottom-right-radius: 4px;
}

/* 接收方图片气泡圆角 */
.openim-msg-received .openim-msg-image {
  border-bottom-left-radius: 4px;
}
.openim-msg-received .openim-msg-image img {
  border-bottom-left-radius: 4px;
}

/* ---- 图片放大预览 ---- */
.openim-image-preview {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
  cursor: zoom-out;
}

.openim-image-preview.is-visible {
  opacity: 1;
  visibility: visible;
}

.openim-image-preview img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.openim-image-preview-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.openim-image-preview-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ---- 客服列表选择界面 ---- */
.openim-cs-list {
  padding: 4px 0 8px;
  background: transparent;
}

.openim-cs-list-title {
  font-size: 13px;
  font-weight: 500;
  color: #8290a3;
  margin-bottom: 10px;
  text-align: center;
}

.openim-cs-list-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.openim-cs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e5e9f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.openim-cs-item:hover {
  border-color: #1769ff;
  background: #f0f6ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(23, 105, 255, 0.12);
}

.openim-cs-item.active {
  border-color: #1769ff;
  background: #eaf2ff;
}

.openim-cs-item.active small {
  color: #1769ff;
}

.openim-cs-item-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.openim-cs-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.openim-cs-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.openim-cs-item-info strong {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
}

.openim-cs-item-info small {
  font-size: 12px;
  color: #888;
}

.openim-cs-item-error {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 13px;
}
