/* ═══════════════════════════════════════════════
   CHATBOT
═══════════════════════════════════════════════ */
.wg-chatbot {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 8888;
  user-select: none
}

.chatbot-btn {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #12131f, #1c1e30);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .07);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s;
}

.chatbot-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 165, 0, .25)
}

.chatbot-btn:active {
  cursor: grabbing
}

.wg-chatbot.is-dragging .chatbot-btn {
  transform: scale(0.85) rotate(-15deg);
  opacity: 0.8;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
  filter: brightness(1.2)
}

.wg-chatbot.is-dragging {
  cursor: grabbing !important
}

.cb-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(249, 115, 22, .4);
  animation: cbPulse 2.5s ease-out infinite;
  pointer-events: none
}

.cb-ring.r2 {
  inset: -9px;
  border-color: rgba(249, 115, 22, .2);
  animation-delay: .65s
}

@keyframes cbPulse {
  0% {
    transform: scale(1);
    opacity: 1
  }

  80% {
    transform: scale(1.45);
    opacity: 0
  }

  100% {
    transform: scale(1.45);
    opacity: 0
  }
}

.cb-star {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #fff;
  border: 2px solid #12131f;
  font-weight: 900;
  animation: starSpin 2s ease-in-out infinite
}

@keyframes starSpin {

  0%,
  100% {
    transform: scale(1) rotate(0)
  }

  50% {
    transform: scale(1.2) rotate(20deg)
  }
}

.chatbot-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: rgba(9, 11, 18, .94);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 24px;
  /* Deep layered shadow for premium feel */
  box-shadow:
    0 40px 100px rgba(0, 0, 0, .5),
    0 20px 40px rgba(0, 0, 0, .3),
    0 0 0 0.5px rgba(255,255,255,.06) inset,
    0 2px 0 rgba(255,255,255,.08) inset;
  overflow: hidden;
  display: none;
  flex-direction: column;
  transform-origin: bottom right;
  min-height: 420px;
  max-height: min(580px, calc(100vh - 110px));
}

.chatbot-window.active {
  display: flex;
  animation: winPop .28s cubic-bezier(.16, 1, .3, 1);
}

@keyframes winPop {
  0% {
    transform: scale(.93) translateY(8px);
    opacity: 0;
  }

  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.cw-header {
  padding: 16px 18px;
  cursor: move;
  /* Premium gradient header */
  background: linear-gradient(135deg,
    rgba(249, 115, 22, .15) 0%,
    rgba(255, 140, 66, .06) 50%,
    rgba(22, 163, 74, .06) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* Subtle shine line at top of header */
.cw-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
}

.cwh-info {
  display: flex;
  align-items: center;
  gap: 11px
}

.cwh-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  background: rgba(255, 107, 53, .12);
  border-radius: 11px;
  border: 1px solid rgba(255, 107, 53, .2);
  display: flex;
  align-items: center;
  justify-content: center
}

.cwh-online {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0a0c14;
  animation: onlinePulse 2s ease-in-out infinite
}

@keyframes onlinePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, .6)
  }

  50% {
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0)
  }
}

.cwh-info h4 {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff;
  margin: 0
}

.cwh-info p {
  font-size: 11px;
  color: rgba(255, 255, 255, .38);
  margin: 0
}

.cw-close {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  color: rgba(255, 255, 255, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all .2s
}

.cw-close:hover {
  background: rgba(239, 68, 68, .15);
  border-color: rgba(239, 68, 68, .3);
  color: #f87171
}

.cw-msgs {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Taller message area */
  max-height: 360px;
  min-height: 260px;
  /* Subtle inner scroll gradient */
  mask-image: linear-gradient(to bottom, transparent 0%, black 16px, black calc(100% - 16px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 16px, black calc(100% - 16px), transparent 100%);
}

.cw-msgs::-webkit-scrollbar {
  width: 3px
}

.cw-msgs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 99px
}

.msg {
  display: flex;
  gap: 9px;
  align-items: flex-end
}

.msg-av {
  width: 26px;
  height: 26px;
  background: rgba(255, 107, 53, .1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0
}

.msg-bubble {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .88);
  padding: 11px 15px;
  border-radius: 16px 16px 16px 4px;
  font-size: 13.5px;
  line-height: 1.6;
  /* Wider bubbles in larger window */
  max-width: 280px;
  word-break: break-word;
  overflow-wrap: anywhere;
  /* Glassmorphism on bot bubbles */
  backdrop-filter: blur(8px);
}

.msg {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  width: 100%;
}

.msg.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.msg.user .msg-bubble {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-color: transparent;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 16px rgba(22,163,74,.25);
}



.typing span {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, .45);
  border-radius: 50%;
  display: inline-block;
  animation: typDot 1.2s ease-in-out infinite
}

