/* ========================================
   LetX Technologies — LeXa Business Chatbot
   ======================================== */

/* ─── Color Tokens ─────────────────────── */
:root {
  --letx-navy:        #F1F5F9;
  --letx-navy-2:      #E2E8F0;
  --letx-navy-3:      #CBD5E1;
  --letx-blue:        #864ffe;
  --letx-blue-mid:    #7c31f6;
  --letx-blue-light:  #a585ff;
  --letx-border:      rgba(0, 0, 0, 0.08);
  --letx-border-soft: rgba(0, 0, 0, 0.04);
  --letx-text:        #1E293B;
  --letx-text-muted:  #64748B;
  --letx-green:       #10B981;
}

/* ─── Toggle Button ─────────────────────── */
#letx-chatbot-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--letx-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(134, 79, 254, 0.45), 0 1px 6px rgba(0,0,0,0.3);
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
  outline: none;
}

#letx-chatbot-toggle:hover {
  transform: scale(1.07);
  background: var(--letx-blue-mid);
  box-shadow: 0 6px 28px rgba(124, 49, 246, 0.55), 0 2px 8px rgba(0,0,0,0.3);
}

#letx-chatbot-toggle svg {
  width: 26px;
  height: 26px;
  color: #fff;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

#letx-chatbot-toggle .icon-chat  { display: block; }
#letx-chatbot-toggle .icon-close { display: none;  }
#letx-chatbot-toggle.open .icon-chat  { display: none;  }
#letx-chatbot-toggle.open .icon-close { display: block; }

/* ─── Notification Badge ────────────────── */
#letx-chatbot-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 12px;
  height: 12px;
  background: var(--letx-green);
  border-radius: 50%;
  border: 2px solid #fff;
  animation: letx-blink 2.5s infinite;
}

@keyframes letx-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ─── Chat Window ───────────────────────── */
#letx-chatbot-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 99998;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 545px;
  max-height: calc(100vh - 116px);
  background: var(--letx-navy);
  border: 1px solid var(--letx-border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(.4,0,.2,1), opacity 0.25s ease;
}

#letx-chatbot-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ─── Header ────────────────────────────── */
#letx-chatbot-header {
  background: var(--letx-navy-3);
  border-bottom: 1px solid var(--letx-border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* LX Initials Avatar */
.letx-bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--letx-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  border: 1px solid rgba(165, 133, 255, 0.35);
}

.letx-bot-info {
  flex: 1;
  min-width: 0;
}

.letx-bot-name {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--letx-text);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.letx-bot-status {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 11.5px;
  color: var(--letx-text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.letx-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--letx-green);
  flex-shrink: 0;
  animation: letx-blink 2.5s infinite;
}

/* ─── Messages Area ─────────────────────── */
#letx-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#letx-chatbot-messages::-webkit-scrollbar       { width: 3px; }
#letx-chatbot-messages::-webkit-scrollbar-track  { background: transparent; }
#letx-chatbot-messages::-webkit-scrollbar-thumb  { background: rgba(124, 49, 246, 0.3); border-radius: 3px; }

/* ─── Message Row ───────────────────────── */
.letx-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: letx-fadein 0.25s ease both;
}

@keyframes letx-fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.letx-msg.user { flex-direction: row-reverse; }

/* ─── Small Avatars in Chat ─────────────── */
.letx-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.letx-msg.bot  .letx-msg-avatar {
  background: var(--letx-navy-3);
  border: 1px solid var(--letx-border);
  color: var(--letx-blue-light);
}

.letx-msg.user .letx-msg-avatar {
  background: var(--letx-blue);
  border: 1px solid rgba(165, 133, 255, 0.25);
  color: #fff;
}

/* ─── Bubbles ───────────────────────────── */
.letx-msg-bubble {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}

/* Bot bubble — clean dark card */
.letx-msg.bot .letx-msg-bubble {
  background: var(--letx-navy-2);
  border: 1px solid var(--letx-border-soft);
  color: var(--letx-text);
  border-bottom-left-radius: 4px;
}

/* User bubble — solid professional blue */
.letx-msg.user .letx-msg-bubble {
  background: var(--letx-blue);
  border: 1px solid rgba(165, 133, 255, 0.25);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ─── Clickable Links in Chat ───────────── */
.letx-chat-link {
  color: var(--letx-blue-light);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: color 0.15s;
  cursor: pointer;
}

.letx-chat-link:hover {
  color: #93C5FD;
  text-decoration: underline;
}

/* ─── Typing Indicator ──────────────────── */
.letx-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
}

