/* ============================================================================
   WIDGET BONG BÓNG CHAT HỖ TRỢ AI DEX & AI ZIP (assets/css/dcz-ai-support.css)
   Phong cách Industrial Modern chuẩn DCZ (Đen - Cam #FE6A17 - Trắng)
   ============================================================================ */

/* Khung gốc đặt ngay phía trên icon Zalo bên phải màn hình */
.dcz-ai-root {
  position: fixed;
  right: 14px;
  bottom: 282px;
  z-index: 1450;
  font-family: var(--font-sans, "Noto Sans", sans-serif);
}

/* Nút bong bóng không khung viền: chỉ hiện khuôn mặt linh vật và bóng mây suy nghĩ */
.dcz-ai-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.dcz-ai-trigger:hover {
  transform: translateY(-2px) scale(1.04);
}

/* Bóng mây suy nghĩ nổi phía trên bên trái khuôn mặt AI DEX / AI ZIP (nhấp nháy nhẹ & bay bổng) */
.dcz-ai-thought-cloud {
  position: absolute;
  right: 34px;
  bottom: 42px;
  width: 184px;
  height: 78px;
  pointer-events: none;
  animation: dczCloudFloatPulse 3.2s ease-in-out infinite;
}

.dcz-ai-cloud-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.dcz-ai-cloud-text {
  position: absolute;
  inset: 7px 18px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.dcz-ai-cloud-text.is-switching {
  opacity: 0;
  transform: translateY(3px);
}

.dcz-ai-cloud-text strong {
  font-size: 11px;
  font-weight: 800;
  color: var(--orange-logo, #fe6a17);
}

.dcz-ai-cloud-text span {
  font-size: 10px;
  font-weight: 700;
  color: var(--charcoal, #1e293b);
}

@keyframes dczCloudFloatPulse {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 1;
    filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.14));
  }
  50% {
    transform: translateY(-4px) scale(1.03);
    opacity: 0.9;
    filter: drop-shadow(0 6px 14px rgba(254, 106, 23, 0.28));
  }
}

/* Hiệu ứng lắc đầu nhẹ nhàng thân thiện cho khuôn mặt AI DEX & AI ZIP */
@keyframes dczAiHeadTilt {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-6deg) translateY(-1.5px); }
  75% { transform: rotate(6deg) translateY(-1.5px); }
}

/* Chỉ hiển thị khuôn mặt linh vật gọn đẹp, không cắt tai và không khung viền */
.dcz-ai-avatar-wrap {
  position: relative;
  width: 50px;
  height: 48px;
  flex: 0 0 50px;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dcz-ai-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 50% 75%;
  animation: dczAiHeadTilt 3.2s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.16));
  display: block;
}

.dcz-ai-head .dcz-ai-avatar-img {
  animation-duration: 4s;
}

/* Chấm xanh báo hiệu trợ lý AI đang trực tuyến */
.dcz-ai-online-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #22c55e;
  border: 2px solid var(--white, #ffffff);
  box-shadow: 0 0 0 1.5px rgba(34, 197, 94, 0.28);
}

.dcz-ai-trigger-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.25;
}

.dcz-ai-trigger-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--charcoal, #1e293b);
}

