/**
 * Thai An AI Smart Assistant Stylesheet (Dien May Xanh style)
 *
 * @package ThaiAn
 */

/* 1. Speech Bubble on Floating Launcher */
.thaian-ai-speech-bubble {
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  animation: floatBubble 3s ease-in-out infinite;
}

@keyframes floatBubble {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

.thaian-ai-bubble-arrow {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid #ffffff;
}

/* 2. Chatbox Window Container */
.thaian-ai-chatbox {
  height: 540px;
  max-height: calc(100vh - 120px);
  box-shadow: 0 16px 40px -8px rgba(10, 37, 64, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.04);
  transform-origin: bottom right;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s ease;
  border-radius: 10px !important;
  overflow: hidden;
}

.thaian-ai-chatbox.is-open {
  display: flex !important;
  opacity: 1 !important;
  transform: scale(1) translateY(0) !important;
  pointer-events: auto !important;
}

/* 3. Messages Stream Scrollbar */
.thaian-ai-messages {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.thaian-ai-messages::-webkit-scrollbar {
  width: 5px;
}

.thaian-ai-messages::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 9999px;
}

/* 4. Message Bubbles */
.thaian-msg-row {
  display: flex;
  margin-bottom: 0.75rem;
  animation: fadeInMsg 0.25s ease-out forwards;
}

@keyframes fadeInMsg {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.thaian-msg-row.user-msg {
  justify-content: flex-end;
}

.thaian-msg-bubble.user-bubble {
  background: #0068FF;
  color: #ffffff;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  border-top-right-radius: 0.125rem;
  max-width: 82%;
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(0, 104, 255, 0.2);
  word-break: break-word;
}

.thaian-msg-bubble.bot-bubble {
  background: #ffffff;
  color: #1e293b;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  border-top-left-radius: 0.125rem;
  max-width: 86%;
  line-height: 1.5;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  word-break: break-word;
}

.thaian-msg-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
  text-align: right;
}

/* 5. Mini Product Card in Chat */
.thaian-ai-product-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.thaian-ai-product-card:hover {
  border-color: #009E49;
  box-shadow: 0 4px 10px rgba(0, 158, 73, 0.08);
}

.thaian-ai-product-img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: contain;
  background: #f8fafc;
  flex-shrink: 0;
  border: 1px solid #f1f5f9;
}

.thaian-ai-product-info {
  flex: 1;
  min-width: 0;
}

.thaian-ai-product-title {
  font-size: 12px;
  font-weight: 700;
  color: #0A2540;
  line-height: 1.3;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thaian-ai-product-cat {
  font-size: 10px;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.thaian-ai-product-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 11px;
  font-weight: 700;
  color: #009E49;
  background: rgba(0, 158, 73, 0.08);
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.15s;
  text-decoration: none;
}

.thaian-ai-product-btn:hover {
  background: #009E49;
  color: #ffffff;
}

/* 6. Action Buttons inside Message */
.thaian-ai-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.625rem;
}

.thaian-ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 11px;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  transition: all 0.18s;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}

.thaian-ai-action-btn.btn-call {
  background: #009E49;
  color: #ffffff;
}

.thaian-ai-action-btn.btn-call:hover {
  background: #007A38;
}

.thaian-ai-action-btn.btn-link {
  background: #f1f5f9;
  color: #0A2540;
  border-color: #cbd5e1;
}

.thaian-ai-action-btn.btn-link:hover {
  background: #e2e8f0;
  color: #009E49;
}

.thaian-zalo-svg {
  width: 15px;
  height: 15px;
  display: inline-block;
  vertical-align: -2px;
  flex-shrink: 0;
  margin-right: 5px;
}

.thaian-ai-action-btn.btn-zalo,
.thaian-ai-action-btn[href*="zalo"] {
  background: #f0f7ff;
  color: #0068FF;
  border-color: #bcd9ff;
  font-weight: 600;
}

.thaian-ai-action-btn.btn-zalo:hover,
.thaian-ai-action-btn[href*="zalo"]:hover {
  background: #0068FF;
  color: #ffffff;
  border-color: #0068FF;
}

.thaian-ai-action-btn.btn-zalo:hover svg rect,
.thaian-ai-action-btn[href*="zalo"]:hover svg rect {
  fill: #0050c7;
}

.thaian-chip-btn[data-query*="Zalo"] {
  color: #0068FF;
  background: #f0f7ff;
  border-color: #bcd9ff;
}

.thaian-chip-btn[data-query*="Zalo"]:hover {
  background: #0068FF;
  color: #ffffff;
  border-color: #0068FF;
}

.thaian-chip-btn[data-query*="Zalo"]:hover svg rect {
  fill: #0050c7;
}

/* 7. Quick Chips Bar */
.thaian-chip-btn {
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
  transition: all 0.15s;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.thaian-chip-btn:hover {
  background: #e2e8f0;
  color: #009E49;
  border-color: #cbd5e1;
}

/* 8. Typing Indicator */
.thaian-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.625rem 0.875rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  border-top-left-radius: 0.125rem;
}

.thaian-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typingBounce 1.2s infinite ease-in-out;
}

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

.thaian-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-5px);
  }
}

/* 9. Mobile Responsive adjustments */
@media (max-width: 640px) {
  .thaian-ai-chatbox {
    width: calc(100vw - 24px) !important;
    height: min(540px, 78vh) !important;
    right: 12px !important;
    bottom: 5rem !important;
  }
}