/* ═══════════════════════════════════════════════════════
   TCMS AI 客服助手 · 共享样式（所有页面通用）
   Shared chatbot + CTA styles used on every page.
   ═══════════════════════════════════════════════════════ */

/* ── Animated multicolour "orbit" used by the CTA + floating button ── */
@property --tcms-glow-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
@keyframes tcms-spectrum-orbit {
  to { --tcms-glow-angle: 360deg; }
}

/* Glow-only layer for the "Book a trial" CTAs. Only the border/gradient/glow are
   set here so each page keeps its own layout (padding, height, display, media
   queries). This gives every page the same spectrum CTA without regressions. */
.nav-cta {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--ink, #1a1c18), var(--ink, #1a1c18)) padding-box,
    conic-gradient(from var(--tcms-glow-angle), #63e6ff, #7c5cff, #f263c7, #ff9d4d, #b7f36b, #63e6ff) border-box;
  box-shadow: 0 0 12px rgba(99,230,255,.24), 0 0 18px rgba(242,99,199,.16);
  animation: tcms-spectrum-orbit 5s linear infinite;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.nav-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 15px rgba(99,230,255,.36), 0 0 24px rgba(242,99,199,.24);
}
.nav-cta:focus-visible {
  outline: 3px solid rgba(30,77,59,.35);
  outline-offset: 3px;
}
.mobile-menu .m-cta {
  border: 2px solid transparent;
  background:
    linear-gradient(var(--ink, #1a1c18), var(--ink, #1a1c18)) padding-box,
    conic-gradient(from var(--tcms-glow-angle), #63e6ff, #7c5cff, #f263c7, #ff9d4d, #b7f36b, #63e6ff) border-box;
  box-shadow: 0 0 12px rgba(99,230,255,.2), 0 0 18px rgba(242,99,199,.14);
  animation: tcms-spectrum-orbit 5s linear infinite;
  cursor: pointer;
}

/* ── 聊天按钮 ── */
#tcms-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border: 3px solid transparent;
  background:
    linear-gradient(#fff, #fff) padding-box,
    conic-gradient(from var(--tcms-glow-angle), #63e6ff, #7c5cff, #f263c7, #ff9d4d, #b7f36b, #63e6ff) border-box;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(99,230,255,.38), 0 0 30px rgba(242,99,199,.25), 0 5px 24px rgba(15,45,31,.3);
  z-index: 9998;
  transition: transform .2s, box-shadow .2s;
  outline: none;
  animation: tcms-spectrum-orbit 4.5s linear infinite;
}
#tcms-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 22px rgba(99,230,255,.52), 0 0 42px rgba(242,99,199,.34), 0 7px 28px rgba(15,45,31,.34);
}
#tcms-chat-btn:focus-visible {
  outline: 3px solid rgba(30,77,59,.35);
  outline-offset: 5px;
}
#tcms-chat-btn svg {
  width: 26px;
  height: 26px;
  transition: opacity .2s;
  position: relative;
  z-index: 1;
}
/* 实心星星：用 conic 渐变 + SVG mask，颜色随外圈追光灯同步流动，且在圆心居中 */
#tcms-chat-btn .icon-chat {
  display: block;
  width: 28px;
  height: 28px;
  position: relative;
  z-index: 1;
  background: conic-gradient(from var(--tcms-glow-angle), #63e6ff, #7c5cff, #f263c7, #ff9d4d, #b7f36b, #63e6ff);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3L13.7 10.3L21 12L13.7 13.7L12 21L10.3 13.7L3 12L10.3 10.3Z'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3L13.7 10.3L21 12L13.7 13.7L12 21L10.3 13.7L3 12L10.3 10.3Z'/%3E%3C/svg%3E") center/contain no-repeat;
  animation: tcms-spectrum-orbit 4.5s linear infinite;
}
#tcms-chat-btn .icon-close { display: none; fill: #1e4d3b; }
/* 红点提示 */
#tcms-chat-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 12px; height: 12px;
  background: #e05252;
  border-radius: 50%;
  border: 2px solid #fff;
  animation: tcms-pulse 2s infinite;
  z-index: 2;
}
@keyframes tcms-pulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: .7; }
}

