/* ==========================================================================
   Thun Kal Dakma - AI Assistant & Chatbot Styles
   ========================================================================== */

/* Floating Launcher Button */
.tkd-chat-launcher {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1f4d38 0%, #163a2b 100%);
  color: #ffffff;
  padding: 14px 22px;
  border-radius: 50px;
  border: 2px solid #d8b347;
  box-shadow: 0 10px 30px rgba(31, 77, 56, 0.35);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  user-select: none;
}

.tkd-chat-launcher:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 14px 35px rgba(216, 179, 71, 0.4);
  background: linear-gradient(135deg, #163a2b 0%, #0e271d 100%);
}

.tkd-chat-launcher .launcher-icon {
  font-size: 1.35rem;
  color: #efd98b;
  animation: tkd-pulse 2.5s infinite;
}

.tkd-chat-launcher .launcher-text {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
}

.tkd-chat-launcher .launcher-badge {
  background: #d8b347;
  color: #163a2b;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

@keyframes tkd-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); filter: drop-shadow(0 0 6px rgba(239, 217, 139, 0.8)); }
  100% { transform: scale(1); }
}

/* Floating Chat Drawer / Popup */
.tkd-chat-container {
  position: fixed;
  bottom: 95px;
  left: 28px;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  border: 1px solid rgba(216, 179, 71, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.tkd-chat-container.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Chat Header */
.tkd-chat-header {
  background: linear-gradient(135deg, #1f4d38 0%, #163a2b 100%);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #d8b347;
}

.tkd-chat-header .header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tkd-chat-header .bot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  border: 1.5px solid #efd98b;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #efd98b;
  font-size: 1.25rem;
}

.tkd-chat-header .header-titles h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.tkd-chat-header .header-titles span {
  font-size: 0.78rem;
  color: #efd98b;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tkd-chat-header .status-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #22c55e;
}

.tkd-chat-header .header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tkd-chat-header .header-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.tkd-chat-header .header-btn:hover {
  background: rgba(216, 179, 71, 0.35);
  color: #efd98b;
}

/* Chat Messages Area */
.tkd-chat-messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fbfbf8;
  scroll-behavior: smooth;
}

.tkd-chat-messages::-webkit-scrollbar {
  width: 5px;
}
.tkd-chat-messages::-webkit-scrollbar-thumb {
  background: #d8b347;
  border-radius: 10px;
}

/* Message Bubble */
.tkd-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: tkd-fadeInUp 0.3s ease;
}

.tkd-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.tkd-msg.bot {
  align-self: flex-start;
}

.tkd-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.tkd-msg.user .tkd-msg-avatar {
  background: #d8b347;
  color: #163a2b;
}

.tkd-msg.bot .tkd-msg-avatar {
  background: #1f4d38;
  color: #efd98b;
}

.tkd-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.6;
  position: relative;
  word-break: break-word;
}

.tkd-msg.user .tkd-msg-bubble {
  background: #1f4d38;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.tkd-msg.bot .tkd-msg-bubble {
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.tkd-msg-bubble p {
  margin-bottom: 8px;
}
.tkd-msg-bubble p:last-child {
  margin-bottom: 0;
}

.tkd-msg-bubble h3, .tkd-msg-bubble h4 {
  margin-top: 6px;
  margin-bottom: 8px;
  color: #1f4d38;
  font-size: 1rem;
}

.tkd-msg-bubble ul, .tkd-msg-bubble ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.tkd-msg-bubble blockquote {
  border-left: 3px solid #d8b347;
  padding-left: 10px;
  margin: 8px 0;
  color: #4b5563;
  font-style: italic;
  background: #fdfaf0;
  padding: 6px 10px;
  border-radius: 0 8px 8px 0;
}

/* ABCD Result Cards */
.tkd-abcd-box {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tkd-abcd-item {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tkd-abcd-item.a { background: #fff1f2; border-left: 4px solid #e11d48; }
.tkd-abcd-item.b { background: #fefce8; border-left: 4px solid #ca8a04; }
.tkd-abcd-item.c { background: #ecfdf5; border-left: 4px solid #059669; }
.tkd-abcd-item.d { background: #eff6ff; border-left: 4px solid #2563eb; }

.tkd-abcd-item strong {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tkd-abcd-item.a strong { color: #be123c; }
.tkd-abcd-item.b strong { color: #a16207; }
.tkd-abcd-item.c strong { color: #047857; }
.tkd-abcd-item.d strong { color: #1d4ed8; }

/* Links & Suggestion Chips */
.tkd-chat-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tkd-chat-links a {
  background: #f0fdf4;
  color: #1f4d38;
  border: 1px solid #bbf7d0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.tkd-chat-links a:hover {
  background: #1f4d38;
  color: #ffffff;
}

/* Quick Prompt Suggestions */
.tkd-suggestions-bar {
  padding: 8px 16px;
  background: #ffffff;
  border-top: 1px solid #f3f4f6;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
}

.tkd-suggestions-bar::-webkit-scrollbar {
  height: 3px;
}
.tkd-suggestions-bar::-webkit-scrollbar-thumb {
  background: #e5e7eb;
}

.tkd-chip {
  background: #f3f4f6;
  color: #374151;
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tkd-chip:hover {
  background: #d8b347;
  color: #163a2b;
  border-color: #d8b347;
  font-weight: 600;
}

/* Typing Indicator */
.tkd-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 14px;
  width: fit-content;
  border: 1px solid #e5e7eb;
}

.tkd-typing-dot {
  width: 6px;
  height: 6px;
  background: #1f4d38;
  border-radius: 50%;
  animation: tkd-typing 1.4s infinite ease-in-out;
}

.tkd-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.tkd-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes tkd-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Chat Input Bar */
.tkd-chat-input-wrap {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tkd-chat-input {
  flex: 1;
  border: 1.5px solid #d1d5db;
  border-radius: 25px;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.tkd-chat-input:focus {
  border-color: #1f4d38;
  box-shadow: 0 0 0 3px rgba(31, 77, 56, 0.12);
}

.tkd-send-btn {
  background: #1f4d38;
  color: #ffffff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.tkd-send-btn:hover {
  background: #163a2b;
  transform: scale(1.05);
}

.tkd-send-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
}

@keyframes tkd-fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Full Page AI Assistant Portal */
.ai-portal-wrap {
  width: min(1200px, 92%);
  margin: 30px auto 60px auto;
}

.ai-portal-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 25px;
  margin-top: 25px;
}

@media (max-width: 900px) {
  .ai-portal-grid {
    grid-template-columns: 1fr;
  }
  .tkd-chat-container {
    left: 16px;
    bottom: 85px;
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
  }
  .tkd-chat-launcher {
    left: 16px;
    bottom: 20px;
  }
}