.letx-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--letx-blue-light);
  opacity: 0.5;
  animation: letx-bounce 1.1s infinite ease-in-out;
}

.letx-typing span:nth-child(1) { animation-delay: 0s; }
.letx-typing span:nth-child(2) { animation-delay: 0.16s; }
.letx-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes letx-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* ─── Quick Suggestion Chips ────────────── */
#letx-chatbot-suggestions {
  padding: 4px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.letx-suggestion-chip {
  background: transparent;
  border: 1px solid var(--letx-border);
  color: var(--letx-blue-light);
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  white-space: nowrap;
}

.letx-suggestion-chip:hover {
  background: rgba(124, 49, 246, 0.15);
  border-color: rgba(165, 133, 255, 0.5);
  color: #fff;
}

/* ─── Input Area ────────────────────────── */
#letx-chatbot-input-area {
  padding: 10px 14px;
  border-top: 1px solid var(--letx-border-soft);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--letx-navy-2);
}

#letx-chatbot-input {
  flex: 1;
  background: var(--letx-navy-3);
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 10px;
  padding: 9px 13px;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 13px;
  color: var(--letx-text);
  outline: none;
  resize: none;
  max-height: 90px;
  line-height: 1.5;
  transition: border-color 0.18s;
  scrollbar-width: none;
}

#letx-chatbot-input::placeholder { color: var(--letx-text-muted); }
#letx-chatbot-input:focus         { border-color: rgba(124, 49, 246, 0.5); }

/* ─── Send Button ───────────────────────── */
#letx-chatbot-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--letx-blue);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.15s, opacity 0.18s;
}

#letx-chatbot-send:hover    { background: var(--letx-blue-mid); transform: scale(1.05); }
#letx-chatbot-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

#letx-chatbot-send svg {
  width: 17px;
  height: 17px;
  color: #fff;
}

/* ─── Footer Branding ───────────────────── */
#letx-chatbot-footer {
  padding: 5px 14px 9px;
  text-align: center;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 10.5px;
  color: var(--letx-text-muted);
  border-top: 1px solid rgba(0,0,0,0.04);
  background: var(--letx-navy);
}

#letx-chatbot-footer span {
  color: rgba(165, 133, 255, 0.6);
  font-weight: 600;
}

/* ─── Error Bubble ──────────────────────── */
.letx-msg-error .letx-msg-bubble {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.2);
  color: #FCA5A5;
}

/* ─── Rate Limit / Busy Bubble ──────────── */
.letx-busy-bubble {
  background: rgba(134, 79, 254, 0.08) !important;
  border-color: rgba(124, 49, 246, 0.25) !important;
}

/* ─── Contact Us CTA Button (in bubble) ─── */
.letx-contact-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 16px;
  background: var(--letx-blue);
  color: #fff !important;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter Tight', 'Inter', sans-serif;
  border-radius: 7px;
  text-decoration: none !important;
  transition: background 0.18s, transform 0.15s;
  cursor: pointer;
}

.letx-contact-btn:hover {
  background: var(--letx-blue-mid);
  transform: translateY(-1px);
  text-decoration: none !important;
  color: #fff !important;
}

/* ─── Responsive ────────────────────────── */
@media (max-width: 420px) {
  #letx-chatbot-window {
    right: 10px;
    bottom: 84px;
    width: calc(100vw - 20px);
    height: 470px;
  }
  #letx-chatbot-toggle {
    right: 16px;
    bottom: 18px;
  }
}

/* ─── Theme Toggle Alignment ────────────── */
#theme-toggle {
  bottom: 28px !important;
  left: 28px !important;
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 1px 6px rgba(0,0,0,0.1) !important;
  transition: transform 0.22s ease, box-shadow 0.22s ease, background 0.22s ease !important;
  border: none !important;
  outline: none !important;
}
#theme-toggle::before,
#theme-toggle::after {
  display: none !important;
}
#theme-toggle:hover {
  transform: scale(1.07) !important;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0,0,0,0.15) !important;
}
@media (max-width: 420px) {
  #theme-toggle {
    left: 16px !important;
    bottom: 18px !important;
  }
}
