/* ============================================================
   KLYSSEL LABS — KLYX CHATBOT THEME
   Brand Theme: Primary Violet #6A54FB, Dark Obsidian #0F0C1E,
   Montserrat Typography, Clean High-Contrast Cards
   ============================================================ */
:root {
  --kb-primary: #5852F2;        /* Klyssel primary violet */
  --kb-primary-light: #6A54FB;  /* vibrant violet */
  --kb-accent: #7B77F2;         /* violet accent */
  --kb-accent-dark: #5138F2;    /* deep primary */
  --kb-text-light: #FFFFFF;
  --kb-text-dark: #18181B;      /* high contrast dark */
  --kb-user-bubble: #5852F2;    /* primary bubble */
  --kb-bot-bubble: #F4F3FF;     /* crisp lavender light bubble */
  --kb-bg: #FFFFFF;
  --kb-border-radius: 24px;
  --kb-font: 'Montserrat', sans-serif;
}

/* ---------- Floating Launcher: Free-Standing Robotic Assistant (Outside / No Circle) ---------- */
#kb-launcher {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  width: auto !important;
  height: auto !important;
  min-width: 76px !important;
  min-height: 88px !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer !important;
  z-index: 999999 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-end !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  overflow: visible !important;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
  -webkit-tap-highlight-color: transparent;
}

#kb-launcher:hover { 
  transform: translateY(-4px) scale(1.05) !important; 
}

#kb-launcher:active {
  transform: translateY(0) scale(0.97) !important;
}

/* Robot Icon wrapper */
#kb-launcher .kb-launcher-robot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

#kb-launcher .kb-launcher-robot img,
#kb-launcher .kb-launcher-robot svg { 
  width: 76px !important; 
  height: 88px !important; 
  object-fit: contain; 
  pointer-events: none;
  filter: drop-shadow(0 10px 18px rgba(88, 82, 242, 0.32)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
  transition: filter 0.3s ease;
}

#kb-launcher:hover .kb-launcher-robot img {
  filter: drop-shadow(0 14px 26px rgba(88, 82, 242, 0.5)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
}

/* Interactive Floating Speech / Greeting Pill (Positioned cleanly to the left of Klyx) */
#kb-launcher .kb-robot-speech-pill {
  position: absolute;
  top: 14px;
  right: calc(100% + 10px);
  transform: translateX(6px) scale(0.92);
  background: #FFFFFF;
  color: #5852F2;
  font-family: var(--kb-font);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1.5px solid rgba(88, 82, 242, 0.28);
  box-shadow: 0 6px 20px rgba(88, 82, 242, 0.2), 0 2px 6px rgba(0, 0, 0, 0.05);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
  z-index: 10;
}

/* Cute speech bubble tail pointing towards Klyx */
#kb-launcher .kb-robot-speech-pill::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -5px;
  transform: translateY(-50%) rotate(45deg);
  width: 9px;
  height: 9px;
  background: #FFFFFF;
  border-top: 1.5px solid rgba(88, 82, 242, 0.28);
  border-right: 1.5px solid rgba(88, 82, 242, 0.28);
  border-radius: 1px;
}

/* Active visible state when speech pill is shown */
#kb-launcher .kb-robot-speech-pill.kb-visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

#kb-launcher:hover .kb-robot-speech-pill.kb-visible {
  transform: translateX(-3px) scale(1.02);
  border-color: #5852F2;
  box-shadow: 0 8px 24px rgba(88, 82, 242, 0.3);
}

#kb-launcher:hover .kb-robot-speech-pill::after {
  border-color: #5852F2;
}

/* Close (X) Floating Pill Button */
#kb-launcher .kb-launcher-close {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5852F2 0%, #5138F2 100%);
  border: 2px solid #FFFFFF;
  box-shadow: 0 10px 28px rgba(88, 82, 242, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  color: #FFFFFF;
  pointer-events: none;
}

#kb-launcher .kb-launcher-close svg {
  width: 24px;
  height: 24px;
  stroke: #FFFFFF;
  stroke-width: 2.5;
}

/* Active / Open state: Hide free robot & speech pill, show crisp Floating Close X Button */
#kb-launcher.kb-active,
#kb-launcher.is-open {
  min-width: 54px !important;
  min-height: 54px !important;
}

#kb-launcher.kb-active .kb-launcher-robot,
#kb-launcher.is-open .kb-launcher-robot {
  opacity: 0;
  transform: translateY(12px) scale(0.5);
  pointer-events: none;
}

#kb-launcher.kb-active .kb-launcher-close,
#kb-launcher.is-open .kb-launcher-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
  pointer-events: auto;
}

#kb-launcher .kb-badge {
  display: none !important; /* No blinking badge */
}

/* ---------- Chat Window ---------- */
#kb-window {
  position: fixed !important;
  bottom: 104px !important;
  right: 24px !important;
  width: 380px !important;
  max-width: calc(100vw - 32px) !important;
  height: 560px !important;
  max-height: calc(100vh - 120px) !important;
  background: var(--kb-bg);
  border-radius: var(--kb-border-radius);
  border: 1.5px solid rgba(88, 82, 242, 0.22);
  box-shadow: 0 20px 60px rgba(15, 12, 30, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.8);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999 !important;
  font-family: var(--kb-font);
  animation: kb-slide-up 0.25s ease;
}
#kb-window.kb-open { display: flex; }

@keyframes kb-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
#kb-header {
  background: linear-gradient(135deg, var(--kb-primary), var(--kb-primary-light));
  color: var(--kb-text-light);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#kb-header .kb-title { display: flex; align-items: center; gap: 10px; }
