/* ==========================================================================
   Yugvex Tech Solutions - Advanced Next-Gen AI Chatbot Widget Stylesheet
   ========================================================================== */

/* --- Floating Chat Trigger Button --- */
.ai-chat-trigger {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  box-shadow: 0 8px 32px rgba(6, 182, 212, 0.45);
  z-index: 99999;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.ai-chat-trigger:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 12px 40px rgba(6, 182, 212, 0.6);
}

.ai-chat-trigger .trigger-pulse-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #10B981;
  border: 2.5px solid var(--bg-dark);
}

.ai-chat-trigger .trigger-pulse-dot::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 50%;
  background: #10B981;
  opacity: 0.8;
  animation: pulseDot 2s infinite;
}

.ai-chat-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #EF4444;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-dark);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
  animation: bounceBadge 2s infinite ease-in-out;
}

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

/* --- Proactive Teaser Speech Bubble --- */
.ai-chat-teaser {
  position: fixed;
  bottom: 6.25rem;
  right: 2rem;
  max-width: 290px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-active);
  border-radius: 18px;
  padding: 1rem 1.15rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  z-index: 99998;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: teaserSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  cursor: pointer;
}

.ai-chat-teaser::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 24px;
  width: 14px;
  height: 14px;
  background: rgba(15, 23, 42, 0.95);
  border-right: 1px solid var(--border-active);
  border-bottom: 1px solid var(--border-active);
  transform: rotate(45deg);
}

.teaser-close-btn {
  background: transparent;
  color: var(--text-subtle);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  margin-left: auto;
  transition: color 0.2s;
}

.teaser-close-btn:hover {
  color: var(--text-main);
}

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

/* --- Main Chat Modal Window --- */
.ai-chat-window {
  position: fixed;
  bottom: 6.25rem;
  right: 2rem;
  width: 390px;
  max-width: calc(100vw - 2.5rem);
  height: 570px;
  max-height: calc(100vh - 8rem);
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  z-index: 100000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px) scale(0.95);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-window.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(99, 102, 241, 0.15));
  border-bottom: 1px solid var(--border-light);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(12px);
}

.chat-brand-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-avatar-wrap {
  position: relative;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-glow);
}

.chat-avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #10B981;
  border: 2px solid var(--bg-surface);
}

.chat-title-box h4 {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 0.1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chat-status-sub {
  font-size: 0.78rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 500;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-header-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition-fast);
}

.chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}

/* Chat Body & Scroll Area */
.chat-body {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  background-image: radial-gradient(circle at 50% 0%, rgba(6, 182, 212, 0.04) 0%, transparent 60%);
}

/* Message Bubble Styling */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  max-width: 86%;
  animation: msgPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.chat-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  flex-shrink: 0;
}

.chat-msg-bubble {
  padding: 0.85rem 1.1rem;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
}

.chat-msg.bot .chat-msg-bubble {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.chat-msg.user .chat-msg-bubble {
  background: var(--gradient-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.chat-msg-time {
  font-size: 0.7rem;
  color: var(--text-subtle);
  margin-top: 0.35rem;
  display: block;
}

.chat-msg.user .chat-msg-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.8);
}

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

/* Quick Suggestion Chips */
.chat-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chat-chip {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chat-chip:hover {
  background: var(--gradient-primary);
  color: #ffffff;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

/* Typing Indicator Animation */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

/* Chat Input Footer Area */
.chat-footer {
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-light);
}

.chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.5rem 0.35rem 1rem;
  transition: var(--transition-fast);
}

.chat-input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.25);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
}

.chat-input::placeholder {
  color: var(--text-subtle);
}

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-glow);
}

.chat-send-btn:hover {
  transform: scale(1.08);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-footer-note {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-subtle);
  margin-top: 0.4rem;
}

/* --- Comprehensive Mobile & Tablet Responsiveness --- */
@media (max-width: 768px) {
  .ai-chat-trigger {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    bottom: max(1.25rem, env(safe-area-inset-bottom, 1.25rem)) !important;
    right: max(1.25rem, env(safe-area-inset-right, 1.25rem)) !important;
    width: 58px !important;
    height: 58px !important;
    font-size: 1.6rem !important;
    z-index: 999999 !important;
    box-shadow: 0 10px 35px rgba(6, 182, 212, 0.6) !important;
  }

  body.ai-chat-open .ai-chat-trigger {
    display: none !important;
  }

  .ai-chat-teaser {
    bottom: max(5.5rem, calc(env(safe-area-inset-bottom, 1.25rem) + 4.5rem));
    right: max(1rem, env(safe-area-inset-right, 1rem));
    left: max(1rem, env(safe-area-inset-left, 1rem));
    max-width: calc(100vw - 2rem);
    z-index: 999998;
  }

  .ai-chat-window {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    z-index: 1000000 !important;
  }

  .chat-header {
    padding: 0.85rem 1rem;
  }

  .chat-body {
    padding: 1rem;
  }

  .chat-footer {
    padding: 0.75rem 0.85rem;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem));
  }

  .chat-input {
    font-size: 16px !important; /* Prevents auto-zoom on mobile WebKit */
  }
}

@media (max-width: 480px) {
  .ai-chat-trigger {
    width: 54px !important;
    height: 54px !important;
    font-size: 1.5rem !important;
    bottom: max(1rem, env(safe-area-inset-bottom, 1rem)) !important;
    right: max(1rem, env(safe-area-inset-right, 1rem)) !important;
  }

  .ai-chat-teaser {
    bottom: max(5rem, calc(env(safe-area-inset-bottom, 1rem) + 4rem));
    right: max(0.75rem, env(safe-area-inset-right, 0.75rem));
    left: max(0.75rem, env(safe-area-inset-left, 0.75rem));
  }
}
