/* ============================================================
   AI 聊天助手样式 —— 金色按钮 + 深蓝弹窗
   与站点风格一致：--gold #c8a359 / 深蓝 #0b172b
   ============================================================ */

.hzchat {
  --hz-gold: #c8a359;
  --hz-gold-2: #e8c97a;
  --hz-navy: #0b172b;
  --hz-navy-2: #16294a;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- 悬浮按钮 ---------- */
.hzchat-fab {
  position: relative;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(140deg, var(--hz-gold-2), var(--hz-gold));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(200, 163, 89, .42), 0 2px 6px rgba(0, 0, 0, .12);
  transition: transform .25s, box-shadow .25s, opacity .25s;
}
.hzchat-fab svg { width: 27px; height: 27px; }
.hzchat-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 12px 30px rgba(200, 163, 89, .5); }
.hzchat-fab.hide { opacity: 0; pointer-events: none; transform: scale(.7); }
.hzchat-fab-dot {
  position: absolute; top: 8px; right: 8px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #22c55e; border: 2px solid #fff;
  animation: hzchat-pulse 2.4s infinite;
}
@keyframes hzchat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .55); }
  60% { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
}

/* ---------- 面板 ---------- */
.hzchat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 372px;
  height: 570px;
  max-height: calc(100dvh - 40px);
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(11, 23, 43, .24), 0 4px 14px rgba(11, 23, 43, .1);
  opacity: 0;
  transform: translateY(16px) scale(.96);
  transform-origin: right bottom;
  pointer-events: none;
  transition: opacity .26s ease, transform .26s cubic-bezier(.2, .9, .3, 1.2);
}
.hzchat-panel.on { opacity: 1; transform: none; pointer-events: auto; }

/* 头部深蓝 */
.hzchat-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(135deg, var(--hz-navy) 0%, var(--hz-navy-2) 100%);
  color: #fff;
  flex: 0 0 auto;
}
.hzchat-hd-l { display: flex; align-items: center; gap: 10px; }
.hzchat-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--hz-gold-2), var(--hz-gold));
  color: #fff; font-weight: 700; font-size: 16px;
  flex: 0 0 auto;
}
.hzchat-hd-l b { display: block; font-size: 14.5px; font-weight: 600; letter-spacing: .2px; }
.hzchat-hd-l i {
  display: flex; align-items: center; gap: 5px;
  font-style: normal; font-size: 11.5px; color: rgba(255, 255, 255, .62); margin-top: 2px;
}
.hzchat-hd-l i em {
  width: 6px; height: 6px; border-radius: 50%; background: #22c55e;
  display: inline-block;
}
.hzchat-hd-r { display: flex; gap: 4px; }
.hzchat-ico {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .8);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.hzchat-ico:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.hzchat-ico svg { width: 15px; height: 15px; }

/* 消息区 */
.hzchat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 8px;
  background: #f7f8fa;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.hzchat-msg { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.hzchat-msg.me { flex-direction: row-reverse; }
.hzchat-ava {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--hz-gold-2), var(--hz-gold));
  color: #fff; font-size: 12.5px; font-weight: 700;
}
.hzchat-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.72;
  color: #1f2937;
  background: #fff;
  box-shadow: 0 1px 3px rgba(11, 23, 43, .07);
  word-break: break-word;
  border-top-left-radius: 4px;
}
.hzchat-msg.me .hzchat-bubble {
  background: linear-gradient(135deg, var(--hz-navy-2), var(--hz-navy));
  color: #fff;
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
}
.hzchat-disc {
  display: block; margin-top: 8px; padding-top: 7px;
  border-top: 1px dashed rgba(11, 23, 43, .12);
  font-size: 11px; line-height: 1.55; color: #98a2b3;
}

/* 快捷问题 */
.hzchat-quick { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 8px 36px; }
.hzchat-quick button {
  border: 1px solid rgba(200, 163, 89, .38);
  background: #fff; color: #8a6d2f;
  border-radius: 14px; padding: 6px 11px;
  font-size: 12px; cursor: pointer;
  transition: all .18s;
}
.hzchat-quick button:hover { background: rgba(200, 163, 89, .1); border-color: var(--hz-gold); }

