/* KlWL floating customer service chat panel */
saf-online saf-onlinelist {
  display: none !important;
}

/* Hide legacy online message popbox when chat widget is active */
div[id="c_popbox-1750211754649"] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.klwl-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 180px;
  z-index: 99999;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: min(480px, calc(100vh - 220px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
  pointer-events: none;
}

.klwl-chat-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.klwl-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #f37021 0%, #e85d0a 100%);
  color: #fff;
  flex-shrink: 0;
}

.klwl-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.klwl-chat-header-text h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.klwl-chat-header-text p {
  margin: 2px 0 0;
  font-size: 11px;
  opacity: 0.9;
}

.klwl-chat-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s;
}

.klwl-chat-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.klwl-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  background: #f5f6f8;
  min-height: 200px;
}

.klwl-chat-msg {
  max-width: 92%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px 12px 12px 4px;
  background: #fff;
  color: #333;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.klwl-chat-msg.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.klwl-chat-msg strong {
  color: #f37021;
  font-weight: 600;
}

.klwl-chat-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.klwl-chat-stat {
  flex: 1 1 30%;
  min-width: 88px;
  padding: 6px 8px;
  background: #fff8f3;
  border-radius: 8px;
  text-align: center;
  font-size: 11px;
  color: #666;
}

.klwl-chat-stat b {
  display: block;
  font-size: 15px;
  color: #f37021;
  margin-bottom: 2px;
}

.klwl-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.klwl-chat-typing span {
  width: 6px;
  height: 6px;
  background: #ccc;
  border-radius: 50%;
  animation: klwl-chat-dot 1.2s infinite ease-in-out;
}

.klwl-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.klwl-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes klwl-chat-dot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.klwl-chat-footer {
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.klwl-chat-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: #25d366;
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  box-sizing: border-box;
}

.klwl-chat-wa-btn:hover {
  background: #1fb855;
  transform: translateY(-1px);
}

.klwl-chat-wa-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.klwl-chat-footer-hint {
  margin: 8px 0 0;
  font-size: 11px;
  color: #999;
  text-align: center;
  line-height: 1.4;
}

/* Floating chat trigger — moved to body via JS (footer hides parent on mobile) */
.liuyantanceng {
  position: fixed !important;
  left: auto !important;
  right: 30px !important;
  bottom: 10% !important;
  z-index: 99990 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  width: auto !important;
  height: auto !important;
}

.liuyantanceng a {
  display: block;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}

.liuyantanceng img {
  width: 60px;
  height: 60px;
  max-width: none;
  display: block;
}

@media (max-width: 768px) {
  /* Match desktop: only the orange FAB, not the legacy bottom bar */
  saf-online.saf-theme01 {
    display: none !important;
  }

  .liuyantanceng {
    right: 12px !important;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .liuyantanceng img {
    width: 56px;
    height: 56px;
  }
}

@media (max-width: 480px) {
  .klwl-chat-panel {
    right: 12px;
    bottom: 150px;
    max-height: min(420px, calc(100vh - 200px));
    width: calc(100vw - 24px);
  }

  .liuyantanceng {
    right: 10px !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
