/**
 * Popup Chatbot AI Đậu Đậu CSS
 * Mobile: Full-screen 100% | Desktop: 440×640 popup
 * Color: Monochrome + Amber accent (matching site palette)
 */

/* ==================== 1. FLOATING CHAT TRIGGER BUTTON ==================== */
.floating-chatbot-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid rgba(17, 17, 17, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
  padding: 0;
}

.floating-chatbot-btn:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: #111111;
}

.floating-chatbot-btn:active {
  transform: scale(0.95);
}

.chatbot-btn-avatar-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: visible;
}

.chatbot-btn-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.floating-chatbot-btn:hover .chatbot-btn-avatar {
  transform: rotate(6deg) scale(1.05);
}

.chatbot-btn-status {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  background: #10B981;
  border: 2px solid #FFFFFF;
  border-radius: 50%;
}

.chatbot-btn-tooltip {
  position: absolute;
  right: 70px;
  top: 50%;
  transform: translateY(-50%) translateX(10px);
  background: #111111;
  color: #FFFFFF;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  font-family: 'Inter', system-ui, sans-serif;
}

.chatbot-btn-tooltip::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -5px;
  transform: translateY(-50%);
  border-width: 5px 0 5px 6px;
  border-style: solid;
  border-color: transparent transparent transparent #111111;
}

.floating-chatbot-btn:hover .chatbot-btn-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-50%) translateX(0);
}

/* ==================== 2. CHATBOT POPUP WINDOW ==================== */
.chatbot-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 24px;
  box-sizing: border-box;
}

.chatbot-popup-card {
  pointer-events: auto;
  width: 440px;
  max-width: calc(100% - 32px);
  height: 640px;
  max-height: calc(100vh - 110px);
  background: #FFFFFF;
  border-radius: 24px;
  border: 1px solid #DEDEDA;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.85) translateY(30px);
  transform-origin: bottom right;
  transition: all 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chatbot-popup-overlay.active {
  pointer-events: auto;
  background: transparent !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.chatbot-popup-overlay.active .chatbot-popup-card {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

/* ==================== 3. CHATBOT HEADER ==================== */
.chatbot-header {
  padding: 14px 18px;
  background: #111111;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-header-avatar-wrap {
  position: relative;
  width: 50px;
  height: 50px;
  flex-shrink: 0;
}

.chatbot-header-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #F7F7F4;
  border: 2px solid #333;
}

.chatbot-header-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10B981;
  border-radius: 50%;
  border: 2px solid #111111;
}

.chatbot-header-text h3 {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #FFFFFF;
}

.chatbot-header-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: #F59E0B;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 1px 7px;
  border-radius: 12px;
  font-family: 'Inter', system-ui, sans-serif;
}

.chatbot-header-text p {
  font-size: 11.5px;
  color: #A3A3A3;
  margin: 2px 0 0 0;
  font-family: 'Inter', system-ui, sans-serif;
}

.chatbot-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chatbot-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #A3A3A3;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}

.chatbot-header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.chatbot-header-btn.btn-close:hover {
  background: #EF4444;
  border-color: #EF4444;
  color: #FFFFFF;
}

/* ==================== 4. CHAT MESSAGES BODY ==================== */
.chatbot-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F7F7F4;
  scroll-behavior: smooth;
  overscroll-behavior: contain !important;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  box-sizing: border-box;
}

.chatbot-body::-webkit-scrollbar {
  width: 4px;
}

.chatbot-body::-webkit-scrollbar-thumb {
  background: #DEDEDA;
  border-radius: 10px;
}

/* Message Rows */
.chat-msg-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  min-width: 0;
  width: fit-content;
  box-sizing: border-box;
  animation: chatMsgFadeIn 0.28s ease-out forwards;
}

.chat-msg-content-wrap,
.chat-msg-row > div {
  min-width: 0;
  flex: 1;
  max-width: 100%;
  box-sizing: border-box;
}

@keyframes chatMsgFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg-row.bot {
  align-self: flex-start;
}

.chat-msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1px solid #DEDEDA;
  background: #FFF;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  word-wrap: break-word !important;
  white-space: normal;
  max-width: 100%;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, sans-serif;
}

.chat-bubble code,
.chat-bubble pre {
  overflow-wrap: anywhere !important;
  word-break: break-all !important;
  white-space: pre-wrap !important;
  max-width: 100%;
}

