/* Scoped existing chat styles; approved header/footer/page styles remain intact. */
.chat-trigger,.chat-panel,.chat-tooltip,.chat-modal-mask,.image-preview-overlay,.ticket-modal,.emoji-picker{
  --brand-blue: #003580;
  --brand-blue-deep: #002663;
  --brand-light: #0077c8;
  --brand-sea: #00a3e0;
  --brand-orange: #ff6b00;
  --brand-orange-light: #ff8533;
  --bg-light: #f4f6f8;
  --bg-dark: #0f172a;
  --text-dark: #1a1a1a;
  --text-mid: #4b5563;
  --text-light: #94a3b8;
}


/* ===== 客服浮窗 ===== */
.chat-trigger {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-orange-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 107, 0, 0.4);
  z-index: 999;
  color: white;
  font-size: 28px;
  transition: all 0.3s;
  animation: pulse-orange 2s infinite;
}

.chat-trigger:hover { transform: scale(1.1); }


@keyframes pulse-orange {
  0%, 100% { box-shadow: 0 8px 24px rgba(255, 107, 0, 0.4), 0 0 0 0 rgba(255, 107, 0, 0.5); }
  50% { box-shadow: 0 8px 24px rgba(255, 107, 0, 0.4), 0 0 0 14px rgba(255, 107, 0, 0); }
}


/* 按钮下方文字标签 */
.chat-trigger-label {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  white-space: nowrap;
  letter-spacing: 1px;
  pointer-events: none;
}


/* 招呼气泡 (按钮左侧弹出) */
.chat-tooltip {
  position: fixed;
  right: 100px;          /* 按钮宽 64 + 间距 36 */
  bottom: 32px;
  z-index: 998;
  opacity: 0;
  transform: translateX(20px) scale(0.92);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.chat-tooltip.chat-tooltip-show {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}

.chat-tooltip-inner {
  background: linear-gradient(135deg, #fff, #fff8f0);
  border: 2px solid #ff6b00;
  border-radius: 16px;
  padding: 12px 36px 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(255, 107, 0, 0.25), 0 0 0 4px rgba(255,107,0,0.08);
  cursor: default;
  position: relative;
  min-width: 240px;
}

.chat-tooltip-emoji {
  font-size: 30px;
  animation: tooltipWave 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes tooltipWave {
  0%, 100% { transform: rotate(0); }
  20%, 60% { transform: rotate(-14deg); }
  40%, 80% { transform: rotate(14deg); }
}

.chat-tooltip-text {
  flex: 1;
}

.chat-tooltip-t1 {
  font-size: 14px;
  font-weight: 700;
  color: #d84800;
  letter-spacing: 1px;
}

.chat-tooltip-t2 {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.chat-tooltip-close {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 18px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
}

.chat-tooltip-close:hover { color: #d84800; }

.chat-tooltip-arrow {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 12px solid #ff6b00;
}

.chat-tooltip-arrow::before {
  content: '';
  position: absolute;
  right: 2px;
  top: -8px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 10px solid #fff;
}
@media (max-width: 768px){
  .chat-tooltip { right: 88px; bottom: 28px; }

  .chat-tooltip-inner { min-width: 180px; padding: 10px 28px 10px 12px; }

  .chat-tooltip-t1 { font-size: 13px; }

  .chat-tooltip-t2 { font-size: 11px; }}


.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 360px;
  height: 520px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  z-index: 998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
}

.chat-header {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-light));
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h4 { font-size: 16px; font-weight: 600; }

.chat-header .status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.chat-header .status::before {
  content: '';
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: blink 1.5s infinite;
}

@keyframes blink { 50% { opacity: 0.4; } }


.chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--bg-light);
}

.chat-msg {
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
}

.chat-msg.bot { justify-content: flex-start; }

.chat-msg.user { justify-content: flex-end; }

.chat-msg .bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.chat-msg.bot .bubble {
  background: white;
  color: var(--text-dark);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.chat-msg.user .bubble {
  background: var(--brand-blue);
  color: white;
  border-top-right-radius: 4px;
}

.chat-quick {
  padding: 12px 20px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.chat-quick-item {
  display: inline-block;
  padding: 6px 12px;
  margin: 4px 4px 4px 0;
  font-size: 12px;
  background: var(--bg-light);
  color: var(--brand-blue);
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-quick-item:hover {
  background: var(--brand-blue);
  color: white;
}

.chat-input {
  display: flex;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  background: white;
  gap: 8px;
}

.chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}

.chat-input input:focus { border-color: var(--brand-blue); }

.chat-input button {
  padding: 10px 16px;
  background: var(--brand-blue);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.chat-input button:hover { background: var(--brand-blue-deep); }


/* ===== 客服浮窗 v2 增强(badge / 工具按钮 / 表情 / 语音 / 工单) ===== */
.chat-header .status::before { display: none !important; }

.chat-header h4 { display: flex; align-items: center; }

.chat-msg.system { justify-content: center; }

.chat-msg.system .bubble {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  font-size: 12.5px;
  border-radius: 12px;
  max-width: 88%;
  text-align: center;
}

.chat-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.chat-trigger { position: relative; }


/* 输入栏工具按钮 */
.chat-input {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
}

.chat-input input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 14px;
  outline: none;
}

.chat-input input:focus { border-color: var(--brand-blue); }

.chat-tool-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  cursor: pointer; color: #6b7280;
  font-size: 16px;
  border-radius: 50%;
  transition: all 0.15s;
  flex-shrink: 0;
}

.chat-tool-btn:hover { background: #f3f4f6; color: var(--brand-blue); }

.chat-tool-btn:active { transform: scale(0.92); }

.chat-send-btn {
  background: var(--brand-blue);
  color: #fff;
  border: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--brand-blue-deep); }


/* 表情面板 */
.chat-emoji-panel {
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 10px;
  max-height: 180px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}

.chat-emoji {
  font-size: 20px;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.1s;
}

.chat-emoji:hover { background: #f3f4f6; }


/* 录音指示 */
.chat-voice-indicator {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.97);
  padding: 30px 40px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  text-align: center;
  z-index: 1000;
}

@keyframes chatPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}


/* 工单 modal */
.chat-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1100;
  display: flex; align-items: center; justify-content: center;
}

