/* ==========================================================================
   UserCrowd - Live AI Chat Widget Stylesheet
   Styled after Instant Loan America Live Chat & AI Assistant
   ========================================================================== */

/* ---------------- Floating Launcher Button ---------------- */
.ai-chat-launcher {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 1500;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #10b981 100%);
  color: var(--white);
  box-shadow: 0 8px 24px rgba(5, 150, 105, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}

.ai-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 30px rgba(5, 150, 105, 0.5);
}

.ai-chat-launcher svg {
  width: 28px;
  height: 28px;
  transition: transform 0.25s ease;
}

.ai-chat-launcher.active svg.icon-chat {
  display: none;
}

.ai-chat-launcher svg.icon-close {
  display: none;
}

.ai-chat-launcher.active svg.icon-close {
  display: block;
}

/* Pulsating Green Online Dot */
.launcher-status-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  background-color: #22c55e;
  border: 2.5px solid var(--white);
  border-radius: 50%;
}

.launcher-status-dot::after {
  content: '';
  position: absolute;
  top: -2.5px;
  left: -2.5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background-color: #22c55e;
  opacity: 0.6;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ---------------- Chat Window Modal / Card ---------------- */
.ai-chat-widget {
  position: fixed;
  bottom: 100px;
  right: 25px;
  z-index: 1500;
  width: 380px;
  max-width: calc(100vw - 30px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--slate-200);
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}

.ai-chat-widget.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: var(--white);
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-agent-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.agent-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
}

.agent-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #10b981 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.agent-status-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background-color: #22c55e;
  border: 2px solid #0f172a;
}

.agent-details h4 {
  font-size: 0.925rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1.2;
}

.agent-details p {
  font-size: 0.725rem;
  color: #34d399;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.chat-header-actions button {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.chat-header-actions button:hover {
  color: var(--white);
  background-color: rgba(255, 255, 255, 0.1);
}

/* Chat Messages Container */
.chat-body {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background-color: #f8fafc;
}

.chat-timestamp-badge {
  align-self: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--slate-400);
  background: var(--slate-200);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.4rem;
}

/* Chat Bubbles */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msgSlideIn 0.25s ease-out;
}

@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg.msg-incoming {
  align-self: flex-start;
}

.chat-msg.msg-outgoing {
  align-self: flex-end;
}

.msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.45;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  word-break: break-word;
}

.msg-incoming .msg-bubble {
  background: var(--white);
  color: var(--slate-800);
  border: 1px solid var(--slate-200);
  border-bottom-left-radius: 4px;
}

.msg-outgoing .msg-bubble {
  background: linear-gradient(135deg, var(--primary) 0%, #10b981 100%);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.msg-time {
  font-size: 0.65rem;
  color: var(--slate-400);
  margin-top: 0.25rem;
  padding: 0 0.35rem;
}

.msg-incoming .msg-time {
  text-align: left;
}

.msg-outgoing .msg-time {
  text-align: right;
}

/* Quick Suggestion Chips */
.chat-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.chip-btn {
  background: var(--white);
  border: 1px solid #a7f3d0;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.chip-btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
}

/* Animated Typing Indicator */
.typing-indicator {
  display: none;
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 0.65rem 0.9rem;
  gap: 0.3rem;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.typing-indicator.active {
  display: flex;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--slate-400);
  border-radius: 50%;
  animation: typingBounce 1.3s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Chat Footer & Input Box */
.chat-footer {
  background: var(--white);
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--slate-200);
}

.chat-input-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--slate-50);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-lg);
  padding: 0.35rem 0.65rem;
  transition: var(--transition);
}

.chat-input-form:focus-within {
  background: var(--white);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.chat-input-field {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.45rem;
  font-size: 0.875rem;
  color: var(--slate-800);
}

.chat-send-btn {
  background: var(--primary);
  color: var(--white);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.chat-send-btn:hover {
  background-color: var(--primary-hover);
  transform: scale(1.05);
}

.chat-footnote {
  text-align: center;
  font-size: 0.685rem;
  color: var(--slate-400);
  margin-top: 0.45rem;
}

/* Mobile Adaptation */
@media (max-width: 480px) {
  .ai-chat-widget {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }
}
