/* ============================================================
   在线客服 · 聊天窗口样式
   ============================================================ */

.cs-layer {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  visibility: hidden;
  opacity: 0;
  transition: opacity .22s ease, visibility .22s;
}
.cs-layer.is-open {
  visibility: visible;
  opacity: 1;
}

.cs-mask {
  position: absolute;
  inset: 0;
  background: rgba(5, 28, 51, .55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.cs-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 760px;
  max-width: 100%;
  height: 620px;
  max-height: 88vh;
  overflow: hidden;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(2, 24, 48, .38);
  transform: translateY(16px) scale(.985);
  transition: transform .24s cubic-bezier(.22, .8, .3, 1);
}
.cs-layer.is-open .cs-dialog { transform: none; }

/* ---------------- 头部 ---------------- */
.cs-header {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 16px 20px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(100deg, #0a4b84 0%, #0d5fa6 58%, #1476c6 100%);
}
.cs-header::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -90px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 34px solid rgba(255, 255, 255, .06);
  pointer-events: none;
}

.cs-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.cs-brand-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .3);
}
.cs-brand-text { min-width: 0; }
.cs-brand-text h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .5px;
}
.cs-brand-text h2 span {
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .5px;
  color: #ffe6ad;
  border: 1px solid rgba(255, 230, 173, .5);
  border-radius: 2px;
}
.cs-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .78);
}
.cs-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade8b;
  box-shadow: 0 0 0 3px rgba(74, 222, 139, .22);
}

