/* ============================================
   BrixAI Chat Widget — Floating chatbot UI
   Matches landing page design tokens from theme.css
   ============================================ */

:root {
  --chat-bg: #fafaf9;
  --chat-fg: #1a1a2e;
  --chat-accent: #f59e0b;
  --chat-accent-dark: #d97706;
  --chat-muted: #64748b;
  --chat-surface: #ffffff;
  --chat-border: #e5e7eb;
  --chat-font: 'DM Sans', sans-serif;
  --chat-font-display: 'Syne', sans-serif;
}

/* Floating launch button */
.chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--chat-accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(245, 158, 11, 0.45);
}
.chat-launcher svg { width: 28px; height: 28px; fill: white; }

.chat-launcher.open { background: var(--chat-fg); }

/* Chat window */
.chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--chat-surface);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15), 0 0 0 1px var(--chat-border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  animation: chatSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.chat-window.open { display: flex; }

@keyframes chatSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.chat-header {
  padding: 20px 24px;
  background: var(--chat-fg);
  color: white;
  display: flex;
  align-items: center;
  gap: 14px;
}
.chat-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-icon svg { width: 20px; height: 20px; fill: white; }
.chat-header-text { flex: 1; }
.chat-header-name {
  font-family: var(--chat-font-display);
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}
.chat-header-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}
.chat-header-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  transition: background 0.2s;
}
.chat-header-close:hover { background: rgba(255,255,255,0.1); color: white; }

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--chat-bg);
}
.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  animation: msgPop 0.25s ease;
}
@keyframes msgPop {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--chat-surface);
  color: var(--chat-fg);
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-accent);
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-msg-time {
  font-size: 10px;
  color: var(--chat-muted);
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}
.chat-msg:hover .chat-msg-time { opacity: 1; }

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: none;
  gap: 4px;
  align-items: center;
}
.chat-typing.dots { display: flex; }
.chat-typing span {
  width: 7px; height: 7px;
  background: var(--chat-muted);
  border-radius: 50%;
  animation: dotBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Lead capture form */
.chat-form { padding: 16px 20px; border-top: 1px solid var(--chat-border); background: var(--chat-surface); }
.chat-input-row { display: flex; gap: 10px; }
.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid var(--chat-border);
  border-radius: 12px;
  font-family: var(--chat-font);
  font-size: 14px;
  color: var(--chat-fg);
  background: var(--chat-bg);
  outline: none;
  transition: border-color 0.2s;
}
.chat-input:focus { border-color: var(--chat-accent); }
.chat-input::placeholder { color: var(--chat-muted); }
.chat-send {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--chat-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.chat-send:hover { background: var(--chat-accent-dark); }
.chat-send svg { width: 18px; height: 18px; fill: white; }

/* Quick reply chips */
.chat-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.chat-quick-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--chat-accent);
  border-radius: 20px;
  background: transparent;
  color: var(--chat-accent);
  font-family: var(--chat-font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.chat-quick-btn:hover { background: var(--chat-accent); color: white; }

/* Lead form (shown first) */
.chat-lead-form {
  padding: 20px;
  background: var(--chat-surface);
  border-top: 1px solid var(--chat-border);
}
.chat-lead-form h3 {
  font-family: var(--chat-font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--chat-fg);
  margin: 0 0 6px;
}
.chat-lead-form p {
  font-size: 13px;
  color: var(--chat-muted);
  margin: 0 0 16px;
}
.chat-lead-form .form-row { display: flex; flex-direction: column; gap: 10px; }
.chat-lead-form input {
  padding: 10px 14px;
  border: 1.5px solid var(--chat-border);
  border-radius: 10px;
  font-family: var(--chat-font);
  font-size: 14px;
  color: var(--chat-fg);
  background: var(--chat-bg);
  outline: none;
  transition: border-color 0.2s;
}
.chat-lead-form input:focus { border-color: var(--chat-accent); }
.chat-lead-form button {
  width: 100%;
  padding: 12px;
  background: var(--chat-accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: var(--chat-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.chat-lead-form button:hover { background: var(--chat-accent-dark); }

/* Score badge */
.chat-score {
  position: absolute;
  top: 12px;
  right: 60px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.chat-score.qualified { background: #dcfce7; color: #15803d; }
.chat-score.nurture  { background: #fef9c3; color: #a16207; }