/* =============================================
   chatbox.css — AI Chat Widget
   ============================================= */

/* Nút mở chat */
.chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
  overflow: visible;
}
.chat-toggle img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.28);
}
.chat-toggle .chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}
.chat-toggle .chat-badge.show { display: flex; }

/* Cửa sổ chat */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 340px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1200;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), opacity 0.22s;
}
.chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header chat */
.chat-header {
  background: linear-gradient(135deg, #2e7d32, #43a047);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.chat-header-status {
  font-size: 10px;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-header-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a5d6a7;
}
.chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  padding: 4px;
  line-height: 0;
  border-radius: 4px;
  transition: background 0.15s;
}
.chat-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f9fafb;
  min-height: 0;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* Bubble */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.msg.ai { align-self: flex-start; }
.msg.user { align-self: flex-end; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}
.msg.ai .msg-bubble {
  background: #fff;
  color: #212121;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.msg.user .msg-bubble {
  background: #2e7d32;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-time {
  font-size: 10px;
  color: #bbb;
  margin-top: 3px;
  padding: 0 2px;
}
.msg.user .msg-time { align-self: flex-end; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 10px 13px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  width: fit-content;
}
.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  animation: typingDot 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: none;
  line-height: 1.4;
  max-height: 80px;
  overflow-y: auto;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: #43a047; }
.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2e7d32;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.chat-send:hover { background: #1b5e20; }
.chat-send:active { transform: scale(0.92); }
.chat-send:disabled { background: #ccc; cursor: not-allowed; }
.chat-send svg { width: 16px; height: 16px; color: #fff; }

/* Gợi ý nhanh */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
  background: #f9fafb;
}
.chat-chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1.5px solid #c8e6c9;
  background: #fff;
  color: #2e7d32;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
}
.chat-chip:hover { background: #e8f5e9; }

@media (max-width: 400px) {
  .chat-window { right: 10px; left: 10px; width: auto; }
  .chat-toggle { right: 16px; bottom: 20px; }
}
