/**
 * Lynkova Support Chatbot Widget Styles
 * Sleek, dark mode, glassmorphism, responsive, and animated.
 */

:root {
  --chatbot-primary: #7C3AED;
  --chatbot-secondary: #A855F7;
  --chatbot-bg: rgba(13, 13, 20, 0.92);
  --chatbot-card-bg: rgba(255, 255, 255, 0.06);
  --chatbot-border: rgba(255, 255, 255, 0.09);
  --chatbot-text: #FAFAFA;
  --chatbot-text-muted: rgba(255, 255, 255, 0.5);
}

/* --- Floating Chat Bubble --- */
.chatbot-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.5), 0 0 0 1px rgba(168, 85, 247, 0.3);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  outline: none;
  overflow: visible;
  padding: 0;
}

.chatbot-bubble-img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.chatbot-bubble:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.65);
}

.chatbot-bubble-ping {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background-color: #10B981;
  border: 2px solid #0D0D11;
  border-radius: 50%;
  animation: chatbot-pulse 2s infinite;
}

@keyframes chatbot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* --- Chat Window Container --- */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 390px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--chatbot-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--chatbot-border);
  border-radius: 20px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(168, 85, 247, 0.12);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.chatbot-window.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* --- Header --- */
.chatbot-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(0, 0, 0, 0.3));
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

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

.chatbot-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.chatbot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid rgba(168, 85, 247, 0.4);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.3);
}

.chatbot-status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  background-color: #10B981;
  border: 2px solid #0d0d14;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.chatbot-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--chatbot-text);
  line-height: 1.2;
}

.chatbot-subtitle {
  font-size: 0.72rem;
  color: var(--chatbot-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chatbot-online-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #10B981;
  border-radius: 50%;
  box-shadow: 0 0 4px #10B981;
  animation: chatbot-pulse 2s infinite;
}

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

.chatbot-action-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--chatbot-text-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s, color 0.2s;
  font-size: 0.8rem;
}

.chatbot-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--chatbot-text);
  border-color: rgba(255, 255, 255, 0.12);
}

/* --- Messages Container --- */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.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(168, 85, 247, 0.3); }

/* Message Row */
.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 88%;
}

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

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

/* Bot Message Avatar */
.chat-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

.chat-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-message-bubble {
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 14px;
  word-break: break-word;
}

/* Rendered message content */
.chat-message-bubble p {
  margin: 0 0 6px 0;
}
.chat-message-bubble p:last-child {
  margin-bottom: 0;
}
.chat-message-bubble .chat-spacer {
  height: 6px;
}
.chat-message-bubble .chat-list {
  margin: 4px 0 6px 0;
  padding-left: 18px;
  list-style: disc;
}
.chat-message-bubble .chat-list li {
  margin-bottom: 3px;
  line-height: 1.45;
}
.chat-message-bubble .chat-link {
  color: #C4B5FD;
  text-decoration: underline;
  word-break: break-all;
}
.chat-message.user .chat-message-bubble .chat-link {
  color: rgba(255,255,255,0.85);
}

.chat-message.user .chat-message-bubble {
  background: linear-gradient(135deg, var(--chatbot-primary), #6D28D9);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

.chat-message.bot .chat-message-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
  border-bottom-left-radius: 4px;
}

/* --- Typing Indicator Animation --- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--chatbot-secondary);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
  opacity: 0.7;
}

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

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* --- Quick Reply Chips --- */
.chatbot-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 14px 6px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.quick-reply-btn {
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.35);
  color: rgba(168, 85, 247, 0.95);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.quick-reply-btn:hover {
  background: rgba(124, 58, 237, 0.28);
  border-color: rgba(168, 85, 247, 0.65);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(124, 58, 237, 0.25);
}

/* --- Input Form --- */
.chatbot-input-area {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chatbot-input-wrap {
  flex: 1;
  position: relative;
}

.chatbot-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--chatbot-border);
  border-radius: 20px;
  padding: 9px 16px;
  color: var(--chatbot-text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.chatbot-input::placeholder { color: rgba(255,255,255,0.3); }

.chatbot-input:focus {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.chatbot-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
  border: none;
  color: #ffffff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
}

.chatbot-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5);
}

.chatbot-send-btn:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--chatbot-text-muted);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* --- Responsive Adaptations --- */
@media (max-width: 480px) {
  .chatbot-bubble {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  .chatbot-bubble-img {
    width: 54px;
    height: 54px;
  }
  .chatbot-window {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .chatbot-window.active {
    transform: translateY(0) scale(1);
  }
}