/* ── 聊天面板 ── */
#tcms-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  max-height: 540px;
  box-sizing: border-box;
  border: 2px solid transparent;
  background:
    linear-gradient(#fefcf6, #fefcf6) padding-box,
    conic-gradient(from var(--tcms-glow-angle), #63e6ff, #7c5cff, #f263c7, #ff9d4d, #b7f36b, #63e6ff) border-box;
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  z-index: 9997;
  overflow: hidden;
  transform: scale(.9) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
}
/* 打开后追光灯描边流动 + 光晕 */
#tcms-chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
  animation: tcms-spectrum-orbit 6s linear infinite;
  box-shadow: 0 0 20px rgba(99,230,255,.30), 0 0 38px rgba(242,99,199,.20), 0 14px 50px rgba(0,0,0,.30);
}

/* 半透明背景遮罩(仅手机端弹窗时显示,点击可关闭) */
#tcms-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 9996;
}
#tcms-chat-backdrop.show { opacity: 1; pointer-events: auto; }
/* Mobile close button (hidden on desktop) */
#tcms-chat-close-btn {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  margin-left: auto;
  padding: 4px 6px;
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}
#tcms-chat-close-btn:hover { color: #fff; }

/* NOTE: The mobile (max-width:560px) overrides live at the END of this file so
   they win the cascade over the base component rules defined further below.
   See "Mobile overrides" block at the bottom. */

/* 头部 */
#tcms-chat-header {
  background: linear-gradient(135deg, #16382b 0%, #1e4d3b 55%, #245c46 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#tcms-chat-header .avatar {
  width: 40px; height: 40px;
  background: #9bd873;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
#tcms-chat-header .info h4 {
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  margin: 0 0 2px;
  font-family: Inter, sans-serif;
}
#tcms-chat-header .info p {
  color: rgba(255,255,255,.6);
  font-size: .78rem;
  margin: 0;
  font-family: Inter, sans-serif;
}
#tcms-chat-header .status-dot {
  width: 8px; height: 8px;
  background: #9bd873;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
  animation: tcms-pulse 2.5s infinite;
}

/* 消息区 */
#tcms-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  /* 只在消息区内部滚动,不把滚动传导到背后的页面 */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#tcms-chat-messages::-webkit-scrollbar { width: 4px; }
#tcms-chat-messages::-webkit-scrollbar-thumb { background: rgba(30,77,59,.2); border-radius: 4px; }

.tcms-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .88rem;
  line-height: 1.5;
  font-family: Inter, sans-serif;
  word-break: break-word;
}
.tcms-msg.bot {
  background: #fff;
  color: #1a1c18;
  border: 1px solid rgba(30,77,59,.12);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.tcms-msg.user {
  background: #1e4d3b;
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* 快捷回复胶囊按钮（欢迎语下方） */
.tcms-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  margin-top: 2px;
  max-width: 100%;
}
.tcms-quick-btn {
  background: #fff;
  color: #1e4d3b;
  border: 1.5px solid rgba(30,77,59,.28);
  border-radius: 16px;
  padding: 7px 13px;
  font-size: .82rem;
  font-family: Inter, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.tcms-quick-btn:hover  { background: #1e4d3b; color: #9bd873; border-color: #1e4d3b; }
.tcms-quick-btn:active { transform: scale(.96); }

/* 正在输入 */
.tcms-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid rgba(30,77,59,.12);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.tcms-typing span {
  width: 7px; height: 7px;
  background: #9bd873;
  border-radius: 50%;
  animation: tcms-bounce .9s infinite;
}
.tcms-typing span:nth-child(2) { animation-delay: .15s; }
.tcms-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes tcms-bounce {
  0%,60%,100% { transform: translateY(0); }
  30%          { transform: translateY(-6px); }
}

/* 超时提示条 */
#tcms-timeout-bar {
  background: rgba(30,77,59,.07);
  border-top: 1px solid rgba(30,77,59,.1);
  padding: 6px 16px;
  font-size: .74rem;
  color: rgba(26,28,24,.5);
  font-family: Inter, sans-serif;
  text-align: center;
  display: none;
  flex-shrink: 0;
}

/* 留资表单 */
#tcms-lead-form {
  border-top: 1px solid rgba(30,77,59,.12);
  background: #fff;
  padding: 14px 16px;
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  gap: 8px;
}
#tcms-lead-form.show { display: flex; }
#tcms-lead-form .form-title {
  font-size: .82rem;
  font-weight: 700;
  color: #1e4d3b;
  font-family: Inter, sans-serif;
  margin-bottom: 2px;
}
#tcms-lead-form input {
  border: 1.5px solid rgba(30,77,59,.2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .84rem;
  font-family: Inter, sans-serif;
  outline: none;
  color: #1a1c18;
  transition: border-color .2s;
  width: 100%;
  box-sizing: border-box;
}
#tcms-lead-form input:focus { border-color: #1e4d3b; }
#tcms-lead-form input::placeholder { color: rgba(26,28,24,.35); }
#tcms-lead-form .form-row { display: flex; gap: 6px; }
#tcms-lead-form .form-row input { flex: 1; }
#tcms-lead-submit {
  background: #1e4d3b;
  color: #9bd873;
  border: none;
  border-radius: 8px;
  padding: 9px;
  font-size: .88rem;
  font-weight: 700;
  font-family: Inter, sans-serif;
  cursor: pointer;
  transition: background .2s;
  width: 100%;
  margin-top: 2px;
}
#tcms-lead-submit:hover    { background: #2a6b52; }
#tcms-lead-submit:disabled { background: #ccc; color: #999; cursor: not-allowed; }
.tcms-form-note {
  font-size: .74rem;
  color: rgba(26,28,24,.45);
  font-family: Inter, sans-serif;
  text-align: center;
}

