/* ==========================================================================
   TechStore - Google Gemini AI Chatbot Stylesheet
   Kế thừa 100% theme.css (Không hardcode màu sắc, chuẩn biến CSS)
   ========================================================================== */

.chatbot-container {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 1080;
  font-family: var(--bs-font-sans-serif, 'Be Vietnam Pro', sans-serif);
}

/* ==================== 1. TOGGLE BUTTON (NÚT NỔI GÓC PHẢI) ==================== */
.chatbot-toggler {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-gradient, linear-gradient(135deg, #FF6B00 0%, #FF8C00 100%));
  color: var(--white-color, #ffffff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(255, 107, 0, 0.4);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  outline: none;
  z-index: 1082;
}

.chatbot-toggler:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 25px rgba(255, 107, 0, 0.55);
}

.chatbot-toggler:active {
  transform: scale(0.96);
}

.toggler-icon-chat,
.toggler-icon-close {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toggler-icon-chat svg {
  fill: var(--white-color, #ffffff);
  width: 28px;
  height: 28px;
}

.toggler-icon-close {
  position: absolute;
  font-size: 1.8rem;
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
  color: var(--white-color, #ffffff);
}

/* Trạng thái khi mở chat */
.chatbot-container.is-open .chatbot-toggler {
  background: #343a40;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.chatbot-container.is-open .toggler-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

.chatbot-container.is-open .toggler-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Pulse animation quanh nút */
.toggler-pulse {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary, #FF6B00);
  animation: chatbotPulse 2.2s infinite cubic-bezier(0.25, 0, 0, 1);
  pointer-events: none;
}

.chatbot-container.is-open .toggler-pulse {
  display: none;
}

@keyframes chatbotPulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  70% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* ==================== 2. TOOLTIP GỢI MỞ ==================== */
.chatbot-tooltip {
  position: absolute;
  bottom: 12px;
  right: 70px;
  background: var(--white-color, #ffffff);
  color: #212529;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: var(--fs-xs, 1.25rem);
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: chatbotTooltipFadeIn 0.4s ease forwards;
  z-index: 1081;
}

.chatbot-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--white-color, #ffffff);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.tooltip-close {
  background: none;
  border: none;
  color: var(--text-muted, #8A8F99);
  cursor: pointer;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
}

.tooltip-close:hover {
  color: #212529;
}

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

.chatbot-container.is-open .chatbot-tooltip,
.chatbot-tooltip.is-hidden {
  display: none !important;
}

/* ==================== 3. CHATBOT POPUP WINDOW ==================== */
.chatbot-popup {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--white-color, #ffffff);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.92);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1081;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

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

/* ==================== 4. HEADER ==================== */
.chatbot-header {
  background: var(--primary-gradient, linear-gradient(135deg, #FF6B00 0%, #FF8C00 100%));
  color: var(--white-color, #ffffff);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.header-avatar svg {
  fill: var(--white-color, #ffffff);
}

.header-titles h3 {
  margin: 0;
  font-size: var(--fs-sm, 1.4rem);
  font-weight: 700;
  color: var(--white-color, #ffffff);
  line-height: 1.2;
}

.header-status {
  font-size: var(--fs-xs, 1.15rem);
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #28a745;
  display: inline-block;
  box-shadow: 0 0 6px #28a745;
}

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

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

.header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

/* ==================== 5. BODY & MESSAGES ==================== */
.chatbot-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--page-bg, #f9f9fb);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--primary, #FF6B00) #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--primary, #FF6B00);
  border-radius: 4px;
}

/* Messages styling */
.message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 86%;
  animation: chatbotMsgFadeIn 0.25s ease-out;
}

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

/* Bot Message */
.bot-message {
  align-self: flex-start;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary, #FF6B00);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-avatar svg {
  fill: var(--white-color, #ffffff);
}

.bot-message .message-content {
  background: var(--white-color, #ffffff);
  color: #212529;
  border-radius: 4px 16px 16px 16px;
  padding: 12px 14px;
  font-size: var(--fs-xs, 1.3rem);
  line-height: 1.55;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.06);
  word-break: break-word;
}

.bot-message .message-content p {
  margin-bottom: 8px;
}

.bot-message .message-content p:last-child {
  margin-bottom: 0;
}

.bot-message .message-content strong {
  font-weight: 600;
  color: var(--primary-dark, #E55A00);
}

.bot-message .message-content ul,
.bot-message .message-content ol {
  margin: 6px 0;
  padding-left: 20px;
}

.bot-message .message-content li {
  margin-bottom: 4px;
}

.bot-message .message-content a {
  color: var(--primary, #FF6B00);
  text-decoration: underline;
  font-weight: 600;
}

/* User Message */
.user-message {
  align-self: flex-end;
  justify-content: flex-end;
}

.user-message .message-content {
  background: var(--primary-gradient, linear-gradient(135deg, #FF6B00 0%, #FF8C00 100%));
  color: var(--white-color, #ffffff);
  border-radius: 16px 4px 16px 16px;
  padding: 10px 14px;
  font-size: var(--fs-xs, 1.3rem);
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(255, 107, 0, 0.25);
  word-break: break-word;
}

.user-message .message-content p {
  margin: 0;
}

/* ==================== 6. TYPING INDICATOR ==================== */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  background: var(--white-color, #ffffff);
  border-radius: 4px 16px 16px 16px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary, #FF6B00);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.1);
    opacity: 1;
  }
}

/* ==================== 7. QUICK CHIPS ==================== */
.chatbot-quick-chips {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.7);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.chatbot-quick-chips::-webkit-scrollbar {
  display: none;
}

.quick-chip {
  background: var(--white-color, #ffffff);
  color: #495057;
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 5px 11px;
  border-radius: 20px;
  font-size: var(--fs-xs, 1.15rem);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.quick-chip i {
  color: var(--primary, #FF6B00);
}

.quick-chip:hover {
  background: var(--primary-subtle, #FFF4ED);
  color: var(--primary-dark, #E55A00);
  border-color: var(--primary, #FF6B00);
  transform: translateY(-1px);
}

/* ==================== 8. FOOTER & INPUT ==================== */
.chatbot-footer {
  padding: 12px 14px;
  background: var(--white-color, #ffffff);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.chatbot-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--page-bg, #f9f9fb);
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 24px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-form:focus-within {
  border-color: var(--primary, #FF6B00);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
  background: var(--white-color, #ffffff);
}

.chatbot-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: var(--fs-xs, 1.3rem);
  color: #212529;
  font-family: inherit;
  padding: 6px 0;
}

.chatbot-input::placeholder {
  color: var(--text-muted, #8A8F99);
  font-size: var(--fs-xs, 1.25rem);
}

.chatbot-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-gradient, linear-gradient(135deg, #FF6B00 0%, #FF8C00 100%));
  color: var(--white-color, #ffffff);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.chatbot-send-btn:hover {
  transform: scale(1.08);
}

.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chatbot-disclaimer {
  text-align: center;
  font-size: 1rem;
  color: var(--text-muted, #8A8F99);
  margin-top: 6px;
}

/* ==================== 9. RESPONSIVE MOBILE ==================== */
@media (max-width: 576px) {
  .chatbot-container {
    bottom: 16px;
    right: 16px;
  }

  .chatbot-toggler {
    width: 50px;
    height: 50px;
  }

  .toggler-icon-chat svg {
    width: 24px;
    height: 24px;
  }

  .chatbot-popup {
    bottom: 66px;
    right: 0;
    width: calc(100vw - 32px);
    height: 520px;
    border-radius: 16px;
  }

  .chatbot-tooltip {
    display: none !important;
  }
}
