/* 在线客服（页面临时对话）组件样式 - 全部类名 sc- 前缀，避免与站点样式冲突 */

.sc-root {
  --sc-primary: #2563eb;
  --sc-primary-dark: #1d4ed8;
  --sc-brand: #1f3a5f;
  --sc-line: #e2e8f0;
  --sc-muted: #94a3b8;
}

/* ===== 右侧入口 ===== */
.sc-launcher {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 0;
  border-radius: 12px 0 0 12px;
  background-color: #1f3a5f;
  background-image: linear-gradient(180deg, #2563eb 0%, #1f3a5f 100%);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(31, 58, 95, 0.25);
  transition: filter 0.2s, box-shadow 0.2s;
}

.sc-launcher:hover {
  filter: brightness(1.06);
  box-shadow: 0 8px 26px rgba(31, 58, 95, 0.32);
}

.sc-launcher:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -4px;
}

.sc-launcher-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 18px;
  line-height: 1;
}

.sc-launcher-icon svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.sc-launcher-text {
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  letter-spacing: 2px;
  font-size: 13px;
  line-height: 1;
  color: #fff;
}

.sc-launcher-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 2px #fff;
}

/* ===== 遮罩（仅移动端显示） ===== */
.sc-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 9997;
}

.sc-mask[hidden] {
  display: none;
}

/* ===== 面板 ===== */
.sc-panel {
  position: fixed;
  right: 0;
  top: 50%;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: 100vw;
  height: min(640px, 80vh);
  padding: 0;
  background: #fff;
  border-radius: 12px 0 0 12px;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.18);
  transform: translate(110%, -50%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.28s ease, opacity 0.2s ease, visibility 0.28s;
  font-family: inherit;
  color: #0f172a;
}

/* 状态类使用 sc- 前缀，避免与宿主页面的通用 .open 类冲突 */
.sc-panel.sc-open {
  transform: translate(0, -50%);
  opacity: 1;
  visibility: visible;
}

.sc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sc-line);
  background: linear-gradient(135deg, #2563eb 0%, #1f3a5f 100%);
  color: #fff;
  border-radius: 12px 0 0 0;
}

.sc-head-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.sc-head-main strong {
  font-size: 15px;
  font-weight: 600;
}

.sc-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

.sc-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.sc-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sc-convbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--sc-line);
  background: #f8fafc;
}

.sc-conv-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--sc-line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  color: #475569;
  font-family: inherit;
}

/* ===== 消息区 ===== */
.sc-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  background: #f8fafc;
  min-height: 0;
}

/* 深色主题页面（如训练营宣传页）会全局改写滚动条配色，此处限定组件内保持浅色 */
.sc-body::-webkit-scrollbar {
  width: 8px;
}

.sc-body::-webkit-scrollbar-track {
  background: transparent;
}

.sc-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 8px;
}

.sc-welcome {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  color: #1e40af;
  font-size: 13px;
  line-height: 1.6;
}

.sc-welcome[hidden] {
  display: none;
}

.sc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sc-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
}

.sc-msg-user {
  align-items: flex-end;
}

.sc-msg-admin {
  align-items: flex-start;
}

.sc-msg-system {
  align-items: center;
}

.sc-msg-name {
  font-size: 11px;
  color: var(--sc-muted);
}

.sc-bubble {
  max-width: 80%;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--sc-line);
  background: #fff;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.sc-msg-user .sc-bubble {
  background: var(--sc-primary);
  border-color: var(--sc-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.sc-msg-admin .sc-bubble {
  border-bottom-left-radius: 4px;
}

.sc-msg-system .sc-bubble {
  max-width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--sc-muted);
  font-size: 12px;
  text-align: center;
}

.sc-msg-time {
  font-size: 11px;
  color: var(--sc-muted);
}

.sc-msg-pending .sc-bubble {
  opacity: 0.65;
}

.sc-msg-error .sc-bubble {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* ===== 访客信息（选填） ===== */
.sc-guest {
  border-top: 1px solid var(--sc-line);
  padding: 8px 12px 0;
  background: #fff;
}

.sc-guest-toggle {
  border: 0;
  background: none;
  padding: 2px 0;
  color: var(--sc-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.sc-guest-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0 10px;
}

.sc-guest-fields[hidden] {
  display: none;
}

.sc-guest-fields input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--sc-line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: #0f172a;
}

.sc-guest-fields input:focus {
  outline: none;
  border-color: var(--sc-primary);
}

.sc-guest-tip {
  margin: 0;
  font-size: 11px;
  color: var(--sc-muted);
}

/* ===== 输入区 ===== */
.sc-foot {
  flex: 0 0 auto;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--sc-line);
  background: #fff;
  border-radius: 0 0 0 12px;
}

.sc-foot textarea {
  width: 100%;
  min-height: 54px;
  max-height: 120px;
  padding: 8px 10px;
  border: 1px solid var(--sc-line);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
  color: #0f172a;
  resize: vertical;
}

.sc-foot textarea:focus {
  outline: none;
  border-color: var(--sc-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.sc-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.sc-count {
  font-size: 11px;
  color: var(--sc-muted);
}

.sc-send {
  padding: 8px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--sc-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.sc-send:hover {
  background: var(--sc-primary-dark);
}

.sc-send:disabled {
  opacity: 0.6;
  cursor: default;
}

.sc-tip {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 12px;
  line-height: 1.5;
}

body.sc-lock {
  overflow: hidden;
}

/* ===== 移动端：右下角悬浮球 + 底部弹层 ===== */
@media (max-width: 768px) {
  .sc-launcher {
    top: auto;
    bottom: 84px;
    right: 16px;
    transform: none;
    flex-direction: row;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
  }

  .sc-launcher-text {
    display: none;
  }

  .sc-launcher-icon {
    width: 24px;
    height: 24px;
    font-size: 24px;
  }

  .sc-launcher-icon svg {
    width: 24px;
    height: 24px;
  }

  .sc-launcher-dot {
    top: 4px;
    right: 4px;
  }

  .sc-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 78vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
  }

  .sc-panel.sc-open {
    transform: translateY(0);
  }

  .sc-head {
    border-radius: 16px 16px 0 0;
  }

  .sc-foot {
    border-radius: 0;
  }

  .sc-foot textarea {
    font-size: 16px;
  }
}