/* 打字动画 */
.hzchat-dots { display: flex; gap: 4px; align-items: center; height: 40px; padding: 0 15px; }
.hzchat-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: #c8cdd6;
  animation: hzchat-bounce 1.3s infinite ease-in-out;
}
.hzchat-dots i:nth-child(2) { animation-delay: .16s; }
.hzchat-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes hzchat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 输入区 */
.hzchat-ft {
  flex: 0 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid rgba(11, 23, 43, .07);
}
.hzchat-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(11, 23, 43, .12);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.6;
  max-height: 96px;
  font-family: inherit;
  color: #1f2937;
  transition: border-color .2s, box-shadow .2s;
  background: #f7f8fa;
}
.hzchat-input:focus {
  outline: none; background: #fff;
  border-color: var(--hz-gold);
  box-shadow: 0 0 0 3px rgba(200, 163, 89, .13);
}
.hzchat-send {
  width: 38px; height: 38px; flex: 0 0 auto;
  border: none; border-radius: 10px; cursor: pointer;
  background: linear-gradient(140deg, var(--hz-gold-2), var(--hz-gold));
  color: #fff; display: flex; align-items: center; justify-content: center;
  transition: transform .18s, opacity .2s;
}
.hzchat-send svg { width: 17px; height: 17px; }
.hzchat-send:hover { transform: scale(1.05); }
.hzchat.busy .hzchat-send { opacity: .5; pointer-events: none; }

.hzchat-tip {
  flex: 0 0 auto;
  text-align: center; font-size: 10.5px; color: #a9b1bd;
  padding: 0 12px 8px; line-height: 1.5; background: #fff;
}

/* ---------- 留资表单 ---------- */
.hzchat-form {
  display: none;
  flex: 0 0 auto;
  background: linear-gradient(160deg, #fdfaf3, #fff);
  border-top: 1px solid rgba(200, 163, 89, .28);
  padding: 13px 14px 14px;
  animation: hzchat-slide .3s ease;
}
.hzchat-form.on { display: block; }
@keyframes hzchat-slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.hzchat-form-hd { font-size: 12.5px; font-weight: 600; color: #8a6d2f; margin-bottom: 9px; }
.hzchat-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.hzchat-in {
  width: 100%;
  border: 1px solid rgba(11, 23, 43, .13);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.hzchat-in:focus { outline: none; border-color: var(--hz-gold); box-shadow: 0 0 0 3px rgba(200, 163, 89, .13); }
.hzchat-form-grid .hzchat-in:nth-child(4) { grid-column: 1 / -1; }
.hzchat-submit {
  width: 100%; margin-top: 9px;
  border: none; border-radius: 9px; cursor: pointer;
  padding: 11px; font-size: 14px; font-weight: 600; font-family: inherit;
  background: linear-gradient(135deg, var(--hz-gold-2), var(--hz-gold));
  color: #fff;
  transition: opacity .2s, transform .18s;
}
.hzchat-submit:hover { transform: translateY(-1px); }
.hzchat-submit:disabled { opacity: .6; cursor: default; transform: none; }
.hzchat-form-note { margin-top: 7px; font-size: 10.5px; color: #a9b1bd; text-align: center; }
.hzchat-form-note a { color: #8a6d2f; }

/* ---------- 提示气泡 & toast ---------- */
.hzchat-hello {
  position: absolute; right: 68px; bottom: 14px;
  background: #fff; color: #1f2937;
  padding: 9px 13px; border-radius: 10px;
  font-size: 13px; white-space: nowrap;
  box-shadow: 0 6px 20px rgba(11, 23, 43, .14);
  opacity: 0; transform: translateX(8px);
  animation: hzchat-hello-in .4s .1s forwards;
}
.hzchat-hello i {
  position: absolute; right: -5px; bottom: 13px;
  width: 10px; height: 10px; background: #fff; transform: rotate(45deg);
  box-shadow: 2px -2px 4px rgba(11, 23, 43, .04);
}
.hzchat-hello.out { opacity: 0; transition: opacity .5s; }
@keyframes hzchat-hello-in { to { opacity: 1; transform: none; } }

.hzchat-toast {
  position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(11, 23, 43, .92); color: #fff;
  padding: 9px 16px; border-radius: 8px;
  font-size: 12.5px; white-space: nowrap; z-index: 30;
  animation: hzchat-slide .24s ease;
}
.hzchat-toast.out { opacity: 0; transition: opacity .4s; }

/* ---------- 移动端 ---------- */
@media (max-width: 767px) {
  .hzchat { right: 14px; bottom: 78px; }
  .hzchat-fab { width: 52px; height: 52px; }
  .hzchat-fab svg { width: 24px; height: 24px; }
  .hzchat-panel {
    position: fixed;
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: 84dvh;
    max-height: 84dvh;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .hzchat-panel.on { transform: none; }
  .hzchat-hello { right: 62px; bottom: 10px; font-size: 12.5px; padding: 8px 11px; }
  .hzchat-body { padding: 14px 12px 6px; }
  .hzchat-bubble { font-size: 14px; max-width: 86%; }
  /* iOS 输入框不小于 16px，避免聚焦时页面放大 */
  .hzchat-input, .hzchat-in { font-size: 16px; }
  /* 表单在移动端紧跟输入区，保证可见 */
  .hzchat-form-grid { grid-template-columns: 1fr 1fr; }
  .hzchat-tip { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}

/* 小屏高度不足时压缩 */
@media (max-height: 620px) {
  .hzchat-panel { height: calc(100dvh - 20px); }
}
