/* 客服工作台 */
.kefu-page {
  height: 100%;
  overflow: hidden;
  background: #eef3f8;
  padding-bottom: 0;
}

.kefu-shell {
  display: flex;
  max-width: 1100px;
  height: calc(100vh - var(--header-h));
  margin: 0 auto;
  background: #fff;
  border-left: 1px solid rgba(178, 200, 220, 0.45);
  border-right: 1px solid rgba(178, 200, 220, 0.45);
}

.kefu-sidebar {
  flex: 0 0 280px;
  width: 280px;
  border-right: 1px solid rgba(178, 200, 220, 0.55);
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f7fafc;
}

.kefu-sidebar-head {
  padding: 14px 16px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #5a738c;
}

.kefu-customer-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}

.kefu-empty {
  padding: 24px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.6;
}

.kefu-announce-box {
  border-top: 1px solid rgba(178, 200, 220, 0.55);
  padding: 12px;
  background: #fff;
}

.kefu-announce-head {
  font-size: 12px;
  font-weight: 700;
  color: #5a738c;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.kefu-announce-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 72px;
  resize: vertical;
  border: 1px solid rgba(178, 200, 220, 0.7);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: #1a2f32;
  background: #f7fafc;
  margin-bottom: 8px;
}

.kefu-editor {
  margin-bottom: 8px;
  border: 1px solid rgba(178, 200, 220, 0.7);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.kefu-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(178, 200, 220, 0.55);
  background: #f7fafc;
}

.kefu-ed-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #334155;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
}

.kefu-ed-btn:hover {
  background: #fff;
  border-color: rgba(178, 200, 220, 0.8);
}

.kefu-ed-btn i {
  font-style: italic;
  font-weight: 600;
}

.kefu-ed-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px 4px;
  background: rgba(178, 200, 220, 0.7);
}

.kefu-ed-colors {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 2px;
}

.kefu-ed-color {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
  flex: 0 0 16px;
}

.kefu-ed-color:hover {
  transform: scale(1.08);
  border-color: rgba(15, 23, 42, 0.45);
}

.kefu-ed-color-pick {
  position: relative;
  overflow: hidden;
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
}

.kefu-ed-color-pick input[type='color'] {
  position: absolute;
  inset: -4px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  cursor: pointer;
  opacity: 0;
}

.kefu-announce-html {
  margin: 0;
  border: 0;
  border-radius: 0;
  min-height: 88px;
  max-height: 180px;
  overflow-y: auto;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

.kefu-announce-html:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}

.kefu-announce-html a {
  color: #2f6fad;
  text-decoration: underline;
}

.kefu-announce-html ul,
.kefu-announce-html ol {
  margin: 0.25em 0 0.25em 1.2em;
  padding: 0;
}

.kefu-announce-save {
  width: 100%;
  height: 34px;
}

.kefu-customer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 4px 0 0;
}

.kefu-customer-row:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(178, 200, 220, 0.45);
}

.kefu-customer-row.is-active {
  background: #fff;
  border-color: rgba(47, 111, 173, 0.35);
  box-shadow: 0 6px 16px rgba(16, 42, 72, 0.06);
}

.kefu-customer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 10px 6px 10px 10px;
  margin: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.kefu-customer:hover {
  background: transparent;
  border-color: transparent;
}

.kefu-customer.is-active {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.kefu-customer-del {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  margin-right: 4px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.kefu-customer-row:hover .kefu-customer-del,
.kefu-customer-row.is-active .kefu-customer-del {
  opacity: 1;
}

.kefu-customer-del:hover {
  color: #e11d48;
  background: rgba(225, 29, 72, 0.08);
}

.kefu-customer-del:active {
  transform: scale(0.96);
}

.kefu-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  background: #2f6fad;
  position: relative;
}

.kefu-unread {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.kefu-customer-meta {
  flex: 1;
  min-width: 0;
}

.kefu-customer-name {
  font-size: 14px;
  font-weight: 600;
  color: #13293f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kefu-customer-preview {
  margin-top: 2px;
  font-size: 12px;
  color: #7b90a6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kefu-main {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.kefu-messages {
  position: absolute !important;
  left: 0;
  right: 0;
  top: 0;
  bottom: 78px;
}

.kefu-composer {
  position: absolute !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  max-width: none !important;
  margin-left: 0 !important;
}

.kefu-at-bar {
  padding: 0 4px 8px;
  font-size: 12px;
  color: #3b6ea5;
}

.kefu-reply-target {
  margin-left: auto;
  font-size: 12px;
  color: #5a738c;
  max-width: 42%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kefu-header .chat-header-inner {
  gap: 10px;
}

/* 客服登录弹窗跟随手机的真实可视区域，软键盘弹起后仍可点击。 */
#kefu-login-modal {
  top: var(--kefu-viewport-top, 0px);
  bottom: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  height: var(--kefu-viewport-height, 100dvh);
  min-height: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px
    max(16px, env(safe-area-inset-bottom, 0px));
}

#kefu-login-modal[hidden] {
  display: none !important;
}

#kefu-login-modal::before {
  display: none;
}

#kefu-login-modal .chat-modal-box {
  display: block;
  flex: 0 1 420px;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  max-height: calc(var(--kefu-viewport-height, 100dvh) - 32px);
  margin: auto;
  overflow-y: auto;
  box-sizing: border-box;
}

.kefu-login-label {
  display: block;
  margin: 0 0 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

#kefu-login-password {
  min-height: 44px;
  font-size: 16px;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .kefu-shell {
    height: calc(100vh - var(--header-h));
  }

  .kefu-sidebar {
    flex: 0 0 96px;
    width: 96px;
  }

  .kefu-sidebar-head,
  .kefu-customer-meta,
  .kefu-empty {
    display: none;
  }

  .kefu-customer {
    justify-content: center;
    padding: 8px;
  }

  .kefu-messages {
    bottom: 72px;
  }

  #kefu-login-modal {
    align-items: flex-start;
    padding-left: 14px;
    padding-right: 14px;
  }

  #kefu-login-modal .chat-modal-box {
    flex-basis: auto;
    margin-top: auto;
    margin-bottom: auto;
    padding: 20px 16px 16px;
    border-radius: 14px;
  }

  #kefu-login-modal .chat-form {
    overflow: visible;
  }

  #kefu-login-modal .chat-form .actions {
    display: flex;
    gap: 10px;
    overflow: visible;
  }

  #kefu-login-modal .chat-form .actions .chat-btn-outline,
  #kefu-login-modal .chat-form .actions .chat-btn-primary {
    float: none;
    flex: 1;
    min-width: 0;
    height: 42px;
    line-height: 42px;
    margin: 0;
    border-radius: 10px;
    text-align: center;
  }
}
