/* ==========================================================================
   AI Customer Support Widget Styles (Dedicated Module)
   ========================================================================== */
.ai-customer-container {
  position: relative;
  z-index: 10000;
}

/* Floating Bubble Container & Button */
.ai-support-bubble-container {
  position: fixed;
  bottom: 100px; /* Shifted up from 50px */
  right: 140px;  /* Shifted left from 80px */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 10000;
}

.ai-support-bubble-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary-color) 0%, #4338ca 100%);
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 118, 254, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  padding: 0;
  animation: supportBubbleFloat 6s ease-in-out infinite;
}

.ai-support-bubble-btn:hover {
  transform: translateY(-5px) scale(1.08);
  box-shadow: 0 12px 35px rgba(0, 118, 254, 0.45);
}

.ai-support-bubble-btn:active {
  transform: scale(0.95);
}

.bubble-icon-wrapper svg {
  transition: transform 0.3s ease;
}

.ai-support-bubble-btn:hover .bubble-icon-wrapper svg {
  transform: rotate(10deg);
}

/* Sparkle Halo breathing animation */
.bubble-sparkle-halo {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary-color);
  opacity: 0;
  pointer-events: none;
  animation: sparkleHaloPulse 2.5s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

/* Tooltip pop */
.bubble-tooltip-pop {
  position: absolute;
  right: 70px;
  top: 28px;
  transform: translateY(-50%);
  background: var(--bg-dark);
  color: #ffffff !important;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 10001;
}

.ai-support-bubble-container:hover .bubble-tooltip-pop {
  opacity: 1;
  transform: translateY(-50%) translateX(-5px);
}

.ai-support-bubble-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: #ffffff !important; /* Force white text */
  background: var(--primary-color) !important; /* Blue in light theme, Orange in dark theme */
  padding: 3px 10px;
  border-radius: 20px;
  user-select: none;
  text-align: center;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px var(--primary-glow);
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 4px;
}

html[data-theme="dark"] .ai-support-bubble-label {
  background: var(--primary-color) !important; /* Orange in dark theme */
  box-shadow: 0 2px 8px rgba(255, 122, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Chat Dialog Window */
.ai-support-chat-window {
  position: fixed;
  bottom: 175px; /* Shifted up from 125px */
  right: 140px;  /* Shifted left from 80px */
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 220px);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.95);
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10000;
}

.ai-support-chat-window.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

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

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

.agent-avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.online-status-pulse {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  background-color: #22c55e;
  border: 1.5px solid var(--primary-color);
  border-radius: 50%;
  animation: onlinePulse 2s infinite;
}

.chat-agent-name {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
}

.chat-agent-status {
  font-size: 0.68rem;
  opacity: 0.85;
  margin-top: 2px;
}

.chat-close-btn {
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 1.75rem;
  cursor: pointer;
  opacity: 0.8;
  padding: 0;
  line-height: 1;
  transition: opacity 0.2s;
}

.chat-close-btn:hover {
  opacity: 1;
}

/* Messages Body */
.chat-messages-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(248, 250, 252, 0.5);
}

/* Individual Message Bubble */
.chat-message {
  display: flex;
  max-width: 85%;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
}

.message-bubble {
  padding: 10px 14px;
  font-size: 0.825rem;
  line-height: 1.5;
  word-wrap: break-word;
  word-break: break-all;
  white-space: pre-wrap;
}

.chat-message.user .message-bubble {
  background-color: var(--primary-color);
  color: #ffffff;
  border-radius: 14px 14px 2px 14px;
  box-shadow: 0 3px 10px rgba(0, 118, 254, 0.15);
}

.chat-message.assistant .message-bubble {
  background-color: var(--bg-white);
  color: var(--text-main);
  border-radius: 14px 14px 14px 2px;
  border: 1px solid var(--border-color);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.02);
}

/* Quick tags section */
.chat-quick-tags {
  padding: 8px 12px;
  background-color: var(--bg-white);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-tag-chip {
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 20px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quick-tag-chip:hover {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: transparent;
  transform: translateY(-1px);
}

/* Bottom Input Bar */
.chat-input-bar {
  padding: 10px 16px;
  background-color: var(--bg-white);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input-bar textarea {
  flex-grow: 1;
  border: none;
  resize: none;
  background: transparent;
  outline: none;
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.4;
  padding: 6px 0;
  max-height: 60px;
  font-family: inherit;
}

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

.chat-send-action-btn:hover {
  background-color: var(--primary-hover);
  transform: scale(1.05);
}

.chat-send-action-btn:active {
  transform: scale(0.95);
}

/* Typing / Loading Dots Animation */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 6px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

/* Animations Keyframes */
@keyframes supportBubbleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes sparkleHaloPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes onlinePulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

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

/* Dark Mode Overrides for AI Customer Support */
html[data-theme="dark"] .ai-support-bubble-btn {
  background: linear-gradient(135deg, var(--primary-color) 0%, #ea580c 100%);
  box-shadow: 0 8px 30px rgba(255, 122, 0, 0.25);
}

html[data-theme="dark"] .bubble-sparkle-halo {
  border-color: var(--primary-color);
}

html[data-theme="dark"] .ai-support-chat-window {
  background: rgba(28, 25, 23, 0.85); /* Stone-900 Warm Charcoal */
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .chat-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #ea580c 100%);
}

html[data-theme="dark"] .chat-messages-body {
  background: rgba(20, 18, 16, 0.5);
}

html[data-theme="dark"] .chat-message.assistant .message-bubble {
  background-color: #1c1917; /* Stone-900 */
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .chat-quick-tags {
  background-color: #1c1917;
  border-top-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .quick-tag-chip {
  background-color: #292524; /* Stone-800 */
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .quick-tag-chip:hover {
  background-color: var(--primary-color);
}

html[data-theme="dark"] .chat-input-bar {
  background-color: #1c1917;
  border-top-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .chat-send-action-btn {
  background-color: var(--primary-color);
}

html[data-theme="dark"] .chat-send-action-btn:hover {
  background-color: var(--primary-hover);
}

/* Mobile Responsiveness for chat box */
@media (max-width: 500px) {
  .ai-support-chat-window {
    width: auto;
    left: 16px;
    right: 16px;
    bottom: 88px;
    height: 480px;
    max-height: calc(100vh - 100px);
  }
  .ai-support-bubble-btn {
    bottom: 16px;
    right: 16px;
  }
}

/* Custom styles for system messages and admin replies in landing widget */
.chat-message.system {
  align-self: center;
  max-width: 90%;
  margin: 6px 0;
}

.chat-message.system .message-bubble {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 0.75rem;
  padding: 4px 10px;
  text-align: center;
  box-shadow: none;
}

html[data-theme="dark"] .chat-message.system .message-bubble {
  background-color: rgba(255, 255, 255, 0.05);
}

.chat-message.admin {
  align-self: flex-start;
}

.chat-message.admin .message-bubble {
  background-color: rgba(13, 148, 136, 0.08); /* light teal tint */
  color: var(--text-main);
  border-radius: 14px 14px 14px 2px;
  border: 1px solid rgba(13, 148, 136, 0.25);
  box-shadow: 0 3px 10px rgba(13, 148, 136, 0.03);
}

html[data-theme="dark"] .chat-message.admin .message-bubble {
  background-color: rgba(255, 122, 0, 0.08); /* light orange tint */
  border-color: rgba(255, 122, 0, 0.25);
}

.chat-message-sender-name {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent-color);
  margin-bottom: 4px;
}

html[data-theme="dark"] .chat-message-sender-name {
  color: var(--primary-color);
}

