/* ============================================================
   通用组件：右侧联系方式 + 返回顶部
   ------------------------------------------------------------------
   形态：fixed 固定定位在页面右侧垂直居中，不随页面滚动
   交互：鼠标悬浮（或移动端点击）展开电话 / QQ / 微信信息，
         点击向上箭头平滑返回页面顶部
   调用方式（任意页面引入下面两行即可，组件 DOM 由 JS 自动注入）：
     <link rel="stylesheet" href="css/components/side-contact.css" />
     <script src="js/components/side-contact.js"></script>
   说明：所有数值取自 Figma「右侧联系方式和返回顶部」节点 #1021:3125
   ============================================================ */

.side-contact {
  --sc-pad: 13px;
  --sc-icon: 44px;
  --sc-line: 39px;
  --sc-gap: 16px;
  --sc-bg: #f5f7fa;
  --sc-border: #dbdfe8;
  --sc-icon-color: #93959d;

  position: fixed;
  top:54%;
  right: 6px;
  transform: translateY(-50%);
  z-index: 900;
  box-sizing: border-box;
  padding: var(--sc-pad);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sc-gap);
  background: var(--sc-bg);
  border: 1px solid var(--sc-border);
}

/* ---------- 单个功能项（图标按钮 + 悬浮面板） ---------- */
.side-contact-item {
  position: relative;
  flex: 0 0 auto;
  width: var(--sc-icon);
  height: var(--sc-icon);
}

.side-contact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.side-contact-btn img {
  display: block;
  width: 24px;
  height: 24px;
  transition: filter 0.2s ease;
}

/* 悬浮态：图标加深（原色 #93959D → 深灰 #57575C，
   通过亮度滤镜将同一张 SVG 映射到更深的灰色） */
.side-contact-btn:hover img {
  filter: brightness(0.585);
}

/* 图标之间的分隔线 */
.side-contact-line {
  display: block;
  flex: 0 0 auto;
  width: var(--sc-line);
  height: 1px;
  background: var(--sc-border);
}

/* ---------- 展开面板：贴在竖条左侧，与所悬浮的图标顶对齐 ---------- */
.side-contact-panel {
  position: absolute;
  top:-18px;
  right: calc(100% + var(--sc-pad) + 1px);
  box-sizing: border-box;
  background: var(--sc-bg);
  border: 1px solid var(--sc-border);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}

.side-contact-item:hover .side-contact-panel,
.side-contact-item.is-open .side-contact-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
}

/* ---------- 电话 / QQ：图标 + 文本行 ---------- */
.side-contact-panel--phone,
.side-contact-panel--qq {
  width: 270px;
  padding: 12px 24px;
}

/* 电话面板：顶部与组件顶部区域顶对齐，底部与下方分割线底对齐 */
.side-contact-panel--phone {
  top: calc(-1 * var(--sc-pad));
}

.side-contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-contact-row + .side-contact-row {
  margin-top: 8px;
}

.side-contact-row img {
  display: block;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.side-contact-panel--phone .side-contact-row span,
.side-contact-panel--qq .side-contact-row span {
  font-family: "Microsoft YaHei", Arial, sans-serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 24px;
  color: var(--sc-icon-color);
  white-space: nowrap;
}

/* ---------- 微信：二维码 + 说明文字 ---------- */
/* 兼容说明：360 极速浏览器旧内核（Chromium < 84）不支持 flex 的 gap，
   且绝对定位元素 width:auto 的收缩计算与该内核存在差异，
   会导致二维码与文字贴在一起、面板被压窄、文字多换行。
   这里改为固定宽度 + margin 间距，现代浏览器下渲染结果完全一致。 */
.side-contact-panel--wechat {
  display: flex;
  align-items: center;
  width: 279px;
  box-sizing: border-box;
  padding: 12px;
  background: #f5f7fa;
}

.side-contact-panel--wechat img {
  display: block;
  flex: 0 0 auto;
  width: 127px;
  height: 127px;
  margin-right: 12px;
  object-fit: contain;
}

.side-contact-panel--wechat span {
  flex: 0 0 auto;
  width: 114px;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  font-weight: 300;
  font-size: 22px;
  line-height: 40px;
  color: #57575c;
}

/* ---------- TMS：文字按钮（链接，新窗口打开 TMS 页面） ---------- */
.side-contact-tms {
  font-family: "Microsoft YaHei", Arial, sans-serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--sc-icon-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

.side-contact-tms:hover,
.side-contact-tms:focus {
  color: #57575c;
}

/* ============================================================
   移动端：整条组件等比收窄，面板限制在视口内，避免横向溢出
   ============================================================ */
@media (max-width: 768px) {
  .side-contact {
    display: none;
  }

  .side-contact-panel {
    right: calc(100% + var(--sc-pad) + 1px);
  }

  .side-contact-panel--phone {
    width: auto;
    max-width: calc(100vw - 78px);
    padding: 10px 12px;
  }

  .side-contact-panel--qq {
    padding: 10px 12px;
    max-width: calc(100vw - 78px);
  }

  .side-contact-panel--phone span,
  .side-contact-panel--qq span {
    font-size: 18px;
    line-height: 26px;
  }

  .side-contact-panel--wechat {
    width: 176px;
    padding: 10px;
  }

  .side-contact-panel--wechat img {
    width: 88px;
    height: 88px;
    margin-right: 10px;
  }

  .side-contact-panel--wechat span {
    width: 56px;
    font-size: 12px;
    line-height: 22px;
  }
}