/* ============================================================
   MD-CHATBOX.CSS — Floating AI Chatbox
   ============================================================ */

/* Bubble */
#md-chat-bubble {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #2D8B4E, #4ADE80);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(45,139,78,.4);
  z-index: 2000;
  transition: all .2s;
}
#md-chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(45,139,78,.5); }
#md-chat-bubble.md-chat-hide { transform: scale(0); opacity: 0; pointer-events: none; }

/* Panel */
#md-chat-panel {
  position: fixed;
  bottom: 80px;
  right: 16px;
  width: 360px;
  max-height: 600px;
  background: var(--md-w, #fff);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.15);
  z-index: 2001;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--md-g1, #F0F0F0);
}
#md-chat-panel.md-chat-open { display: flex; }

/* Header */
#md-chat-header {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--md-g1, #F0F0F0);
  background: linear-gradient(135deg, #DCFCE7, #F0FDF4);
}

/* Messages */
#md-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  max-height: 420px;
  min-height: 250px;
}

.md-chat-msg { margin-bottom: 10px; display: flex; }
.md-chat-bot { justify-content: flex-start; }
.md-chat-user { justify-content: flex-end; }

.md-chat-bubble-bot {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px 14px 14px 4px;
  font-size: .84rem;
  line-height: 1.6;
  background: var(--md-g0, #F8F8F8);
  color: var(--md-g8, #1A1A1A);
}

.md-chat-bubble-user {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px 14px 4px 14px;
  font-size: .84rem;
  line-height: 1.6;
  background: linear-gradient(135deg, #2D8B4E, #4ADE80);
  color: #fff;
}

/* TTS button */
.md-chat-tts {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  font-size: .72rem;
  cursor: pointer;
  border-radius: 12px;
  background: #FFF7ED;
  border: 1px solid #FDBA74;
  transition: all .15s;
  user-select: none;
}
.md-chat-tts:hover { background: #FED7AA; }
.md-chat-tts.playing { background: #FFEDD5; border-color: #F97316; }

/* Typing indicator — 3 chấm nhảy */
.md-chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  min-height: auto;
}
.md-chat-typing-dots .dot {
  width: 8px;
  height: 8px;
  background: #A8D5B8;
  border-radius: 50%;
  display: inline-block;
  animation: md-dot-bounce .9s ease-in-out infinite;
}
.md-chat-typing-dots .dot:nth-child(2) { animation-delay: .15s; }
.md-chat-typing-dots .dot:nth-child(3) { animation-delay: .3s; }
@keyframes md-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .35; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* Quick buttons */
#md-chat-quick {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--md-g1, #F0F0F0);
  background: var(--md-g0, #FAFAFA);
}
#md-chat-quick span {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 16px;
  font-size: .72rem;
  font-weight: 500;
  color: #2D8B4E;
  background: #DCFCE7;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
#md-chat-quick span:hover { background: #BBF7D0; }

/* Input */
#md-chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--md-g1, #F0F0F0);
  background: var(--md-w, #fff);
}
#md-chat-inp {
  flex: 1;
  border: 1.5px solid var(--md-g2, #E5E5E5);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .84rem;
  font-family: inherit;
  outline: none;
  color: var(--md-g8, #1A1A1A);
}
#md-chat-inp:focus { border-color: var(--md-primary, #4F46E5); }
#md-chat-inp::placeholder { color: var(--md-g4, #AAA); }

#md-chat-send {
  width: 38px;
  height: 38px;
  border: none;
  background: linear-gradient(135deg, #2D8B4E, #4ADE80);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s;
}
#md-chat-send:hover { opacity: .85; }

/* Responsive */
@media (max-width: 480px) {
  #md-chat-bubble { bottom: 72px; right: 12px; width: 46px; height: 46px; }
  #md-chat-bubble span { font-size: 1.2rem; }
  #md-chat-panel { bottom: 0; right: 0; left: 0; width: 100%; max-height: 90vh; border-radius: 16px 16px 0 0; }
  #md-chat-messages { max-height: 60vh; }
}
