/* ============================================================
 * 四六级备考平台 · 在线客服组件样式
 * 右下角悬浮按钮 + 聊天窗口，绿色主题，移动端全屏
 * ============================================================ */
#cet-chat-widget,
#cet-chat-widget * { box-sizing: border-box; margin: 0; padding: 0; }

/* ---------- 悬浮按钮 ---------- */
#cet-chat-btn {
  position: fixed;
  right: 22px;
  bottom: 26px;
  z-index: 9999;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #1a7f64 0%, #0e4d3a 100%);
  box-shadow: 0 8px 24px rgba(14, 77, 58, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s;
  color: #fff;
}
#cet-chat-btn:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 12px 30px rgba(14, 77, 58, 0.45); }
#cet-chat-btn svg { width: 30px; height: 30px; }

/* 未读红点 */
#cet-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #e63946;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  display: none;
  box-shadow: 0 2px 6px rgba(230, 57, 70, 0.5);
}

/* ---------- 聊天窗口 ---------- */
#cet-chat-window {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 9998;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 540px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
#cet-chat-window.cet-open { display: flex; }

/* 头部 */
#cet-chat-head {
  background: linear-gradient(135deg, #1a7f64 0%, #0e4d3a 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#cet-chat-head .cet-head-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#cet-chat-head .cet-head-icon svg { width: 22px; height: 22px; }
#cet-chat-head .cet-head-txt { flex: 1; min-width: 0; }
#cet-chat-head .cet-head-txt b { display: block; font-size: 15px; font-weight: 700; }
#cet-chat-head .cet-head-txt span { display: block; font-size: 11.5px; opacity: 0.85; margin-top: 2px; }
#cet-chat-close {
  background: none; border: none; color: #fff; cursor: pointer;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.2s;
}
#cet-chat-close:hover { background: rgba(255, 255, 255, 0.18); }
#cet-chat-close svg { width: 18px; height: 18px; }

/* 消息区 */
#cet-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  background: #f4f7f5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#cet-chat-body::-webkit-scrollbar { width: 6px; }
#cet-chat-body::-webkit-scrollbar-thumb { background: #cfe0d8; border-radius: 3px; }

/* 系统提示条 */
.cet-sys {
  align-self: center;
  background: #e8efe9;
  color: #4a6a5a;
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 12px;
  max-width: 85%;
  text-align: center;
}

