/**
 * QueryTel AI Assistant - Enterprise Chatbot Styling
 * Lightweight, zero-dependency, ultra-responsive UI
 */

:root {
  --qt-chat-primary: #2563eb;
  --qt-chat-primary-hover: #1d4ed8;
  --qt-chat-dark: #0f172a;
  --qt-chat-surface: #ffffff;
  --qt-chat-bg-soft: #f8fafc;
  --qt-chat-border: #e2e8f0;
  --qt-chat-text: #1e293b;
  --qt-chat-text-muted: #64748b;
  --qt-chat-success: #10b981;
}

/* Floating Launcher Button */
#qt-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4), 0 8px 10px -6px rgba(37, 99, 235, 0.2);
  cursor: pointer;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

#qt-chat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 28px -5px rgba(37, 99, 235, 0.5);
}

#qt-chat-launcher:active {
  transform: translateY(0) scale(0.98);
}

.qt-launcher-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.qt-launcher-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--qt-chat-success);
  box-shadow: 0 0 0 2px #ffffff;
  animation: qtPulse 2s infinite;
}

@keyframes qtPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Chat Window Container */
#qt-chat-window {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--qt-chat-surface);
  border: 1px solid var(--qt-chat-border);
  border-radius: 20px;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999995;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#qt-chat-window.qt-active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat Header */
.qt-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.qt-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qt-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.qt-chat-avatar img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.qt-chat-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.qt-chat-subtitle {
  font-size: 11px;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.qt-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--qt-chat-success);
}

.qt-chat-header-actions button {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.qt-chat-header-actions button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* Messages Body */
.qt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--qt-chat-bg-soft);
  scroll-behavior: smooth;
}

/* Message Bubble */
.qt-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
}

.qt-msg-bot {
  align-self: flex-start;
}

.qt-msg-user {
  align-self: flex-end;
}

.qt-bubble {
  padding: 10px 14px;
  border-radius: 16px;
}

.qt-msg-bot .qt-bubble {
  background: #ffffff;
  color: var(--qt-chat-text);
  border: 1px solid var(--qt-chat-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.qt-msg-user .qt-bubble {
  background: var(--qt-chat-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.qt-msg a {
  color: #2563eb;
  font-weight: 600;
  text-decoration: underline;
}

.qt-msg-user a {
  color: #ffffff;
}

.qt-time {
  font-size: 10px;
  color: var(--qt-chat-text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

.qt-msg-user .qt-time {
  text-align: right;
}

/* Prompt Quick Chips */
.qt-chips-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.qt-chip {
  background: #ffffff;
  border: 1px solid var(--qt-chat-border);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.qt-chip:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
  transform: translateY(-1px);
}

/* Interactive Lead Handoff Card */
.qt-lead-card {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  padding: 14px;
  margin-top: 6px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  font-size: 12.5px;
}

.qt-lead-card-title {
  font-weight: 700;
  color: #1e3a8a;
  font-size: 13px;
  margin-bottom: 2px;
}

.qt-lead-card-sub {
  color: #64748b;
  font-size: 11.5px;
  margin-bottom: 10px;
}

.qt-form-group {
  margin-bottom: 8px;
}

.qt-form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 3px;
}

.qt-input, .qt-select, .qt-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.qt-input:focus, .qt-select:focus, .qt-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.qt-textarea {
  resize: none;
  height: 52px;
}

.qt-btn-submit {
  width: 100%;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  padding: 8px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.qt-btn-submit:hover {
  background: #1e40af;
}

.qt-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Typing Indicator Animation */
.qt-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--qt-chat-border);
  border-radius: 16px;
  width: fit-content;
  border-bottom-left-radius: 4px;
}

.qt-typing-dot {
  width: 6px;
  height: 6px;
  background-color: #94a3b8;
  border-radius: 50%;
  animation: qtTyping 1.4s infinite ease-in-out both;
}

.qt-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.qt-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes qtTyping {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Chat Input Footer */
.qt-chat-footer {
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1px solid var(--qt-chat-border);
}

.qt-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qt-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.qt-chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.qt-send-btn {
  background: var(--qt-chat-primary);
  color: #ffffff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  shrink: 0;
}

.qt-send-btn:hover {
  background: var(--qt-chat-primary-hover);
  transform: translateY(-1px);
}

.qt-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

.qt-chat-disclaimer {
  font-size: 10.5px;
  color: #94a3b8;
  text-align: center;
  margin-top: 6px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  #qt-chat-launcher {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    font-size: 13px;
  }
  #qt-chat-window {
    bottom: 74px;
    right: 12px;
    left: 12px;
    width: auto;
    height: 520px;
  }
}

