/* chatbot/chatbot.css - Giao diện Chatbot Trợ lý Xưởng In ATVMedia */
:root {
  --atv-cb-primary: #0a4c8a;
  --atv-cb-primary-dark: #073562;
  --atv-cb-primary-light: #1868b7;
  --atv-cb-accent: #f59e0b;
  --atv-cb-bg: #f8fafc;
  --atv-cb-card-bg: #ffffff;
  --atv-cb-text: #1e293b;
  --atv-cb-muted: #64748b;
  --atv-cb-border: #e2e8f0;
  --atv-cb-shadow: 0 10px 25px -5px rgba(10, 76, 138, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --atv-cb-radius: 16px;
}

/* NÚT BUBBLE MỞ CHATBOT (NẰM PHÍA TRÊN NÚT ZALO VÀ HOTLINE) */
.atv-chatbot-launcher {
  position: fixed;
  bottom: 205px;
  right: 18px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.atv-chatbot-launcher.chat-open {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.atv-chatbot-launcher-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a4c8a 0%, #1e70bf 100%);
  box-shadow: 0 6px 20px rgba(10, 76, 138, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 23px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.atv-chatbot-launcher:hover .atv-chatbot-launcher-btn {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 10px 28px rgba(10, 76, 138, 0.55);
}

/* Hiệu ứng sóng pulse */
.atv-chatbot-launcher-btn::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid rgba(14, 116, 219, 0.6);
  animation: atvCbPulse 2.4s infinite;
  z-index: -1;
}

@keyframes atvCbPulse {
  0% { transform: scale(0.95); opacity: 1; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

.atv-chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.atv-chatbot-tooltip {
  background: #ffffff;
  color: #0a4c8a;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0,0,0,0.12);
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.atv-chatbot-tooltip span.pulse-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* KHUNG CỬA SỔ POPUP CHAT */
.atv-chatbot-window {
  position: fixed;
  bottom: 25px;
  right: 20px;
  width: 380px;
  height: 560px;
  max-width: calc(100vw - 30px);
  max-height: calc(100vh - 50px);
  background: #ffffff;
  border-radius: var(--atv-cb-radius);
  box-shadow: var(--atv-cb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(10, 76, 138, 0.15);
}

.atv-chatbot-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 1. HEADER CHATBOT */
.atv-cb-header {
  background: linear-gradient(135deg, #0a4c8a 0%, #155e9c 100%);
  color: #ffffff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  flex-shrink: 0;
}

.atv-cb-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.atv-cb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a4c8a;
  font-size: 22px;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  border: 2px solid #60a5fa;
}

.atv-cb-status-indicator {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

.atv-cb-info {
  line-height: 1.3;
}

.atv-cb-name {
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 5px;
}

.atv-cb-badge-ai {
  font-size: 10px;
  background: rgba(255,255,255,0.25);
  color: #fff;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
}

.atv-cb-status-text {
  font-size: 12px;
  color: #e0f2fe;
  opacity: 0.9;
}

.atv-cb-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.atv-cb-header-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
}

.atv-cb-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(15deg);
}

.atv-cb-header-btn.close:hover {
  transform: rotate(90deg);
}

/* 2. BODY MESSAGES */
.atv-cb-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.atv-cb-body::-webkit-scrollbar {
  width: 5px;
}
.atv-cb-body::-webkit-scrollbar-track {
  background: transparent;
}
.atv-cb-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* QUICK CHIPS SUGGESTIONS */
.atv-cb-chips-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.atv-cb-chips-title {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.atv-cb-chips-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.atv-cb-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  padding: 6px 11px;
  font-size: 12.5px;
  color: #0a4c8a;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.atv-cb-chip:hover {
  background: #0a4c8a;
  color: #ffffff;
  border-color: #0a4c8a;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(10, 76, 138, 0.2);
}

/* BONG BÓNG TIN NHẮN */
.atv-cb-msg-row {
  display: flex;
  gap: 8px;
  max-width: 88%;
}

.atv-cb-msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.atv-cb-msg-row.assistant {
  align-self: flex-start;
}

.atv-cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #0a4c8a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.atv-cb-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.atv-cb-msg-row.user .atv-cb-bubble {
  background: linear-gradient(135deg, #0a4c8a 0%, #1765ad 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.atv-cb-msg-row.assistant .atv-cb-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

.atv-cb-bubble p {
  margin: 0 0 6px 0;
}
.atv-cb-bubble p:last-child {
  margin-bottom: 0;
}

.atv-cb-bubble a {
  color: #0284c7;
  text-decoration: underline;
  font-weight: 600;
}
.atv-cb-msg-row.user .atv-cb-bubble a {
  color: #bae6fd;
}

.atv-cb-time {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 3px;
  text-align: right;
}
.atv-cb-msg-row.user .atv-cb-time {
  color: #cbd5e1;
}

/* THẺ GỢI Ý SẢN PHẨM (PRODUCT CARDS) */
.atv-cb-products-wrap {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.atv-cb-product-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.atv-cb-product-card:hover {
  border-color: #0a4c8a;
  background: #f0f7ff;
  transform: translateX(2px);
}

.atv-cb-product-img {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e2e8f0;
}

.atv-cb-product-info {
  flex: 1;
  min-width: 0;
}

.atv-cb-product-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #0a4c8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.atv-cb-product-btn {
  font-size: 11px;
  color: #0284c7;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}

/* TYPING INDICATOR */
.atv-cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid #e2e8f0;
  width: fit-content;
}

.atv-cb-typing span {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: atvCbBounce 1.4s infinite ease-in-out both;
}

.atv-cb-typing span:nth-child(1) { animation-delay: -0.32s; }
.atv-cb-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes atvCbBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; background: #0a4c8a; }
}

/* 3. FOOTER INPUT */
.atv-cb-footer {
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.atv-cb-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 22px;
  padding: 6px 12px;
  transition: all 0.2s ease;
}

.atv-cb-input-wrap:focus-within {
  border-color: #0a4c8a;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(10, 76, 138, 0.15);
}

.atv-cb-textarea {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  line-height: 1.4;
  resize: none;
  max-height: 80px;
  font-family: inherit;
  color: #1e293b;
  padding: 2px 0;
}

.atv-cb-textarea::placeholder {
  color: #94a3b8;
}

.atv-cb-send-btn {
  background: #0a4c8a;
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 13px;
  transition: all 0.2s ease;
}

.atv-cb-send-btn:hover {
  background: #073562;
  transform: scale(1.05);
}

.atv-cb-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

.atv-cb-credit {
  font-size: 10.5px;
  color: #94a3b8;
  text-align: center;
  line-height: 1.2;
}

.atv-cb-credit a {
  color: #0a4c8a;
  text-decoration: none;
  font-weight: 600;
}

/* RESPONSIVE TRÊN MOBILE */
@media (max-width: 576px) {
  .atv-chatbot-launcher {
    bottom: 172px;
    right: 13px;
    gap: 0;
  }
  .atv-chatbot-launcher-btn {
    width: 44px;
    height: 44px;
    font-size: 19px;
  }
  .atv-chatbot-tooltip {
    display: none; /* Ẩn tooltip trên màn hình nhỏ để không che nội dung */
  }
  .atv-chatbot-window {
    bottom: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    height: calc(100vh - 20px);
    max-height: 650px;
    border-radius: 16px;
  }
}
