/* ================================================================
   GlobalSync 官网 · 在线咨询浮窗（右侧常驻小窗版）
   建档 2026-10-29 ｜ 独立文件，由 assets/js/widget.js 自动注入 DOM
   配色遵循 VI：松石绿 #008b8a / 强调青 #45d6cd / 深墨蓝 #0d3b48
   结构参照常见客服窗口：头部 · 欢迎语+咨询电话 · 顾问问句 · 快捷标签 · 输入区
   ================================================================ */

.gsw-root {
  --gsw-brand: #008b8a;
  --gsw-brand-d: #00706f;
  --gsw-cyan: #45d6cd;
  --gsw-ink: #0d3b48;
  --gsw-ink2: #3f5b63;
  --gsw-ink3: #8aa4a8;
  --gsw-line: #e1ebea;
  --gsw-panel: #ffffff;
  --gsw-chat: #f6f9f9;
  position: relative;
  z-index: 9000;
  font-family: inherit;
}

/* ---------- 右下角浮标 ---------- */
.gsw-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9002;
  width: 56px;
  height: 56px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--gsw-brand) 0%, var(--gsw-cyan) 130%);
  box-shadow: 0 8px 24px rgba(0, 139, 138, .32), 0 2px 6px rgba(13, 59, 72, .12);
  transition: transform .22s ease, box-shadow .22s ease;
  -webkit-tap-highlight-color: transparent;
}
.gsw-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 30px rgba(0, 139, 138, .4), 0 3px 8px rgba(13, 59, 72, .14);
}
.gsw-fab:active { transform: scale(.97); }
.gsw-fab:focus-visible { outline: 3px solid rgba(0, 139, 138, .45); outline-offset: 3px; }
.gsw-fab svg { width: 26px; height: 26px; }
.gsw-fab .gsw-fab-close { display: none; }
.gsw-open .gsw-fab .gsw-fab-chat { display: none; }
.gsw-open .gsw-fab .gsw-fab-close { display: block; }

/* 桌面端面板打开时收起浮标（面板自带关闭），移动端保留 */
@media (min-width: 641px) {
  .gsw-open .gsw-fab { opacity: 0; pointer-events: none; transform: scale(.9); }
}

/* 未读小红点（首次提示） */
.gsw-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f5313f;
  border: 2px solid #fff;
  box-sizing: content-box;
  transition: opacity .2s ease;
}
.gsw-open .gsw-dot,
.gsw-seen .gsw-dot { opacity: 0; }

/* 呼吸光环 */
.gsw-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 139, 138, .35);
  animation: gsw-pulse 2.8s ease-out infinite;
  pointer-events: none;
}
.gsw-open .gsw-fab::after { display: none; }
@keyframes gsw-pulse {
  0%   { transform: scale(1);   opacity: .7; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ---------- 浮标旁的提示气泡（手机端用） ---------- */
.gsw-tip {
  position: fixed;
  right: 92px;
  bottom: 30px;
  z-index: 9001;
  width: 240px;
  padding: 11px 30px 11px 14px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--gsw-line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(13, 59, 72, .12);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--gsw-ink2);
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.gsw-tip.show { opacity: 1; transform: translateX(0); pointer-events: auto; }
.gsw-tip b { color: var(--gsw-ink); font-weight: 700; }
.gsw-tip::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: 18px;
  width: 9px;
  height: 9px;
  background: #fff;
  border-right: 1px solid var(--gsw-line);
  border-bottom: 1px solid var(--gsw-line);
  transform: rotate(-45deg);
}
.gsw-tip-x {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--gsw-ink3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gsw-tip-x:hover { color: var(--gsw-ink); background: #f0f5f5; }
.gsw-tip-x svg { width: 12px; height: 12px; }

/* ---------- 面板：右侧常驻小窗 ---------- */
.gsw-panel {
  position: fixed;
  right: 16px;
  top: 50%;
  z-index: 9003;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: 384px;
  max-height: min(624px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--gsw-panel);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(13, 59, 72, .22), 0 3px 12px rgba(13, 59, 72, .08);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-50%) translateX(18px) scale(.98);
  pointer-events: none;
  transition: opacity .26s ease, transform .26s cubic-bezier(.22, .9, .3, 1);
}
.gsw-open .gsw-panel {
  opacity: 1;
  transform: translateY(-50%) translateX(0) scale(1);
  pointer-events: auto;
}

/* 头部 */
.gsw-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 12px 13px 16px;
  background: linear-gradient(100deg, #00706f 0%, #008b8a 100%);
  color: #fff;
  flex: none;
}
.gsw-ava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.gsw-ava svg { width: 19px; height: 19px; }
.gsw-head-txt { flex: 1; min-width: 0; }
.gsw-head-txt strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 1.3;
}
.gsw-head-txt span {
  display: block;
  font-size: 11px;
  color: rgba(255, 255, 255, .82);
  line-height: 1.45;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gsw-head-txt span i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5be3a8;
  margin-right: 5px;
  vertical-align: 1px;
}
.gsw-hbtn {
  width: 26px;
  height: 26px;
  border: 0;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, .82);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition: background .18s ease, color .18s ease;
}
.gsw-hbtn:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.gsw-hbtn svg { width: 15px; height: 15px; }