.typing span:nth-child(2) {
  animation-delay: .2s
}

.typing span:nth-child(3) {
  animation-delay: .4s
}

@keyframes typDot {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: .4
  }

  30% {
    transform: translateY(-5px);
    opacity: 1
  }
}

.cw-input {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, .02)
}

#cwInput {
  flex: 1;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s
}

#cwInput::placeholder {
  color: rgba(255, 255, 255, .28)
}

#cwInput:focus {
  border-color: rgba(34, 197, 94, .4)
}

#cwSend {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-radius: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0
}

#cwSend:hover {
  transform: scale(1.1);
  box-shadow: 0 0 14px rgba(22, 163, 74, .4)
}

/* ═══════════════════════════════════════════════
   QUICK REPLIES (GLASSMORPHISM UI)
═══════════════════════════════════════════════ */
.quick-replies-wrapper {
  position: relative;
  width: 100%;
}

.qr-scroll-hint {
  position: absolute;
  top: 0;
  right: 0;
  height: calc(100% - 12px);
  width: 48px;
  background: linear-gradient(to right, rgba(9, 11, 18, 0), rgba(9, 11, 18, 0.95) 60%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.8);
  transition: opacity 0.3s ease;
  animation: pulseHint 2s infinite;
}

.qr-scroll-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes pulseHint {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

.quick-replies {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px 16px;
  overflow-x: auto;
  scroll-behavior: smooth;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  scrollbar-width: none; 
}

.quick-replies::-webkit-scrollbar {
  display: none; 
}

.qr-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0; /* KHÔNG CHO NÚT BỊ ÉP NHỎ LẠI */
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  user-select: none; 
}

.qr-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: skewX(-20deg);
  transition: all 0.5s ease;
}

.qr-btn:hover {
  background: rgba(22, 163, 74, 0.12); 
  border-color: rgba(34, 197, 94, 0.4);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(22, 163, 74, 0.2);
}

.qr-btn:hover::before {
  left: 150%;
}

.qr-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 5px rgba(22, 163, 74, 0.1);
}

.qr-btn span {
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.3));
}

.qr-btn.selected {
  animation: qrClickAnim 0.4s ease forwards;
}

@keyframes qrClickAnim {
  0% { transform: scale(1); background: rgba(22, 163, 74, 0.12); }
  50% { transform: scale(0.93); background: rgba(34, 197, 94, 0.3); }
  100% { transform: scale(1); background: rgba(22, 163, 74, 0.12); }
}

/* ═══════════════════════════════════════════════
   MESSAGE CONTENT FORMATTING (MARKDOWN / LINKS)
═══════════════════════════════════════════════ */
.msg-bubble a.chat-link {
  color: #4ade80;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  transition: color .2s;
}

.msg-bubble a.chat-link:hover {
  color: #86efac;
}

.msg-bubble strong {
  color: #fff;
  font-weight: 700;
}

.msg-bubble p {
  margin: 0 0 6px 0;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble ul {
  margin: 4px 0 6px 18px;
  padding: 0;
}

.msg-bubble li {
  margin-bottom: 3px;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media screen and (max-width: 768px) {
  .chatbot-window {
    width: calc(100vw - 32px);
    max-width: 380px;
    bottom: 74px;
    right: 0;
    min-height: 380px;
    max-height: calc(100dvh - 96px);
    border-radius: 20px;
  }

  .cw-msgs {
    max-height: none;
    -webkit-overflow-scrolling: touch;
  }

  .wg-chatbot {
    bottom: 18px;
    right: 18px;
  }
}