/* 消息气泡 */
.cet-msg { display: flex; gap: 8px; max-width: 86%; }
.cet-msg.cet-mine { align-self: flex-end; flex-direction: row-reverse; }
.cet-msg.cet-theirs { align-self: flex-start; }
.cet-msg .cet-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.cet-msg.cet-mine .cet-avatar { background: #1a7f64; }
.cet-msg.cet-theirs .cet-avatar { background: linear-gradient(135deg, #c9a227, #a97e1a); }
.cet-msg .cet-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.cet-msg.cet-mine .cet-bubble {
  background: #1a7f64;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cet-msg.cet-theirs .cet-bubble {
  background: #fff;
  color: #23362d;
  border: 1px solid #e4ece7;
  border-bottom-left-radius: 4px;
}
.cet-msg .cet-time {
  font-size: 10px;
  color: #9db3a8;
  align-self: flex-end;
  margin-bottom: 2px;
  flex-shrink: 0;
}

/* 输入区 */
#cet-chat-inputbar {
  flex-shrink: 0;
  border-top: 1px solid #e6ede9;
  background: #fff;
  padding: 10px 12px;
  display: flex;
  gap: 6px;
  align-items: flex-end;
}
.cet-atbtn {
  border: none;
  background: none;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #5b7268;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.cet-atbtn svg { width: 21px; height: 21px; }
.cet-atbtn:hover { background: #eef4f0; color: #1a7f64; }
.cet-atbtn:active { transform: scale(0.92); }
#cet-chat-input {
  flex: 1;
  border: 1px solid #d5e2db;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 90px;
  line-height: 1.45;
  font-family: inherit;
  color: #23362d;
  background: #f8faf9;
}
#cet-chat-input:focus { border-color: #1a7f64; background: #fff; }
#cet-chat-send {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #1a7f64, #0e4d3a);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter 0.2s, transform 0.15s;
}
#cet-chat-send:hover { filter: brightness(1.08); }
#cet-chat-send:active { transform: scale(0.96); }

/* 附件消息 */
.cet-attach-img {
  display: block;
  max-width: 190px;
  max-height: 240px;
  border-radius: 10px;
  cursor: zoom-in;
  object-fit: cover;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
/* 文件选择输入框：屏幕外隐藏（display:none 在 iOS 上 click 会失效） */
.cet-file-input {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}
.cet-attach-file {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
  max-width: 210px;
  text-decoration: none;
  color: inherit;
}
.cet-file-ic {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 9px;
  background: #eef4f0;
  color: #1a7f64;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cet-file-ic svg { width: 20px; height: 20px; }
.cet-file-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cet-file-info b {
  font-size: 13px;
  font-weight: 600;
  color: #23362d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}
.cet-file-info i {
  font-style: normal;
  font-size: 11.5px;
  color: #7a8f84;
}
html[data-theme="dark"] .cet-atbtn { color: #9db4a9; }
html[data-theme="dark"] .cet-atbtn:hover { background: #1d3127; color: #34c28f; }
html[data-theme="dark"] .cet-file-ic { background: #1d3127; color: #34c28f; }
html[data-theme="dark"] .cet-file-info b { color: #d7e4dc; }
html[data-theme="dark"] .cet-file-info i { color: #8aa398; }

/* 未登录提示态 */
.cet-login-tip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #f4f7f5;
  padding: 20px;
}
.cet-login-tip .cet-tip-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: #e3efe9; display: flex; align-items: center; justify-content: center;
}
.cet-login-tip .cet-tip-icon svg { width: 28px; height: 28px; color: #1a7f64; }
.cet-login-tip p { font-size: 13.5px; color: #5a7266; text-align: center; line-height: 1.6; }
#cet-goto-login {
  border: none;
  border-radius: 22px;
  background: linear-gradient(135deg, #1a7f64, #0e4d3a);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 30px;
  cursor: pointer;
  transition: filter 0.2s;
}
#cet-goto-login:hover { filter: brightness(1.08); }

/* ---------- 移动端全屏 ---------- */
@media (max-width: 640px) {
  #cet-chat-btn { right: 16px; bottom: 18px; width: 52px; height: 52px; }
  #cet-chat-btn svg { width: 26px; height: 26px; }
  #cet-chat-window {
    right: 0; bottom: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    max-width: 100vw;
    max-width: 100dvw;
    border-radius: 0;
  }
  /* 刘海屏安全区 */
  #cet-chat-inputbar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  #cet-chat-head { padding-top: calc(14px + env(safe-area-inset-top)); }
}

/* 暗黑模式适配 */
html[data-theme="dark"] #cet-chat-window { background: #14251d; }
html[data-theme="dark"] #cet-chat-body { background: #101d17; }
html[data-theme="dark"] #cet-chat-inputbar { background: #14251d; border-top-color: #243a2e; }
html[data-theme="dark"] #cet-chat-input { background: #0f1a14; border-color: #2a4233; color: #d7e4dc; }
html[data-theme="dark"] #cet-chat-input:focus { background: #14251d; border-color: #1a7f64; }
html[data-theme="dark"] #cet-chat-body::-webkit-scrollbar-thumb { background: #2c4236; }
html[data-theme="dark"] .cet-msg.cet-theirs .cet-bubble { background: #1b2f24; border-color: #2a4233; color: #d7e4dc; }
html[data-theme="dark"] .cet-sys { background: #1b2f24; color: #8fb09e; }
html[data-theme="dark"] .cet-login-tip { background: #101d17; }
html[data-theme="dark"] .cet-login-tip p { color: #8fb09e; }
html[data-theme="dark"] .cet-login-tip .cet-tip-icon { background: #1b2f24; }

/* 轻量提示浮层（未登录引导等） */
#cet-chat-toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(17, 17, 17, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 999999;
  max-width: 86vw;
  text-align: center;
}
#cet-chat-toast.cet-show { opacity: 1; transform: translateX(-50%) translateY(0); }
html[data-theme="dark"] #cet-chat-toast { background: rgba(240, 240, 240, 0.95); color: #111; }

/* 窗口打开时隐藏悬浮按钮，关闭后恢复 */
#cet-chat-widget.cet-window-open #cet-chat-btn {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.85);
}
#cet-chat-btn { transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s; }