.cs-actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 6px;
}
.cs-icon-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: rgba(255, 255, 255, .8);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.cs-icon-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.cs-icon-btn:focus-visible { outline: 2px solid #ffe6ad; outline-offset: 1px; }

/* ---------------- 消息区 ---------------- */
.cs-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 6px;
  background-color: #f2f7fc;
  background-image: radial-gradient(rgba(160, 186, 210, .18) 1px, transparent 1px);
  background-size: 18px 18px;
  scrollbar-width: thin;
  scrollbar-color: #c4d5e5 transparent;
}
.cs-body::-webkit-scrollbar { width: 6px; }
.cs-body::-webkit-scrollbar-thumb { background: #c4d5e5; border-radius: 3px; }

.cs-day {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.cs-day span {
  padding: 2px 10px;
  font-size: 11px;
  color: #92a5b7;
  background: rgba(255, 255, 255, .8);
  border: 1px solid #e2ebf4;
  border-radius: 10px;
}

.cs-msg {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  animation: csMsgIn .28s cubic-bezier(.2, .8, .3, 1) both;
}
.cs-msg.is-user { flex-direction: row-reverse; }

.cs-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  border-radius: 50%;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(135deg, #0d5fa6, #2b8bd6);
  box-shadow: 0 2px 6px rgba(13, 95, 166, .25);
  user-select: none;
}
.cs-msg.is-user .cs-avatar { background: #dbe6f1; color: #5b7086; box-shadow: none; }

.cs-msg-main {
  min-width: 0;
  max-width: 78%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.cs-msg.is-user .cs-msg-main { align-items: flex-end; }

.cs-bubble {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.75;
  color: #2c3f51;
  word-break: break-word;
  background: #fff;
  border: 1px solid #e2ebf4;
  border-radius: 3px 12px 12px 12px;
  box-shadow: 0 1px 2px rgba(18, 72, 120, .04);
}
.cs-msg.is-user .cs-bubble {
  color: #fff;
  background: linear-gradient(135deg, #1476c6, #0d5fa6);
  border-color: transparent;
  border-radius: 12px 3px 12px 12px;
  box-shadow: 0 2px 8px rgba(13, 95, 166, .25);
}

.cs-bubble p { margin: 0 0 6px; }
.cs-bubble p:last-child { margin-bottom: 0; }

.cs-links { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.cs-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  color: #0b63ad;
  text-decoration: none;
  background: #f2f8fe;
  border: 1px solid #cfe2f3;
  border-radius: 12px;
  transition: background .15s, color .15s, border-color .15s;
}
.cs-links a::after { content: "↗"; font-size: 10px; opacity: .7; }
.cs-links a:hover { background: #0d5fa6; color: #fff; border-color: #0d5fa6; }

.cs-time {
  margin-top: 5px;
  font-size: 10.5px;
  color: #9cadbc;
}
.cs-msg.is-user .cs-time { text-align: right; }

/* 正在输入 */
.cs-typing .cs-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 13px 16px;
}
.cs-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8fb0cb;
  animation: csBlink 1.2s infinite ease-in-out;
}
.cs-typing i:nth-child(2) { animation-delay: .18s; }
.cs-typing i:nth-child(3) { animation-delay: .36s; }

/* ---------------- 常见问题 ---------------- */
.cs-faq {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px 10px;
  overflow-x: auto;
  background: #fff;
  border-top: 1px solid #e8f0f7;
  scrollbar-width: none;
}
.cs-faq::-webkit-scrollbar { display: none; }
.cs-faq-label {
  flex: none;
  font-size: 11.5px;
  color: #93a5b6;
}
.cs-chip {
  flex: none;
  padding: 5px 11px;
  font-size: 12px;
  color: #1f669e;
  white-space: nowrap;
  background: #f5faff;
  border: 1px solid #d3e4f3;
  border-radius: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.cs-chip:hover { background: #0d5fa6; color: #fff; border-color: #0d5fa6; }
.cs-chip:focus-visible { outline: 2px solid #0d5fa6; outline-offset: 2px; }

/* ---------------- 输入区 ---------------- */
.cs-footer {
  flex: none;
  padding: 12px 20px 10px;
  background: #fff;
  border-top: 1px solid #edf3f9;
}
.cs-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.cs-input-row textarea {
  flex: 1;
  min-height: 42px;
  max-height: 96px;
  padding: 10px 12px;
  resize: none;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  color: #24384c;
  background: #fbfdff;
  border: 1px solid #d8e4ef;
  border-radius: 4px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.cs-input-row textarea::placeholder { color: #a3b2c0; }
.cs-input-row textarea:focus {
  border-color: #0d5fa6;
  box-shadow: 0 0 0 3px rgba(13, 95, 166, .1);
}

.cs-send {
  flex: none;
  height: 42px;
  padding: 0 24px;
  border: 0;
  border-radius: 4px;
  background: #0d5fa6;
  color: #fff;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.cs-send:hover { background: #1476c6; }
.cs-send:disabled { opacity: .5; cursor: not-allowed; }
.cs-send:focus-visible { outline: 2px solid #0d5fa6; outline-offset: 2px; }

.cs-hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  font-size: 10.5px;
  color: #a5b3c1;
}
.cs-hint-row .cs-powered { color: #b3c0cc; }

/* 最小化后的悬浮入口 */
.cs-mini {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 8900;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 12px 16px;
  border: 0;
  border-radius: 26px;
  background: linear-gradient(135deg, #1476c6, #0a4b84);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(9, 66, 116, .35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity .2s, visibility .2s, transform .2s, box-shadow .2s;
}
.cs-mini.is-show { opacity: 1; visibility: visible; transform: none; }
.cs-mini:hover { box-shadow: 0 14px 32px rgba(9, 66, 116, .45); }
.cs-mini:focus-visible { outline: 3px solid #9fcdf3; outline-offset: 2px; }

.cs-mini-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: #fff;
  background: #d93a2e;
  border: 2px solid #fff;
  border-radius: 10px;
}
.cs-mini-badge.is-show { display: flex; }

body.cs-lock { overflow: hidden; }

@keyframes csMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes csBlink {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 720px) {
  .cs-layer { padding: 0; }
  .cs-dialog {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
  .cs-header { padding: 14px 14px 14px 16px; }
  .cs-body { padding: 14px 14px 4px; }
  .cs-msg-main { max-width: 84%; }
  .cs-faq { padding: 10px 14px; }
  .cs-footer { padding: 10px 14px 8px; }
  .cs-hint-row .cs-powered { display: none; }
  .cs-send { padding: 0 18px; letter-spacing: 1px; }
  .cs-brand-text h2 span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cs-layer, .cs-dialog, .cs-msg, .cs-mini { transition: none; animation: none; }
}
