/* ================================================
   AI CHATBOT WIDGET — daututaichinh.pro
   Floating Chat | Dark Theme | Gemini AI
   ================================================ */

/* ===== CSS VARIABLES ===== */
:root {
  --chat-primary: #2563eb;
  --chat-primary-light: #3b82f6;
  --chat-bg-dark: #0b1220;
  --chat-bg-card: #0f172a;
  --chat-bg-input: #111b2e;
  --chat-border: rgba(255,255,255,0.08);
  --chat-text: #e5e7eb;
  --chat-text-muted: #94a3b8;
  --chat-radius: 16px;
  --chat-width: 400px;
  --chat-height: 560px;
}


/* ===== FLOATING BUTTON ===== */
.chatbot-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 20px rgba(37, 99, 235, 0.4),
    0 0 0 0 rgba(37, 99, 235, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: chatPulse 2.5s ease-in-out infinite;
}

.chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(37, 99, 235, 0.55);
  animation: none;
}

.chatbot-toggle .chat-icon {
  transition: transform 0.3s ease, opacity 0.2s ease;
}

.chatbot-toggle.active .chat-icon {
  transform: rotate(90deg);
  opacity: 0;
  position: absolute;
}

.chatbot-toggle .close-icon {
  opacity: 0;
  transform: rotate(-90deg);
  transition: transform 0.3s ease, opacity 0.2s ease;
  position: absolute;
}

.chatbot-toggle.active .close-icon {
  opacity: 1;
  transform: rotate(0deg);
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4), 0 0 0 0 rgba(37, 99, 235, 0.3); }
  50%      { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4), 0 0 0 12px rgba(37, 99, 235, 0); }
}

/* Notification badge */
.chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--chat-bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  animation: badgeBounce 0.5s ease;
}

@keyframes badgeBounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Floating label "Chat với AI" */
.chatbot-label {
  position: absolute;
  right: 68px;
  white-space: nowrap;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
  cursor: pointer;
  animation: labelSlideIn 0.6s ease 3s both, labelPulse 3s ease-in-out 4s infinite;
}

.chatbot-label::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-left-color: #5b3aed;
  border-right: none;
}

.chatbot-toggle.active .chatbot-label {
  display: none;
}

@keyframes labelSlideIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes labelPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35); }
  50%      { box-shadow: 0 4px 24px rgba(124, 58, 237, 0.55); }
}


/* ===== CHAT WINDOW ===== */
.chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 9991;
  width: var(--chat-width);
  height: var(--chat-height);
  background: var(--chat-bg-dark);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

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


/* ===== CHAT HEADER ===== */
.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #111b2e 0%, #0f172a 100%);
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.chatbot-header-info {
  flex: 1;
  min-width: 0;
}

.chatbot-header-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.chatbot-header-status {
  font-size: 12px;
  color: #86efac;
  display: flex;
  align-items: center;
  gap: 5px;
}

.chatbot-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.chatbot-header-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
  color: var(--chat-text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.chatbot-header-close:hover {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
}


/* ===== MESSAGES AREA ===== */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Scrollbar */
.chatbot-messages::-webkit-scrollbar {
  width: 5px;
}
.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}
.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}


/* ===== MESSAGE BUBBLES ===== */
.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: msgFadeIn 0.35s ease;
}

.chat-msg.bot {
  align-self: flex-start;
}

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

.chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-msg.bot .chat-msg-avatar {
  background: linear-gradient(135deg, #1e40af, #6d28d9);
}

.chat-msg.user .chat-msg-avatar {
  background: linear-gradient(135deg, #059669, #047857);
}

.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-msg.bot .chat-msg-bubble {
  background: var(--chat-bg-card);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  border-top-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border-top-right-radius: 4px;
}

/* Links inside bot messages */
.chat-msg.bot .chat-msg-bubble a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 500;
}

.chat-msg.bot .chat-msg-bubble a:hover {
  text-decoration: underline;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ===== TYPING INDICATOR ===== */
.chat-typing {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 88%;
  animation: msgFadeIn 0.3s ease;
}

.chat-typing .chat-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e40af, #6d28d9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background: var(--chat-bg-card);
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  border-top-left-radius: 4px;
}

.chat-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chat-text-muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

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


/* ===== QUICK ACTIONS ===== */
.chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 14px;
  flex-shrink: 0;
}

.chat-quick-btn {
  padding: 8px 14px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 20px;
  color: #60a5fa;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, border-color 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.chat-quick-btn:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.chat-quick-btn:active {
  transform: translateY(0);
}


/* ===== INPUT AREA ===== */
.chatbot-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--chat-bg-input);
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--chat-bg-dark);
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  color: var(--chat-text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

.chatbot-input:focus {
  border-color: var(--chat-primary);
}

.chatbot-input::placeholder {
  color: #4b5563;
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 10px;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  flex-shrink: 0;
}

.chatbot-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.chatbot-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}


/* ===== DISCLAIMER ===== */
.chatbot-disclaimer {
  padding: 6px 16px 8px;
  text-align: center;
  font-size: 10px;
  color: #475569;
  background: var(--chat-bg-input);
  line-height: 1.3;
}


/* ===== WELCOME MESSAGE ACTIONS ===== */
.chat-welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.chat-welcome-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 10px;
  color: #60a5fa;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  text-decoration: none;
  font-family: inherit;
}

.chat-welcome-btn:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.4);
}


/* ===== SETUP WARNING ===== */
.chatbot-setup-warning {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  flex: 1;
}

.chatbot-setup-warning .setup-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.chatbot-setup-warning h3 {
  font-size: 16px;
  color: #ffffff;
  margin-bottom: 8px;
}

.chatbot-setup-warning p {
  font-size: 13px;
  color: var(--chat-text-muted);
  line-height: 1.5;
}


/* ===== RESPONSIVE (MOBILE) ===== */
@media (max-width: 480px) {
  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-height: 100dvh;
  }

  .chatbot-toggle {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
    font-size: 24px;
  }

  .chatbot-label {
    display: none;
  }

  .chat-quick-actions {
    padding: 0 12px 12px;
  }

  .chatbot-input-area {
    padding: 10px 12px;
  }
}

@media (max-width: 640px) and (min-width: 481px) {
  .chatbot-window {
    right: 12px;
    bottom: 88px;
    width: calc(100vw - 24px);
    max-width: 400px;
    height: 70vh;
  }
}