/* 输入区 */
#tcms-chat-footer {
  border-top: 1px solid rgba(30,77,59,.1);
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fefcf6;
}
#tcms-chat-input {
  flex: 1;
  border: 1.5px solid rgba(30,77,59,.2);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: .88rem;
  font-family: Inter, sans-serif;
  resize: none;
  outline: none;
  background: #fff;
  color: #1a1c18;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color .2s;
}
#tcms-chat-input:focus { border-color: #1e4d3b; }
#tcms-chat-input::placeholder { color: rgba(26,28,24,.35); }
#tcms-chat-send {
  width: 38px; height: 38px;
  background: #1e4d3b;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
#tcms-chat-send:hover  { background: #2a6b52; }
#tcms-chat-send:active { transform: scale(.93); }
#tcms-chat-send svg    { width: 18px; height: 18px; fill: #9bd873; }
#tcms-chat-send:disabled { background: #ccc; cursor: not-allowed; }
#tcms-chat-send:disabled svg { fill: #999; }

/* Respect reduced-motion: stop the orbit / pulse animations. */
@media (prefers-reduced-motion: reduce) {
  .nav-cta,
  .mobile-menu .m-cta,
  #tcms-chat-btn,
  #tcms-chat-btn .icon-chat,
  #tcms-chat-panel.open,
  #tcms-chat-dot { animation: none; }
  .nav-cta:hover,
  #tcms-chat-btn:hover { transform: none; }
}

/* ═══════════════════════════════════════════════════════
   Mobile overrides (placed last so they win the cascade over the
   base component rules above; selectors are also scoped under
   #tcms-chat-panel for extra specificity).
   ═══════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  /* 圆角卡片弹窗(仿 iOS sheet):四周留边、上方露出后面页面、圆角、追光灯粗边 */
  #tcms-chat-panel {
    top: calc(env(safe-area-inset-top, 0px) + 24px);
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
    width: auto;
    max-height: none;
    border-radius: 22px;
    /* 手机端把彩色追光灯边框加粗到 3 倍(桌面仍为 2px) */
    border-width: 6px;
  }
  /* Show close button inside header on mobile */
  #tcms-chat-panel #tcms-chat-close-btn { display: block; }
  /* Slightly smaller message text on mobile */
  #tcms-chat-panel .tcms-msg { font-size: .86rem; }

  /* iOS Safari auto-zooms the whole page when a focused input is < 16px.
     Force 16px on mobile so tapping the box no longer zooms/jumps the UI. */
  #tcms-chat-panel #tcms-chat-input,
  #tcms-chat-panel #tcms-lead-form input { font-size: 16px; }

  #tcms-chat-panel #tcms-chat-footer { padding: 10px; }
}
