/* ═══════════════════════════════════════════════════════════
   ai-chat.css — M1 Stack AI Live Chat Widget
   Universal Glassmorphic & Modern AI Assistant Design
   ═══════════════════════════════════════════════════════════ */

/* ─── Floating Action Button (FAB) & Teaser ─── */
.ai-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-chat-teaser {
  background: #ffffff;
  border: 1px solid #dbeafe;
  border-radius: 30px;
  padding: 8px 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  animation: teaserBounce 4s ease-in-out infinite;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.ai-chat-teaser:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 30px rgba(29, 78, 216, 0.18);
  border-color: #93c5fd;
}

.ai-ct-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  animation: statusPulse 2s ease-in-out infinite;
}

.ai-ct-txt {
  font-family: 'Sora', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #1e3a8a;
}

@keyframes teaserBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.ai-chat-trigger {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 55%, #0284c7 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(29, 78, 216, 0.45);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  animation: aiPulseRing 2.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes aiPulseRing {
  0%, 100% {
    box-shadow: 0 6px 24px rgba(29, 78, 216, 0.45), 0 0 0 0 rgba(29, 78, 216, 0.3);
  }
  50% {
    box-shadow: 0 6px 24px rgba(29, 78, 216, 0.45), 0 0 0 14px rgba(29, 78, 216, 0);
  }
}

.ai-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(29, 78, 216, 0.55);
}

.ai-chat-trigger:active {
  transform: scale(0.95);
}

.ai-chat-trigger svg,
.ai-chat-trigger i {
  width: 26px;
  height: 26px;
  color: #ffffff;
  transition: transform 0.25s ease;
}

.ai-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #ffffff;
  font-family: 'Sora', sans-serif;
  animation: badgePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes badgePop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ─── Chat Window ─── */
.ai-chat-win {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 99999;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 600px;
  height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.2), 0 4px 16px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(219, 234, 254, 0.9);
  overflow: hidden;
  transform: scale(0.88) translateY(24px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  display: flex;
  flex-direction: column;
}

.ai-chat-win.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ─── Header ─── */
.ai-cw-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #0284c7 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ai-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.ai-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-avatar svg,
.ai-avatar i {
  width: 20px;
  height: 20px;
  color: #ffffff;
}

.ai-status-dot {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #1e3a8a;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.18);
  }
}

.ai-cw-info {
  flex: 1;
  min-width: 0;
}

.ai-cw-name {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.ai-cw-status {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-cw-sdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
}

.ai-cw-product-pill {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  color: #ffffff;
  font-family: 'Sora', sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ai-cw-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ai-cw-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(90deg);
}

.ai-cw-close svg,
.ai-cw-close i {
  width: 15px;
  height: 15px;
  color: #ffffff;
}

/* ─── Product Banner ─── */
.ai-product-banner {
  background: linear-gradient(135deg, #f0f7ff 0%, #e0f2fe 100%);
  border-bottom: 1px solid #dbeafe;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.ai-product-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ai-product-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ai-product-name {
  font-family: 'Sora', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: #1d4ed8;
}

.ai-product-tagline {
  font-size: 10.5px;
  color: #64748b;
  margin-top: 1px;
  line-height: 1.35;
}

/* ─── Messages Area ─── */
.ai-cw-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  min-height: 160px;
  scroll-behavior: smooth;
}

.ai-cw-msgs::-webkit-scrollbar {
  width: 4px;
}

.ai-cw-msgs::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.ai-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 90%;
  animation: msgSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes msgSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 85%;
}

.ai-msg-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 800;
  font-family: 'Sora', sans-serif;
}

.ai-msg.bot .ai-msg-av {
  background: linear-gradient(135deg, #1d4ed8, #0284c7);
  color: #ffffff;
}

.ai-msg.user .ai-msg-av {
  background: linear-gradient(135deg, #64748b, #334155);
  color: #ffffff;
}

.ai-msg-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.55;
  font-family: 'DM Sans', sans-serif;
}

.ai-msg.bot .ai-msg-bubble {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #1d4ed8, #0284c7);
  color: #ffffff;
  border-radius: 18px 4px 18px 18px;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.25);
}

.ai-msg.bot .ai-msg-bubble a {
  color: #1d4ed8;
  font-weight: 600;
  text-decoration: underline;
}

.ai-msg.bot .ai-msg-bubble a:hover {
  color: #2563eb;
}

.ai-msg-time {
  font-size: 9.5px;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}

/* ─── Rich Product / Service Info Card ─── */
.ai-product-info-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 100%);
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  padding: 14px 16px;
  margin-top: 4px;
  font-size: 12.5px;
  color: #0f172a;
  line-height: 1.6;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.06);
}

.ai-pi-stat-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ai-pi-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 7px 12px;
  min-width: 60px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.ai-pi-stat-n {
  font-family: 'Sora', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: #1d4ed8;
  line-height: 1.1;
}

.ai-pi-stat-l {
  font-size: 9.5px;
  color: #64748b;
  margin-top: 2px;
  text-align: center;
  font-weight: 500;
}

.ai-pi-features {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ai-pi-feat-tag {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 10.5px;
  font-weight: 600;
  font-family: 'Sora', sans-serif;
  border-radius: 20px;
  padding: 3px 9px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ─── Typing Indicator ─── */
.ai-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  animation: msgSlideIn 0.3s ease both;
}

.ai-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px 18px 18px 18px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.ai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
  animation: typingBounce 1.3s ease-in-out infinite;
}

.ai-typing-dots span:nth-child(2) {
  animation-delay: 0.18s;
}
.ai-typing-dots span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ─── Quick Suggestion Chips ─── */
.ai-quick-chips {
  padding: 8px 14px 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
  flex-shrink: 0;
  max-height: 80px;
  overflow-y: auto;
}

.ai-chip {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: 'Sora', sans-serif;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.ai-chip:hover {
  background: #1d4ed8;
  color: #ffffff;
  border-color: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25);
}

/* ─── Input Bar ─── */
.ai-input-row {
  padding: 10px 14px 12px;
  display: flex;
  gap: 8px;
  border-top: 1px solid #f1f5f9;
  background: #ffffff;
  flex-shrink: 0;
}

.ai-inp {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.ai-inp:focus {
  border-color: #3b82f6;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.ai-inp::placeholder {
  color: #94a3b8;
}

.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #0284c7);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.35);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  flex-shrink: 0;
  align-self: center;
}

.ai-send-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 20px rgba(29, 78, 216, 0.45);
}

.ai-send-btn:active {
  transform: scale(0.94);
}

.ai-send-btn svg,
.ai-send-btn i {
  width: 16px;
  height: 16px;
  color: #ffffff;
}

/* ─── Footer ─── */
.ai-powered-by {
  padding: 6px 14px 8px;
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  font-family: 'DM Sans', sans-serif;
}

.ai-powered-by strong {
  color: #1d4ed8;
  font-weight: 700;
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .ai-chat-win {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 84px;
    height: calc(100vh - 100px);
    border-radius: 20px;
  }
  .ai-chat-fab {
    right: 16px;
    bottom: 16px;
  }
  .ai-chat-teaser {
    display: none; /* Hide teaser on narrow mobile to keep UI clean */
  }
  .ai-chat-trigger {
    width: 52px;
    height: 52px;
  }
}
