/* ── Chat Widget — Emma AI Assistant ─────────────────────────────── */
.chat-widget {
  --chat-green: #047857;
  --chat-green-deep: #065f46;
  --chat-green-glow: rgba(4, 120, 87, 0.12);
  --chat-ink: #0c1220;
  --chat-charcoal: #1a2335;
  --chat-warm: #faf8f5;
  --chat-mist: #8b95a7;
  --chat-cloud: #e2e8f0;
  font-family: var(--font-sans, 'Geist', system-ui, sans-serif);
}

/* ── Trigger FAB ─────────────────────────────────────────────────── */
.chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--chat-green);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 88;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(4, 120, 87, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: chatPulse 2s infinite;
}
.chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(4, 120, 87, 0.45);
}
.chat-trigger-close { display: none; }
.chat-widget.is-open .chat-trigger-icon { display: none; }
.chat-widget.is-open .chat-trigger-close { display: block; }
.chat-widget.is-open .chat-trigger { animation: none; }

@keyframes chatPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(4, 120, 87, 0.35); }
  50% { box-shadow: 0 4px 24px rgba(4, 120, 87, 0.55), 0 0 0 8px var(--chat-green-glow); }
}

/* ── Nudge tooltip ───────────────────────────────────────────────── */
.chat-nudge {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: #fff;
  color: var(--chat-ink);
  padding: 10px 36px 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  z-index: 88;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 260px;
}
.chat-nudge.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.chat-nudge-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--chat-mist);
  line-height: 1;
}

/* ── Chat Panel ──────────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  z-index: 89;
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(8px);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.chat-widget.is-open .chat-panel {
  display: flex;
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ── Header ──────────────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--chat-charcoal);
  color: #fff;
}
.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.chat-header-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.chat-header-status {
  font-size: 0.75rem;
  color: var(--chat-mist);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  display: inline-block;
}
.chat-header-actions {
  display: flex;
  gap: 6px;
}
.chat-header-actions button {
  background: none;
  border: none;
  color: var(--chat-mist);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.chat-header-actions button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ── Messages ────────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--chat-warm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
  max-height: 380px;
}
.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
  animation: chatMsgIn 0.15s ease;
}
.chat-bubble-user {
  align-self: flex-end;
  background: var(--chat-green);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.chat-bubble-assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--chat-ink);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Typing indicator ────────────────────────────────────────────── */
.chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 10px 14px;
  align-self: flex-start;
  background: #fff;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.chat-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chat-mist);
  animation: chatBounce 0.6s infinite alternate;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-5px); }
}

/* ── Input area ──────────────────────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--chat-cloud);
  background: #fff;
}
.chat-input-area textarea {
  flex: 1;
  border: 1px solid var(--chat-cloud);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.15s;
}
.chat-input-area textarea:focus {
  border-color: var(--chat-green);
}
#chatSend {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--chat-green);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
#chatSend:disabled {
  opacity: 0.4;
  cursor: default;
}
#chatSend:not(:disabled):hover {
  transform: scale(1.08);
}

/* ── Lead capture card (inline) ──────────────────────────────────── */
.chat-lead-card {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--chat-cloud);
  border-radius: 14px;
  padding: 14px;
  max-width: 90%;
  animation: chatMsgIn 0.15s ease;
}
.chat-lead-card h4 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--chat-ink);
}
.chat-lead-card input {
  display: block;
  width: 100%;
  padding: 7px 10px;
  margin-bottom: 6px;
  border: 1px solid var(--chat-cloud);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.chat-lead-card input:focus {
  border-color: var(--chat-green);
}
.chat-lead-card .chat-lead-error {
  color: #dc2626;
  font-size: 0.75rem;
  margin-bottom: 4px;
  display: none;
}
.chat-lead-card button {
  width: 100%;
  padding: 8px;
  background: var(--chat-green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}
.chat-lead-card button:hover {
  background: var(--chat-green-deep);
}
.chat-lead-card button:disabled {
  opacity: 0.5;
  cursor: default;
}
.chat-lead-success {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--chat-green);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Toast ────────────────────────────────────────────────────────── */
.chat-toast {
  position: fixed;
  bottom: 160px;
  right: 24px;
  z-index: 90;
  pointer-events: none;
}
.chat-toast-msg {
  background: var(--chat-charcoal);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  animation: chatMsgIn 0.2s ease;
}

/* ── Mobile ≤640px ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .chat-panel {
    inset: 0;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }
  .chat-messages {
    max-height: none;
    min-height: 0;
    flex: 1;
  }
  .chat-trigger {
    bottom: 80px;
  }
  .chat-widget.is-open .chat-trigger {
    display: none;
  }
  .chat-nudge {
    bottom: 146px;
    right: 16px;
  }
  .chat-toast {
    bottom: auto;
    top: 80px;
    right: 16px;
    left: 16px;
  }
}