.chat-msg-row.bot .chat-bubble {
  background: #FFFFFF;
  color: #111111;
  border-top-left-radius: 4px;
  border: 1px solid #DEDEDA;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-msg-row.user .chat-bubble {
  background: #111111;
  color: #FFFFFF;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Special "chạ biết" Styling */
.chat-bubble.cha-biet {
  font-weight: 800;
  font-size: 14.5px;
  color: #111111 !important;
  background: #FFFBEB !important;
  border-color: #F59E0B !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-bubble.cha-biet::before {
  content: '🕶️';
  font-size: 16px;
}

.chat-msg-time {
  font-size: 10px;
  color: #6F6F6F;
  margin-top: 3px;
  text-align: right;
}

.chat-msg-row.bot .chat-msg-time {
  text-align: left;
}

/* ==================== 5. SUGGESTION QUICK CHIPS ==================== */
.chatbot-chips-wrap {
  padding: 0 14px 10px 14px;
  background: #F7F7F4;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.chatbot-chips-wrap::-webkit-scrollbar {
  display: none;
}

.chatbot-chip {
  padding: 5px 11px;
  background: #FFFFFF;
  border: 1px solid #DEDEDA;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: #111111;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  font-family: 'Inter', system-ui, sans-serif;
}

.chatbot-chip:hover {
  background: #111111;
  border-color: #111111;
  color: #FFFFFF;
  transform: translateY(-1px);
}

/* ==================== 6. CHATBOT TYPING INDICATOR ==================== */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #6F6F6F;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* ==================== 7. CHATBOT FOOTER INPUT BAR ==================== */
.chatbot-footer {
  padding: 12px 14px;
  background: #FFFFFF;
  border-top: 1px solid #DEDEDA;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #DEDEDA;
  border-radius: 20px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13.5px;
  color: #111111;
  background: #F7F7F4;
  outline: none;
  transition: all 0.2s ease;
  min-height: 40px;
  max-height: 90px;
  resize: none;
}

.chatbot-input:focus {
  border-color: #111111;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.chatbot-input::placeholder {
  color: #6F6F6F;
  font-size: 13px;
}

.chatbot-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #111111;
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.06);
  background: #1A1A1A;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.chatbot-send-btn:disabled {
  background: #DEDEDA;
  cursor: not-allowed;
  box-shadow: none;
}

.chatbot-send-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  transform: translateX(1px);
}

/* ==================== 8. MOBILE: PINNED TO TOP & PREVENT ZOOM ==================== */
@media (max-width: 640px) {
  .floating-chatbot-btn {
    bottom: 16px;
    right: 16px;
    width: 66px;
    height: 66px;
    touch-action: manipulation;
  }

  .chatbot-btn-avatar {
    width: 56px;
    height: 56px;
  }

  .chatbot-btn-tooltip {
    display: none !important;
  }

  /* Overlay che phủ với hiệu ứng mờ viền xung quanh trên điện thoại */
  .chatbot-popup-overlay {
    position: fixed;
    inset: 0;
    padding: 10px 8px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    width: 100%;
    height: 100%;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overflow-x: hidden !important;
    box-sizing: border-box;
    transition: background 0.25s ease, backdrop-filter 0.25s ease;
  }

  .chatbot-popup-overlay.active {
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
  }

  /* Popup bo góc mềm mại, viền mờ xung quanh, không bị hở đáy */
  .chatbot-popup-card {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    transform-origin: bottom center;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
    overflow-x: hidden !important;
  }

  .chatbot-popup-overlay.active .chatbot-popup-card {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  /* Header trên điện thoại */
  .chatbot-header {
    padding: 10px 14px;
    flex-shrink: 0;
  }

  .chatbot-header-avatar-wrap {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
  }

  .chatbot-header-text h3 {
    font-size: 13.5px;
  }

  .chatbot-header-badge {
    font-size: 9px;
    padding: 1px 6px;
  }

  .chatbot-header-text p {
    font-size: 10px;
  }

  .chatbot-header-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
    touch-action: manipulation;
  }

  /* Body & Cuộn tin nhắn trên mobile */
  .chatbot-body {
    padding: 10px 12px;
    gap: 10px;
    overflow-x: hidden !important;
    width: 100%;
    box-sizing: border-box;
  }

  .chat-msg-row {
    max-width: 95%;
    gap: 8px;
    min-width: 0;
    width: fit-content;
    box-sizing: border-box;
  }

  .chat-msg-row > div {
    min-width: 0;
    flex: 1;
    max-width: 100%;
    box-sizing: border-box;
  }

  .chat-msg-avatar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
  }

  .chat-bubble {
    font-size: 13px !important;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 16px;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    word-wrap: break-word !important;
    white-space: normal !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  .chat-bubble code,
  .chat-bubble pre {
    overflow-wrap: anywhere !important;
    word-break: break-all !important;
    white-space: pre-wrap !important;
    max-width: 100%;
  }

  .chat-bubble.cha-biet {
    font-size: 13px !important;
  }

  .chat-msg-time {
    font-size: 9px;
    margin-top: 2px;
  }

  /* Gợi ý nhanh nhỏ gọn */
  .chatbot-chips-wrap {
    padding: 0 10px 8px 10px;
    gap: 5px;
  }

  .chatbot-chip {
    font-size: 10.5px;
    padding: 4px 9px;
    border-radius: 12px;
    touch-action: manipulation;
  }

  /* Cute link cards nhỏ gọn */
  .chat-cute-card {
    padding: 8px 10px;
    gap: 8px;
    margin: 6px 0 2px 0;
    border-radius: 12px;
  }

  .cute-card-icon-box {
    width: 32px;
    height: 32px;
    font-size: 16px;
    border-radius: 8px;
  }

  .cute-card-title {
    font-size: 12px;
  }

  .cute-card-desc {
    font-size: 10px;
  }

  .cute-card-btn {
    font-size: 10px;
    padding: 4px 9px;
  }

  /* Khung nhập liệu: font-size 16px để CHẶN TUYỆT ĐỐI iOS/Android tự động phóng to (zoom in) */
  .chatbot-footer {
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 6px;
  }

  .chatbot-input {
    font-size: 16px !important; /* Ngăn iOS/Android zoom khi focus */
    min-height: 38px;
    padding: 7px 12px;
    border-radius: 18px;
    touch-action: manipulation;
  }

  .chatbot-input::placeholder {
    font-size: 12px;
  }

  .chatbot-send-btn {
    width: 38px;
    height: 38px;
    touch-action: manipulation;
  }
}