#kb-header .kb-title img {
  width: 30px; height: 30px; border-radius: 8px; object-fit: contain;
}
#kb-header .kb-title-text { 
  font-size: 16px; 
  font-weight: 700; 
  line-height: 1; 
  letter-spacing: -0.01em; 
  color: #FFFFFF;
}
#kb-close {
  background: rgba(255, 255, 255, 0.1); border: none; color: var(--kb-text-light); font-size: 18px; cursor: pointer; border-radius: 50%; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; transition: background 0.15s ease;
}
#kb-close:hover { background: rgba(255, 255, 255, 0.2); }

/* Body / messages */
#kb-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #FAFAFC;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#kb-body::-webkit-scrollbar { width: 5px; }
#kb-body::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 4px; }

.kb-msg { display: flex; max-width: 88%; animation: kb-fade-in 0.2s ease; }
@keyframes kb-fade-in { from { opacity: 0; } to { opacity: 1; } }
.kb-msg.kb-bot { align-self: flex-start; }
.kb-msg.kb-user { align-self: flex-end; }

.kb-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  white-space: pre-line;
}
.kb-msg.kb-bot .kb-bubble {
  background: var(--kb-bot-bubble);
  color: var(--kb-text-dark);
  border: 1px solid rgba(106, 84, 251, 0.15);
  border-bottom-left-radius: 4px;
}
.kb-msg.kb-user .kb-bubble {
  background: var(--kb-user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(106, 84, 251, 0.25);
}

/* Quick reply buttons */
.kb-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  width: 100%;
}
.kb-option-btn {
  background: #fff;
  border: 1.5px solid rgba(106, 84, 251, 0.25);
  color: var(--kb-text-dark);
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--kb-font);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.kb-option-btn:hover {
  background: var(--kb-accent-dark);
  border-color: var(--kb-accent-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(106, 84, 251, 0.25);
}

/* Lead Capture Form */
.kb-form-card {
  background: #fff;
  border: 1.5px solid rgba(106, 84, 251, 0.2);
  border-radius: 14px;
  padding: 14px;
  width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  font-family: var(--kb-font);
}
.kb-form-card h4 {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--kb-text-dark);
}
.kb-form-card p {
  margin: 0 0 10px;
  font-size: 11.5px;
  color: #52525B;
  line-height: 1.4;
}
.kb-form-group {
  margin-bottom: 8px;
}
.kb-form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #3F3F46;
  margin-bottom: 3px;
}
.kb-form-group label span { color: #EF4444; }
.kb-input, .kb-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: var(--kb-font);
  border: 1px solid #D4D4D8;
  border-radius: 8px;
  background: #FAFAFC;
  color: var(--kb-text-dark);
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.kb-input:focus, .kb-select:focus {
  outline: none;
  border-color: var(--kb-accent-dark);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(106, 84, 251, 0.12);
}
.kb-error-text {
  font-size: 10.5px;
  color: #EF4444;
  margin-top: 2px;
  display: none;
}
.kb-submit-btn {
  width: 100%;
  background: var(--kb-accent-dark);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--kb-font);
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 4px 12px rgba(106, 84, 251, 0.25);
}
.kb-submit-btn:hover {
  background: #5841E8;
  transform: translateY(-1px);
}
.kb-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Typing Indicator */
.kb-typing {
  align-self: flex-start;
  padding: 8px 12px;
  background: var(--kb-bot-bubble);
  border-radius: 12px;
  border: 1px solid rgba(106, 84, 251, 0.15);
  display: inline-flex;
  gap: 4px;
}
.kb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--kb-accent-dark);
  animation: kb-bounce 1s infinite;
}
.kb-typing span:nth-child(2) { animation-delay: 0.2s; }
.kb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes kb-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* Footer */
#kb-footer {
  padding: 8px;
  text-align: center;
  font-size: 10.5px;
  color: #71717A;
  background: #fff;
  border-top: 1px solid #E4E4E7;
  font-weight: 500;
}

/* Interactive Chat Input Bar */
#kb-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #FFFFFF;
  border-top: 1px solid rgba(106, 84, 251, 0.15);
}
#kb-user-input {
  flex: 1;
  background: #F4F3FF;
  border: 1px solid rgba(106, 84, 251, 0.2);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--kb-font);
  color: var(--kb-text-dark);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#kb-user-input:focus {
  background: #FFFFFF;
  border-color: var(--kb-accent-dark);
  box-shadow: 0 0 0 2px rgba(106, 84, 251, 0.12);
}
#kb-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--kb-accent-dark);
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}
#kb-send-btn:hover {
  background: #5841E8;
  transform: scale(1.05);
}

/* Chat Prompt Step Form */
.kb-prompt-form {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
}
.kb-prompt-input {
  flex: 1;
  background: #FFFFFF;
  border: 1.5px solid rgba(106, 84, 251, 0.3);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--kb-font);
  color: var(--kb-text-dark);
  outline: none;
}
.kb-prompt-input:focus {
  border-color: var(--kb-accent-dark);
  box-shadow: 0 0 0 2px rgba(106, 84, 251, 0.12);
}
.kb-prompt-btn {
  background: var(--kb-accent-dark);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--kb-font);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.kb-prompt-btn:hover {
  background: #5841E8;
  transform: translateY(-1px);
}
.kb-prompt-error {
  color: #EF4444;
  font-size: 11px;
  margin-top: 4px;
  font-weight: 500;
}
