/* ═══════════════════════════════════════════
   AI CHATBOT — Complete Styling
   Floating Action Button + Chat Window
═══════════════════════════════════════════ */

/* ═══════════════════════════════════════════
   FLOATING ACTION BUTTON (FAB)
═══════════════════════════════════════════ */
.chatbot-fab {
  /* Positioning */
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  
  /* Size */
  width: 60px;
  height: 60px;
  
  /* Appearance */
  border-radius: 999px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  border: 2px solid rgba(37, 99, 235, 0.5);
  box-shadow: 
    0 8px 24px rgba(37, 99, 235, 0.35),
    0 0 0 0 rgba(37, 99, 235, 0.4);
  
  /* Content */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  
  /* Interaction */
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Remove default button styles */
  padding: 0;
  margin: 0;
  outline: none;
}

.chatbot-fab:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 
    0 12px 32px rgba(37, 99, 235, 0.45),
    0 0 0 8px rgba(37, 99, 235, 0.15);
}

.chatbot-fab:active {
  transform: scale(0.95);
}

.chatbot-fab.open {
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 
    0 8px 24px rgba(34, 197, 94, 0.35),
    0 0 0 0 rgba(34, 197, 94, 0.4);
  transform: rotate(90deg);
}

.chatbot-fab svg {
  width: 28px;
  height: 28px;
  stroke-width: 2.5;
}

/* Pulse animation for attention */
@keyframes fabPulse {
  0%, 100% {
    box-shadow: 
      0 8px 24px rgba(37, 99, 235, 0.35),
      0 0 0 0 rgba(37, 99, 235, 0.4);
  }
  50% {
    box-shadow: 
      0 8px 24px rgba(37, 99, 235, 0.35),
      0 0 0 12px rgba(37, 99, 235, 0);
  }
}

.chatbot-fab:not(.open) {
  animation: fabPulse 2s ease-in-out infinite;
}

/* ── Badge (Unread Indicator) ────────────── */
.fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  border: 2px solid var(--bg-base);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  animation: badgeBounce 0.5s ease;
}

.fab-badge.show {
  display: flex;
}

@keyframes badgeBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ═══════════════════════════════════════════
   CHAT WINDOW
═══════════════════════════════════════════ */
.chatbot-window {
  /* Positioning */
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  z-index: 1000;
  
  /* Size */
  width: 400px;
  max-width: calc(100vw - 3rem);
  height: 600px;
  max-height: calc(100vh - 9rem);
  
  /* Appearance */
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  box-shadow: 
    0 24px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(59, 130, 246, 0.12);
  
  /* Layout */
  display: none;
  flex-direction: column;
  overflow: hidden;
  
  /* Animation */
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────── */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(
    135deg,
    rgba(37, 99, 235, 0.08),
    rgba(15, 118, 110, 0.08)
  );
  flex-shrink: 0;
  position: relative;
}

.chatbot-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(37, 99, 235, 0.5),
    transparent
  );
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chatbot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  border: 2px solid rgba(37, 99, 235, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.chatbot-avatar svg {
  width: 20px;
  height: 20px;
}

.chatbot-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.chatbot-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.15rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green-500);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.2);
  }
}

.chatbot-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border-default);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
  padding: 0;
}

.chatbot-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: rotate(90deg);
}

.chatbot-close svg {
  width: 18px;
  height: 18px;
}

/* ── Messages Area ─────────────────────── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  background: 
    linear-gradient(var(--bg-surface) 30%, transparent),
    linear-gradient(transparent, var(--bg-surface) 70%) 0 100%,
    radial-gradient(farthest-side at 50% 0, rgba(99, 120, 170, 0.1), transparent),
    radial-gradient(farthest-side at 50% 100%, rgba(99, 120, 170, 0.1), transparent) 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
  background-attachment: local, local, scroll, scroll;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(99, 120, 170, 0.3);
  border-radius: 999px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 120, 170, 0.5);
}

/* ── Message Bubbles ───────────────────── */
.chat-message {
  display: flex;
  gap: 0.65rem;
  max-width: 85%;
  animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 0.2rem;
}

.chat-message.bot .message-avatar {
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  border: 1px solid rgba(37, 99, 235, 0.5);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.chat-message.user .message-avatar {
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  border: 1px solid rgba(34, 197, 94, 0.5);
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.2);
}

.message-bubble {
  padding: 0.75rem 0.95rem;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
}

.chat-message.bot .message-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-bottom-left-radius: 4px;
}