/* ==================== 9. CUTE NAVIGATION LINK CARDS ==================== */
.chat-cute-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px 0;
  padding: 10px 12px;
  background: #FFFFFF;
  border-radius: 14px;
  border: 1.5px solid #F59E0B;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  color: #111111;
  user-select: none;
  box-sizing: border-box;
  width: 100%;
}

.chat-cute-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.22);
}

.chat-cute-card:active {
  transform: scale(0.98);
}

/* Card type variants */
.chat-cute-card.donate {
  background: linear-gradient(135deg, #FFFDF7 0%, #FFFBEB 100%);
  border-color: #F59E0B;
}

.chat-cute-card.facebook {
  background: linear-gradient(135deg, #F8FAFC 0%, #EFF6FF 100%);
  border-color: #3B82F6;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.12);
}
.chat-cute-card.facebook:hover {
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.22);
}

.chat-cute-card.tiktok {
  background: linear-gradient(135deg, #FAFAFA 0%, #F1F5F9 100%);
  border-color: #111111;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.chat-cute-card.tiktok:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.chat-cute-card.discord {
  background: linear-gradient(135deg, #FDFDFE 0%, #EEF2FF 100%);
  border-color: #6366F1;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.12);
}
.chat-cute-card.discord:hover {
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.22);
}

.cute-card-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  background: #FEF3C7;
}

.chat-cute-card.facebook .cute-card-icon-box { background: #DBEAFE; }
.chat-cute-card.tiktok .cute-card-icon-box { background: #111111; color: #FFF; }
.chat-cute-card.discord .cute-card-icon-box { background: #E0E7FF; }
.chat-cute-card.default .cute-card-icon-box { background: #F3F4F6; }

.cute-card-content {
  flex: 1;
  min-width: 0;
}

.cute-card-title {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #111111;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cute-card-desc {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  color: #6F6F6F;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cute-card-btn {
  padding: 5px 11px;
  border-radius: 20px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  background: #F59E0B;
  color: #FFFFFF;
  transition: all 0.2s ease;
}

.chat-cute-card.facebook .cute-card-btn { background: #1877F2; }
.chat-cute-card.tiktok .cute-card-btn { background: #111111; }
.chat-cute-card.discord .cute-card-btn { background: #5865F2; }
.chat-cute-card.default .cute-card-btn { background: #111111; }

.chat-cute-card:hover .cute-card-btn {
  transform: scale(1.05);
}

/* Donate card pulse highlight effect on scroll */
@keyframes donateHighlightPulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  50% { box-shadow: 0 0 0 16px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.donate-highlight-pulse {
  animation: donateHighlightPulse 1.2s ease-out 2 !important;
  border-color: #F59E0B !important;
}