/* 内容区 */
.gsw-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--gsw-chat);
  padding: 0;
  display: block;
}
.gsw-body::-webkit-scrollbar { width: 6px; }
.gsw-body::-webkit-scrollbar-thumb { background: #d3e0df; border-radius: 3px; }

/* 欢迎语 + 咨询电话 */
.gsw-intro {
  background: #fff;
  padding: 16px 18px 15px;
  border-bottom: 1px solid var(--gsw-line);
}
.gsw-hello {
  margin: 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--gsw-ink2);
}
.gsw-hello b { color: var(--gsw-ink); font-weight: 700; }
.gsw-telrow {
  margin: 11px 0 0;
  font-size: 12.5px;
  color: var(--gsw-ink3);
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.gsw-telrow b {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .4px;
  color: var(--gsw-brand-d);
}
.gsw-telrow b a { color: inherit; text-decoration: none; }
.gsw-fast {
  margin: 7px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--gsw-ink3);
}

/* 会话区 */
.gsw-log {
  padding: 16px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gsw-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: gsw-in .3s ease both;
}
.gsw-msg .gsw-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gsw-brand), var(--gsw-cyan));
  color: #fff;
  margin-top: 17px;
}
.gsw-msg .gsw-mini svg { width: 14px; height: 14px; }
.gsw-msg-main { min-width: 0; max-width: calc(100% - 36px); }
.gsw-meta {
  display: block;
  font-size: 11.5px;
  color: var(--gsw-ink3);
  line-height: 1.4;
  margin: 0 0 5px 2px;
}
.gsw-meta time { margin-left: 6px; color: #a8bcc0; }
.gsw-bubble {
  background: #fff;
  border: 1px solid var(--gsw-line);
  border-radius: 3px 12px 12px 12px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.72;
  color: var(--gsw-ink2);
  box-shadow: 0 1px 3px rgba(13, 59, 72, .04);
}
.gsw-bubble b { color: var(--gsw-ink); font-weight: 700; }
.gsw-bubble em {
  font-style: normal;
  color: var(--gsw-brand-d);
  font-weight: 700;
}
.gsw-bubble .gsw-kv { display: block; margin-top: 7px; }
.gsw-bubble .gsw-kv:first-child { margin-top: 0; }

/* 我方消息 */
.gsw-msg.me { flex-direction: row-reverse; }
.gsw-msg.me .gsw-meta { text-align: right; margin: 0 2px 5px 0; }
.gsw-msg.me .gsw-bubble {
  background: var(--gsw-brand);
  border-color: var(--gsw-brand);
  color: #fff;
  border-radius: 12px 3px 12px 12px;
  word-break: break-word;
}
.gsw-msg.me .gsw-mini {
  background: #dfeaea;
  color: var(--gsw-ink2);
}

/* 快捷问题 */
.gsw-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 16px 18px 52px;
}
.gsw-chip {
  border: 1px solid #cfe0df;
  background: #fff;
  color: var(--gsw-brand-d);
  font-size: 12px;
  line-height: 1;
  padding: 8px 11px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  transition: all .16s ease;
}
.gsw-chip:hover { background: #eef8f7; border-color: var(--gsw-brand); }
.gsw-chip.on { background: var(--gsw-brand); border-color: var(--gsw-brand); color: #fff; }

@keyframes gsw-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 输入区 ---------- */
.gsw-form {
  flex: none;
  border-top: 1px solid var(--gsw-line);
  background: #fff;
  padding: 12px 14px 11px;
}
.gsw-row { display: flex; gap: 8px; margin-bottom: 8px; }
.gsw-field { flex: 1; min-width: 0; }
.gsw-form input[name="name"],
.gsw-form input[name="phone"] {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  box-sizing: border-box;
  border: 1px solid transparent;
  background: #f4f6f6;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  color: var(--gsw-ink);
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.gsw-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.gsw-form textarea {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 9px 11px;
  box-sizing: border-box;
  border: 1px solid transparent;
  background: #f4f6f6;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  color: var(--gsw-ink);
  resize: none;
  display: block;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.gsw-form input::placeholder,
.gsw-form textarea::placeholder { color: #9fb3b6; }
.gsw-form input:focus,
.gsw-form textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--gsw-brand);
  box-shadow: 0 0 0 3px rgba(0, 139, 138, .1);
}
.gsw-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.gsw-send {
  flex: none;
  height: 34px;
  margin-bottom: 2px;
  padding: 0 16px;
  border: 0;
  border-radius: 17px;
  background: var(--gsw-brand);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background .18s ease, transform .18s ease;
}
.gsw-send svg { width: 14px; height: 14px; }
.gsw-send:hover { background: var(--gsw-brand-d); }
.gsw-send:active { transform: scale(.97); }
.gsw-send:disabled { opacity: .6; cursor: default; }

.gsw-note {
  margin: 9px 0 0;
  font-size: 11px;
  line-height: 1.65;
  color: var(--gsw-ink3);
}
.gsw-err {
  display: none;
  margin: 6px 0 0;
  font-size: 12px;
  color: #e0342f;
}
.gsw-err.show { display: block; }

/* 提交成功后的收起态 */
.gsw-done .gsw-form { display: none; }
.gsw-again {
  display: none;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--gsw-line);
  background: #fff;
  text-align: center;
}
.gsw-done .gsw-again { display: block; }
.gsw-again button {
  border: 1px solid #cfe0df;
  background: #fff;
  color: var(--gsw-brand-d);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 18px;
  cursor: pointer;
}
.gsw-again button:hover { background: #eef8f7; }

/* ---------- 窄屏 / 移动端：底部抽屉 ---------- */
@media (max-width: 640px) {
  .gsw-fab {
    right: 16px;
    bottom: 16px;
    width: 52px;
    height: 52px;
  }
  .gsw-fab svg { width: 24px; height: 24px; }
  .gsw-tip {
    right: 78px;
    bottom: 20px;
    max-width: 200px;
    font-size: 13px;
  }
  .gsw-panel {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-height: 90vh;
    height: 90vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .gsw-open .gsw-panel { transform: translateY(0); }
  .gsw-msg-main { max-width: calc(100% - 36px); }
  .gsw-head { padding: 13px 12px 13px 14px; }
  .gsw-quick { padding: 6px 14px 16px 50px; }
  .gsw-form { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .gsw-form input[name="name"],
  .gsw-form input[name="phone"],
  .gsw-form textarea { font-size: 16px; }
  .gsw-form textarea { height: 48px; }
}

/* 中等宽度：右侧小窗收窄，避免压住正文 */
@media (min-width: 641px) and (max-width: 1180px) {
  .gsw-panel { width: 344px; right: 12px; }
}

@media (max-width: 640px) {
  .gsw-mask {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(13, 59, 72, .35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
  }
  .gsw-open .gsw-mask { opacity: 1; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .gsw-fab, .gsw-panel, .gsw-tip, .gsw-chip, .gsw-send { transition: none; }
  .gsw-fab::after { animation: none; }
  .gsw-msg { animation: none; }
}

/* 打印时不显示 */
@media print {
  .gsw-root, .gsw-fab, .gsw-panel, .gsw-tip, .gsw-mask { display: none !important; }
}