.chat-message.user .message-bubble {
  background: linear-gradient(
    135deg,
    rgba(37, 99, 235, 0.15),
    rgba(37, 99, 235, 0.08)
  );
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.message-time {
  font-size: 0.68rem;
  color: var(--text-faint);
  margin-top: 0.4rem;
  display: block;
  opacity: 0.7;
}

/* ── Typing Indicator ──────────────────── */
.chatbot-typing {
  padding: 0.6rem 1rem;
  display: none;
  align-items: center;
  gap: 0.7rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(2, 8, 23, 0.5);
  flex-shrink: 0;
}

.chatbot-typing.show {
  display: flex;
}

.typing-indicator {
  display: flex;
  gap: 0.3rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--blue-400);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

.typing-text {
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ── Input Area ────────────────────────── */
.chatbot-input-area {
  padding: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
  background: var(--bg-surface);
}

.chatbot-input {
  flex: 1;
  padding: 0.75rem 0.95rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  background: rgba(2, 8, 23, 0.7);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  resize: none;
  min-height: 44px;
  max-height: 120px;
}

.chatbot-input::placeholder {
  color: var(--text-faint);
}

.chatbot-input:focus {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--blue-600), var(--blue-700));
  border: 1px solid rgba(37, 99, 235, 0.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
  padding: 0;
}

.chatbot-send:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.chatbot-send:active:not(:disabled) {
  transform: translateY(0);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-card);
  border-color: var(--border-default);
}

.chatbot-send svg {
  width: 20px;
  height: 20px;
}

/* ── Quick Replies ─────────────────────── */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  animation: messageSlideIn 0.3s ease;
}

.quick-reply-btn {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.3);
  color: var(--blue-300);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.quick-reply-btn:hover {
  background: rgba(37, 99, 235, 0.2);
  border-color: rgba(37, 99, 235, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.quick-reply-btn:active {
  transform: translateY(0);
}

/* ── Error State ───────────────────────── */
.chat-error {
  padding: 0.8rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--r-md);
  color: #fca5a5;
  font-size: 0.8rem;
  text-align: center;
  margin: 0.5rem 0;
  animation: messageSlideIn 0.3s ease;
}

/* ── Empty State ───────────────────────── */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.chat-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

/* ═══════════════════════════════════════════
   MOBILE RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .chatbot-fab {
    bottom: 1rem;
    right: 1rem;
    width: 56px;
    height: 56px;
  }

  .chatbot-fab svg {
    width: 26px;
    height: 26px;
  }

  .chatbot-window {
    bottom: 5rem;
    right: 1rem;
    left: 1rem;
    width: auto;
    max-width: none;
    height: calc(100vh - 8rem);
  }
}

@media (max-width: 480px) {
  .chatbot-fab {
    bottom: 0.75rem;
    right: 0.75rem;
    width: 52px;
    height: 52px;
  }

  .chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    border-radius: 0;
    height: 100vh;
    max-height: 100vh;
    width: 100vw;
  }

  .chatbot-header {
    padding: 0.9rem 1rem;
  }

  .chatbot-messages {
    padding: 0.75rem;
  }

  .chatbot-input-area {
    padding: 0.75rem;
  }

  .chat-message {
    max-width: 90%;
  }
}

/* ═══════════════════════════════════════════
   ACCESSIBILITY
═══════════════════════════════════════════ */
.chatbot-fab:focus-visible,
.chatbot-close:focus-visible,
.chatbot-send:focus-visible,
.quick-reply-btn:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .chatbot-fab,
  .chatbot-window,
  .chat-message,
  .quick-reply-btn {
    animation: none;
    transition: none;
  }
  
  .status-dot,
  .typing-indicator span {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .chatbot-fab {
    border-width: 3px;
  }
  
  .chatbot-window {
    border-width: 2px;
  }
  
  .message-bubble {
    border-width: 2px;
  }
}

/* ═══════════════════════════════════════════
   SUPPORT HUB SPECIFIC STYLES
═══════════════════════════════════════════ */

/* ── Welcome Section ───────────────────── */
.support-welcome {
  padding: 1.5rem 1.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.support-welcome h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.support-welcome p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Support Options ───────────────────── */
.support-options {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.support-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  color: inherit;
}

.support-option:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.15);
}

.support-option:active {
  transform: translateX(2px);
}

.support-option-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.support-option-icon svg {
  width: 24px;
  height: 24px;
  color: var(--blue-400);
}

.support-option-icon-live {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.2);
}

.support-option-icon-live svg {
  color: var(--green-400);
}

.live-indicator {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--text-faint);
  border: 2px solid var(--bg-card);
}

.support-option.live-available .live-indicator {
  background: var(--green-500);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  animation: statusPulse 2s ease-in-out infinite;
}

.support-option-content {
  flex: 1;
  min-width: 0;
}

.support-option-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.support-option-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.15rem;
}

.support-option-meta {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.support-option-arrow {
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform var(--t-fast);
}

.support-option:hover .support-option-arrow {
  transform: translateX(4px);
  color: var(--blue-400);
}

/* ── Footer Info ───────────────────────── */
.support-footer-info {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(2, 8, 23, 0.5);
}

.support-info-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.support-info-item svg {
  flex-shrink: 0;
  color: var(--blue-400);
}

.support-info-item strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Mobile Adjustments ────────────────── */
@media (max-width: 480px) {
  .support-welcome {
    padding: 1.2rem 1rem 0.8rem;
  }

  .support-welcome h3 {
    font-size: 1rem;
  }

  .support-options {
    padding: 0.75rem;
  }

  .support-option {
    padding: 0.9rem 1rem;
  }

  .support-option-icon {
    width: 44px;
    height: 44px;
  }

  .support-option-icon svg {
    width: 22px;
    height: 22px;
  }

  .support-footer-info {
    padding: 0.75rem 1rem;
  }
}
