/**
 * 官网企微客服聊天浮窗样式与交互
 * 嵌入到所有页面底部 /includes/partials/
 */

/* ===== 聊天浮窗 ===== */
.qc-btn {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 999;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #0A4B91;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(10,75,145,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.qc-btn:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(10,75,145,.45); }
.qc-btn svg { width: 26px; height: 26px; }
.qc-btn .qc-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f97316;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(249,115,22,.4);
  display: none;
}
.qc-btn .qc-badge.show { display: flex; }

/* 聊天面板 */
.qc-panel {
  display: none;
  position: fixed;
  bottom: 145px;
  right: 20px;
  z-index: 998;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 180px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  flex-direction: column;
  overflow: hidden;
  animation: qcSlideUp .25s ease;
}
.qc-panel.show { display: flex; }
@keyframes qcSlideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* 头部 */
.qc-header {
  background: linear-gradient(135deg, #0A4B91, #083d7a);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.qc-header h3 { font-size: 15px; font-weight: 700; margin: 0; }
.qc-header p { font-size: 11px; opacity: .8; margin: 2px 0 0; }
.qc-header button {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.qc-header button:hover { background: rgba(255,255,255,.25); }

/* 消息区 */
.qc-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fb;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.qc-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; word-break: break-word; }
.qc-msg.bot { align-self: flex-start; background: #e8edf5; color: #333; border-bottom-left-radius: 4px; }
.qc-msg.user { align-self: flex-end; background: #0A4B91; color: #fff; border-bottom-right-radius: 4px; }
.qc-msg .qc-time { font-size: 10px; opacity: .6; margin-top: 4px; display: block; }

/* 输入区 */
.qc-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
.qc-input input {
  flex: 1;
  border: 1px solid #d0d5dd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}
.qc-input input:focus { border-color: #0A4B91; }
.qc-input button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0A4B91;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.qc-input button:hover { background: #083d7a; }
.qc-input button svg { width: 16px; height: 16px; }

/* 表单模式（首次无痕咨询需留资） */
.qc-form { padding: 16px; background: #fff; flex: 1; overflow-y: auto; }
.qc-form h4 { font-size: 14px; font-weight: 700; color: #0A4B91; margin: 0 0 4px; }
.qc-form p.sub { font-size: 12px; color: #666; margin: 0 0 16px; }
.qc-form input, .qc-form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
  box-sizing: border-box;
  outline: none;
}
.qc-form input:focus, .qc-form textarea:focus { border-color: #0A4B91; box-shadow: 0 0 0 2px rgba(10,75,145,.1); }
.qc-form textarea { resize: vertical; min-height: 56px; }
.qc-form button {
  width: 100%;
  background: #0A4B91;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.qc-form button:hover { background: #083d7a; }
.qc-form button:disabled { opacity: .6; cursor: not-allowed; }
.qc-success { text-align: center; padding: 40px 20px; }
.qc-success .icon { width: 56px; height: 56px; border-radius: 50%; background: #dcfce7; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.qc-success .icon svg { width: 28px; height: 28px; color: #16a34a; }
.qc-success h4 { font-size: 16px; font-weight: 700; color: #166534; margin: 0; }
.qc-success p { font-size: 12px; color: #666; margin: 6px 0 0; }

@media(max-width:640px) {
  .qc-btn { bottom: 72px; right: 12px; width: 48px; height: 48px; }
  .qc-btn svg { width: 22px; height: 22px; }
  .qc-panel { bottom: 130px; right: 8px; width: calc(100vw - 16px); height: 480px; }
}