.chat-modal {
  background: #fff;
  border-radius: 14px;
  width: 92%;
  max-width: 420px;
  max-height: 86vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.chat-modal-header {
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-light));
  color: #fff;
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}

.chat-modal-header h4 { font-size: 16px; font-weight: 600; }

.chat-modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 10px;
}

.chat-modal-body label {
  font-size: 13px; font-weight: 600; color: #4b5563;
  margin-top: 4px;
}

.chat-modal-body input,
.chat-modal-body select,
.chat-modal-body textarea {
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  background: #fafafa;
}

.chat-modal-body input:focus,
.chat-modal-body select:focus,
.chat-modal-body textarea:focus { border-color: var(--brand-blue); background: #fff; }

.chat-modal-body textarea { resize: vertical; min-height: 100px; }

.chat-modal-submit {
  background: var(--brand-blue);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.chat-modal-submit:hover { background: var(--brand-blue-deep); }


/* 工单列表项 */
.chat-ticket-item {
  padding: 14px 18px;
  border-bottom: 1px solid #f3f4f6;
}

.chat-ticket-item .row1 {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px;
}

.chat-ticket-item .row2 { margin-top: 4px; color: #1f2937; font-size: 14px; }

.chat-ticket-item .row3 { margin-top: 4px; color: #9ca3af; font-size: 12px; }

.chat-ticket-item .status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
}
@media (max-width: 768px){
  .chat-emoji-panel { grid-template-columns: repeat(8, 1fr); }}

@keyframes badgeRotate { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@media (max-width: 768px){
  .chat-panel { width: calc(100vw - 32px); right: 16px; }}


/* ============================================
 * 客服浮窗 - 移动端兼容修复 v2 (2026-05-24)
 * 修复: 1) line 681 的 position:relative 覆盖 fixed
 *      2) 移动端面板尺寸/位置/可见性
 *      3) iOS Safari 点击延迟与 hover 粘连
 * ============================================ */
.chat-trigger {
  position: fixed !important;   /* 强制覆盖 line 681 的 position:relative */
  right: 20px !important;
  bottom: 24px !important;
  z-index: 99999 !important;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.chat-trigger:active { transform: scale(0.94); }
@media (hover: none) and (pointer: coarse){
  /* 触屏设备: 禁用 hover 视觉粘连 */
  .chat-trigger:hover { transform: none; }

  .chat-trigger { animation: none; }}

.chat-panel {
  z-index: 99998 !important;
}

.chat-tooltip {
  z-index: 99997 !important;
}
@media (max-width: 768px){
  /* 触发按钮在手机上稍大,易点 */
  .chat-trigger {
    width: 60px !important;
    height: 60px !important;
    font-size: 26px !important;
    right: 14px !important;
    bottom: 18px !important;
  }

  .chat-trigger-label {
    display: none;            /* 手机上隐藏按钮下方"在线客服"标签 */
  }

  /* 面板手机端全屏化 */
  .chat-panel {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 14px !important;
  }

  .chat-panel .chat-body { font-size: 14px; }

  /* 招呼气泡手机端别挡到按钮 */
  .chat-tooltip { right: 80px !important; bottom: 24px !important; }

  .chat-tooltip-inner { min-width: 160px !important; padding: 8px 26px 8px 10px !important; }}