.dcz-ai-trigger-role {
  font-size: 11px;
  font-weight: 700;
  color: var(--orange-logo, #fe6a17);
}

/* Hộp thoại chat mở gọn bên cạnh dải icon liên hệ, không bị tràn mép trên */
.dcz-ai-panel {
  position: fixed;
  right: 76px;
  bottom: 18px;
  width: min(395px, calc(100vw - 96px));
  height: min(540px, calc(100vh - 96px));
  background-color: var(--white, #ffffff);
  border: 1px solid var(--warm-border, #e6e0da);
  border-top: 3px solid var(--orange-logo, #fe6a17);
  border-radius: 14px;
  box-shadow: var(--shadow-md, 0 18px 46px rgba(0, 0, 0, 0.24));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.dcz-ai-panel[hidden] {
  display: none;
}

/* Phần đầu khung chat tông sáng hiện đại, nổi bật mặt linh vật */
.dcz-ai-head {
  background: linear-gradient(135deg, #ffffff 0%, #fff4ec 100%);
  color: var(--charcoal, #1e293b);
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--warm-border, #e6e0da);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dcz-ai-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dcz-ai-head-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.dcz-ai-head-title {
  font-size: 14px;
  font-weight: 800;
  margin: 0;
  color: var(--charcoal, #1e293b);
}

.dcz-ai-head-sub {
  font-size: 11.5px;
  color: var(--text-muted, #64748b);
  margin: 2px 0 0;
}

/* Nút đóng thu gọn khung chat có nền nhẹ */
.dcz-ai-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--warm-border, #e6e0da);
  background: linear-gradient(180deg, #ffffff 0%, #fff4ec 100%);
  color: var(--charcoal, #1e293b);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.dcz-ai-close-btn:hover {
  background: var(--orange-logo, #fe6a17);
  border-color: var(--orange-logo, #fe6a17);
  color: var(--white, #ffffff);
}

/* Thanh chuyển nhanh giữa AI DEX (Kỹ thuật) và AI ZIP (Đơn hàng & CSKH) */
.dcz-ai-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.dcz-ai-switch-btn {
  border: 1px solid var(--warm-border, #e6e0da);
  background: linear-gradient(180deg, #ffffff 0%, #fff5ee 100%);
  color: var(--charcoal, #1e293b);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.dcz-ai-switch-btn:hover {
  background-color: #fff4ee;
  border-color: var(--orange-logo, #fe6a17);
  color: var(--orange-logo, #fe6a17);
}

.dcz-ai-switch-btn.is-active {
  background-color: var(--orange-logo, #fe6a17);
  border-color: var(--orange-logo, #fe6a17);
  color: var(--white, #ffffff);
}

/* Vùng hiển thị tin nhắn hội thoại */
.dcz-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background-color: #faf7f4;
  background-image: radial-gradient(rgba(235, 92, 20, 0.05) 1px, transparent 1px);
  background-size: 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dcz-ai-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 92%;
}

.dcz-ai-msg.is-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Giữ nguyên khuôn mặt linh vật DEX & ZIP cạnh tin nhắn, không khung viền */
.dcz-ai-msg-avatar {
  width: 38px;
  height: 36px;
  flex: 0 0 38px;
  object-fit: contain;
  border: none;
  background: transparent;
  filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.14));
}

.dcz-ai-bubble-text {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--charcoal, #1e293b);
  background: linear-gradient(180deg, #ffffff 0%, #fffaf6 100%);
  border: 1px solid var(--warm-border, #e6e0da);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  word-break: break-word;
}

.dcz-ai-msg.is-user .dcz-ai-bubble-text {
  background: linear-gradient(135deg, #fe6a17 0%, #ea580c 100%);
  border-color: #ea580c;
  color: var(--white, #ffffff);
  font-weight: 500;
}

/* Thẻ thông số kỹ thuật / liên hệ nhân viên thật bên trong tin nhắn AI */
.dcz-ai-card-box {
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background-color: #fff7f2;
  border: 1px solid #ffd4be;
  font-size: 12.2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dcz-ai-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.dcz-ai-action-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 7px;
  background-color: var(--white, #ffffff);
  border: 1px solid var(--orange-logo, #fe6a17);
  color: var(--orange-logo, #fe6a17);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.dcz-ai-action-link:hover {
  background-color: var(--orange-logo, #fe6a17);
  color: var(--white, #ffffff);
}

/* Dải nút gợi ý câu hỏi nhanh chạy ngang 1 hàng mượt mà (Marquee) */
.dcz-ai-quick-row {
  padding: 7px 0;
  overflow: hidden;
  background: linear-gradient(180deg, #fffaf6 0%, #ffffff 100%);
  border-top: 1px solid var(--warm-border, #e6e0da);
}

/* Đường ray chạy ngang chứa 2 nhóm nút lặp vô tận */
.dcz-ai-quick-track {
  display: flex;
  align-items: center;
  width: max-content;
  animation: dczQuickMarquee 18s linear infinite;
}

/* Tạm dừng chạy khi khách rê chuột để dễ bấm nút gợi ý */
.dcz-ai-quick-row:hover .dcz-ai-quick-track {
  animation-play-state: paused;
}

.dcz-ai-quick-group {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-right: 7px;
  flex-shrink: 0;
}

@keyframes dczQuickMarquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.dcz-ai-quick-btn {
  border: 1px solid var(--warm-border, #e6e0da);
  background: linear-gradient(180deg, #ffffff 0%, #fff4ec 100%);
  color: var(--charcoal, #1e293b);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.dcz-ai-quick-btn:hover {
  background-color: #fff4ee;
  border-color: var(--orange-logo, #fe6a17);
  color: var(--orange-logo, #fe6a17);
}

/* Bong bóng trạng thái DEX / ZIP đang soạn tin nhắn với hiệu ứng 3 chấm nảy */
.dcz-ai-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--charcoal, #1e293b);
  font-size: 12.5px;
  font-weight: 600;
}

.dcz-ai-typing-label {
  color: var(--orange-logo, #fe6a17);
}

.dcz-ai-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dcz-ai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--orange-logo, #fe6a17);
  animation: dczTypingBounce 3s infinite ease-in-out;
}

.dcz-ai-typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.dcz-ai-typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes dczTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.38; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Thanh nhập tin nhắn ở đáy khung chat */
.dcz-ai-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background-color: var(--white, #ffffff);
  border-top: 1px solid var(--warm-border, #e6e0da);
}

/* Thanh nhập tin nhắn bỏ khung viền kép khi trỏ chuột / focus */
.dcz-ai-input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--warm-border, #e6e0da);
  border-radius: 9px;
  background-color: #fcfaf8;
  font-family: inherit;
  font-size: 13px;
  color: var(--charcoal, #1e293b);
  outline: none !important;
  box-shadow: none !important;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.dcz-ai-input:focus {
  border-color: var(--orange-logo, #fe6a17);
  background-color: var(--white, #ffffff);
  outline: none !important;
  box-shadow: none !important;
}

/* Nút Gửi có nền chuyển động mượt màu cam DCZ */
.dcz-ai-send-btn {
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 9px;
  background: linear-gradient(135deg, #fe6a17 0%, #ff8b3d 50%, #ea580c 100%);
  background-size: 200% 200%;
  animation: dczSendBtnFlow 3s ease infinite;
  color: var(--white, #ffffff);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(254, 106, 23, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@keyframes dczSendBtnFlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.dcz-ai-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(254, 106, 23, 0.38);
}

/* Đồng bộ avatar AI với menu liên hệ cam trên điện thoại và máy tính bảng */
@media (max-width: 960px) {
  .dcz-ai-root {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(74px + env(safe-area-inset-bottom) + 310px);
  }

  .dcz-ai-root > .dcz-ai-trigger {
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  }

  /* Ẩn trợ lý AI cùng các icon liên hệ khi menu cam thu gọn; hiện lại khi người dùng mở menu */
  body:not(.dcz-contact-menu-open) .dcz-ai-root > .dcz-ai-trigger {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
  }

  body.dcz-contact-menu-open .dcz-ai-root > .dcz-ai-trigger {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  /* Trên màn hình cảm ứng chỉ giữ avatar AI gọn như một icon, không để bong bóng che các kênh khác */
  .dcz-ai-thought-cloud {
    display: none;
  }
}

/* Tối ưu hiển thị gọn gàng trên màn hình điện thoại (đặt ngay trên danh sách icon liên hệ) */
@media (max-width: 640px) {
  .dcz-ai-root {
    right: 12px;
    bottom: calc(74px + env(safe-area-inset-bottom) + 272px);
  }

  .dcz-ai-trigger {
    padding: 0;
  }

  .dcz-ai-thought-cloud {
    right: 28px;
    bottom: 36px;
    width: 152px;
    height: 68px;
  }

  .dcz-ai-cloud-text strong {
    font-size: 10px;
  }

  .dcz-ai-cloud-text span {
    font-size: 9px;
  }

  .dcz-ai-avatar-wrap {
    width: 42px;
    height: 40px;
    flex-basis: 42px;
  }

  .dcz-ai-trigger-name {
    font-size: 11.5px;
  }

  .dcz-ai-trigger-role {
    font-size: 9.5px;
  }

  .dcz-ai-panel {
    right: 12px;
    bottom: 14px;
    width: calc(100vw - 24px);
    height: min(500px, 74vh);
  }
}
