/* ── Lead Qual Chat Widget ─────────────────────────────────────────── */
:root {
  --lq-bg: #0f1117;
  --lq-surface: #1a1d27;
  --lq-surface2: #22263a;
  --lq-border: #2e3347;
  --lq-accent: #6366f1;
  --lq-accent-hover: #4f52d9;
  --lq-text: #e8eaf0;
  --lq-muted: #8b90a8;
  --lq-user-bubble: #6366f1;
  --lq-bot-bubble: #22263a;
  --lq-radius: 16px;
  --lq-shadow: 0 8px 32px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
}

/* ── Launcher Bubble ───────────────────────────────────────────────── */
#lq-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--lq-accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(99,102,241,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#lq-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(99,102,241,0.65);
}
#lq-launcher svg { pointer-events: none; }

/* Notification dot */
#lq-launcher::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--lq-bg);
  display: none;
}
#lq-launcher.has-notification::after { display: block; }

/* ── Chat Window ───────────────────────────────────────────────────── */
#lq-widget {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--lq-bg);
  border: 1px solid var(--lq-border);
  border-radius: var(--lq-radius);
  box-shadow: var(--lq-shadow);
  display: none;
  flex-direction: column;
  z-index: 99999;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}
#lq-widget.lq-open {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

/* ── Header ────────────────────────────────────────────────────────── */
#lq-header {
  background: var(--lq-surface);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--lq-border);
  flex-shrink: 0;
}
#lq-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lq-accent), #818cf8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
#lq-header-text { flex: 1; min-width: 0; }
#lq-header-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--lq-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#lq-header-status {
  font-size: 11px;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}
#lq-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
}
#lq-close {
  background: none;
  border: none;
  color: var(--lq-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
#lq-close:hover { color: var(--lq-text); background: var(--lq-surface2); }

/* ── Messages ──────────────────────────────────────────────────────── */
#lq-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#lq-messages::-webkit-scrollbar { width: 4px; }
#lq-messages::-webkit-scrollbar-track { background: transparent; }
#lq-messages::-webkit-scrollbar-thumb { background: var(--lq-border); border-radius: 4px; }

.lq-msg {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}
.lq-msg.lq-bot { align-self: flex-start; }
.lq-msg.lq-user { align-self: flex-end; }

.lq-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.lq-bot .lq-bubble {
  background: var(--lq-bot-bubble);
  color: var(--lq-text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--lq-border);
}
.lq-user .lq-bubble {
  background: var(--lq-user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Links inside bubbles */
.lq-bubble a {
  color: #93c5fd;
  text-decoration: underline;
  word-break: break-all;
}
.lq-user .lq-bubble a { color: #e0e7ff; }

/* ── Typing Indicator ──────────────────────────────────────────────── */
#lq-typing {
  align-self: flex-start;
  display: none;
}
#lq-typing.lq-visible { display: flex; }
.lq-typing-bubble {
  background: var(--lq-bot-bubble);
  border: 1px solid var(--lq-border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.lq-dot {
  width: 7px;
  height: 7px;
  background: var(--lq-muted);
  border-radius: 50%;
  animation: lqBounce 1.2s infinite;
}
.lq-dot:nth-child(2) { animation-delay: 0.15s; }
.lq-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes lqBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Area ────────────────────────────────────────────────────── */
#lq-input-area {
  padding: 12px;
  border-top: 1px solid var(--lq-border);
  background: var(--lq-surface);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  position: relative;
  z-index: 100000;
}
#lq-input {
  flex: 1;
  background: var(--lq-surface2);
  border: 1px solid var(--lq-border);
  border-radius: 22px;
  padding: 10px 16px;
  color: var(--lq-text);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color 0.15s;
  cursor: text;
  position: relative;
  z-index: 100001;
}
#lq-input::placeholder { color: var(--lq-muted); }
#lq-input:focus { border-color: var(--lq-accent); }
#lq-input, #lq-input:focus { cursor: text !important; }
#lq-send { cursor: pointer !important; }
#lq-close { cursor: pointer !important; }
#lq-launcher { cursor: pointer !important; }

#lq-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lq-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#lq-send:hover { background: var(--lq-accent-hover); }
#lq-send:active { transform: scale(0.94); }
#lq-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Footer ────────────────────────────────────────────────────────── */
#lq-footer {
  text-align: center;
  font-size: 10px;
  color: var(--lq-muted);
  padding: 6px 0 10px;
  background: var(--lq-surface);
  border-top: 1px solid var(--lq-border);
  flex-shrink: 0;
}

/* ── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #lq-widget {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  #lq-launcher {
    bottom: 16px;
    right: 16px;
  }
}
