/* 前台在线客服卡片（与 TG/WA 同列，按钮全宽高对比） */
.cs-card-chat { position: relative; }
.cs-card-chat .chat-cs-icon {
  background: linear-gradient(145deg, #ccfbf1, #e0f2fe);
  object-fit: contain !important;
  padding: 8px;
  box-sizing: border-box;
}
.cs-card-chat .cs-btn.chat,
button.cs-btn.chat {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(135deg, #0d9488, #0284c7) !important;
  color: #fff !important;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}
.cs-card-chat.has-unread {
  box-shadow: 0 0 0 2px #fb7185, 0 8px 20px rgba(15,23,42,.12);
}
.chat-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(239,68,68,.45);
}

.chat-panel {
  position: fixed; right: 158px; bottom: 100px; z-index: 91;
  width: min(360px, calc(100vw - 180px)); height: min(520px, calc(100vh - 140px));
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(15,23,42,.22);
  display: none; flex-direction: column; border: 1px solid #e2e8f0;
}
.chat-panel.open { display: flex; }
.chat-panel-head {
  padding: 12px 14px; background: linear-gradient(135deg, #14b8a6, #0ea5e9); color: #fff;
  display: flex; justify-content: space-between; align-items: center;
}
.chat-panel-head button {
  border: 0; background: transparent; color: #fff; font-size: 20px; cursor: pointer; line-height: 1;
}
.chat-msgs {
  flex: 1; overflow: auto; padding: 12px; background: #f8fafc;
  display: flex; flex-direction: column; gap: 10px;
}

/* 统一：我说的 = 右(mine)，对方 = 左(theirs) */
.chat-bubble {
  max-width: 82%; padding: 8px 11px; border-radius: 12px; font-size: 14px; line-height: 1.45;
  word-break: break-word; white-space: pre-wrap;
}
.chat-bubble.mine {
  align-self: flex-end;
  background: #0f766e;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}
.chat-bubble.system {
  align-self: center;
  background: #e2e8f0;
  color: #475569;
  font-size: 12px;
  max-width: 90%;
}
.chat-bubble img { display: block; max-width: 100%; border-radius: 8px; }
.chat-bubble .t { display: block; margin-top: 4px; font-size: 11px; opacity: .65; }

.chat-compose {
  display: flex; gap: 8px; align-items: center; padding: 10px; border-top: 1px solid #e2e8f0; background: #fff;
}
.chat-compose input[type=text] {
  flex: 1; border: 1px solid #e2e8f0; border-radius: 999px; padding: 10px 12px; outline: none;
}
.chat-upload {
  border: 1px solid #e2e8f0; border-radius: 999px; padding: 8px 10px; font-size: 12px; cursor: pointer; color: #334155;
}
.chat-compose .btn { padding: 10px 14px; }

@media (max-width: 899px) {
  .chat-panel {
    right: 12px; left: 12px; width: auto; bottom: 150px;
    height: min(62vh, 480px);
  }
}

/* 客服台 */
.agent-body { margin: 0; background: #0b1220; min-height: 100vh; color: #e2e8f0; }
.agent-desk { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }
.agent-side { border-right: 1px solid #1e293b; background: #0f172a; display: flex; flex-direction: column; }
.agent-side-head { padding: 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #1e293b; }
.agent-session-list { overflow: auto; flex: 1; }
.agent-session {
  width: 100%; text-align: left; border: 0; border-bottom: 1px solid #1e293b;
  background: transparent; color: #e2e8f0; padding: 12px 14px; cursor: pointer;
}
.agent-session:hover, .agent-session.active { background: #1e293b; }
.agent-session .t { display: flex; justify-content: space-between; font-weight: 700; }
.agent-session .t em {
  min-width: 18px; height: 18px; border-radius: 999px; background: #ef4444; color: #fff;
  font-style: normal; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.agent-session .p { font-size: 12px; color: #94a3b8; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-session .m { font-size: 11px; color: #64748b; margin-top: 4px; }
.agent-main { display: flex; flex-direction: column; min-width: 0; }
.agent-main-head { padding: 14px 16px; border-bottom: 1px solid #1e293b; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.agent-main .chat-msgs { background: #0b1220; }
.agent-main .chat-bubble.mine {
  background: #0f766e;
  color: #ecfeff;
  border: 0;
}
.agent-main .chat-bubble.theirs {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
.agent-main .chat-compose { background: #0f172a; border-top-color: #1e293b; }
.agent-main .chat-compose input[type=text] { background: #111827; border-color: #334155; color: #e2e8f0; }
.agent-main .chat-upload { border-color: #334155; color: #cbd5e1; }
.agent-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.agent-sound-btn, .agent-del-btn {
  border: 1px solid #334155; background: #1e293b; color: #e2e8f0;
  border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.agent-sound-btn:hover { background: #334155; }
.agent-del-btn { border-color: #7f1d1d; background: #7f1d1d; color: #fecaca; }
.agent-del-btn:hover:not(:disabled) { background: #991b1b; }
.agent-del-btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 860px) {
  .agent-desk { grid-template-columns: 1fr; }
  .agent-side { max-height: 38vh; }
}
