/** ============================================
   AI Assistant Widget Styles
   Floating button + Chat drawer
   Theme-aware, mobile-first
   ============================================ */

/* Floating Action Button */
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-primary, linear-gradient(135deg, #2563EB 0%, #7C3AED 100%));
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0,0,0,0.3));
  z-index: 500;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-fab:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0,0,0,0.4));
}

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

/* Drawer */
.ai-drawer {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100dvh - 120px);
  background: var(--color-bg-card, #18181B);
  border: 1px solid var(--color-border, #3F3F46);
  border-radius: var(--radius-2xl, 1.5rem) var(--radius-2xl, 1.5rem) 0 var(--radius-2xl, 1.5rem);
  display: flex;
  flex-direction: column;
  z-index: 501;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: var(--shadow-2xl, 0 25px 50px -12px rgba(0,0,0,0.5));
}

.ai-drawer.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.ai-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4, 1rem) var(--space-4, 1rem) var(--space-2, 0.5rem);
  border-bottom: 1px solid var(--color-border, #3F3F46);
}

.ai-drawer-header h3 {
  font-size: var(--text-lg, 1.125rem);
  font-weight: 600;
  color: var(--color-text, #FAFAFA);
  margin: 0;
}

.ai-close {
  background: none;
  border: none;
  color: var(--color-text-muted, #71717A);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md, 0.5rem);
  transition: background 0.2s ease;
}

.ai-close:hover {
  background: var(--color-bg-secondary, #0A0A0A);
  color: var(--color-text, #FAFAFA);
}

/* Messages Area */
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4, 1rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 0.75rem);
  scroll-behavior: smooth;
}

/* Message Bubbles */
.ai-message {
  display: flex;
  max-width: 85%;
}

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

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

.ai-message-content {
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  border-radius: var(--radius-xl, 1rem);
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.ai-message-user .ai-message-content {
  background: var(--color-primary, #2563EB);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-message-bot .ai-message-content {
  background: var(--color-bg-secondary, #0A0A0A);
  color: var(--color-text, #FAFAFA);
  border: 1px solid var(--color-border, #3F3F46);
  border-bottom-left-radius: 4px;
}

/* Typing Indicator */
.ai-typing-indicator {
  display: flex;
  gap: 4px;
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
}

.ai-typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--color-text-muted, #71717A);
  border-radius: 50%;
  animation: ai-typing-bounce 1.4s infinite ease-in-out both;
}

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

@keyframes ai-typing-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Suggested Chips */
.ai-suggested-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 0.5rem);
  padding: 0 var(--space-4, 1rem) var(--space-3, 0.75rem);
}

.ai-suggested-chip {
  background: var(--color-bg-secondary, #0A0A0A);
  border: 1px solid var(--color-border, #3F3F46);
  color: var(--color-text-secondary, #A1A1AA);
  padding: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  border-radius: var(--radius-full, 9999px);
  font-size: var(--text-xs, 0.75rem);
  cursor: pointer;
  transition: all 0.2s ease;
}

.ai-suggested-chip:hover {
  border-color: var(--color-primary, #2563EB);
  color: var(--color-primary, #2563EB);
}

/* Input Area */
.ai-input-area {
  display: flex;
  gap: var(--space-2, 0.5rem);
  padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
  border-top: 1px solid var(--color-border, #3F3F46);
}

.ai-input {
  flex: 1;
  padding: var(--space-2, 0.5rem) var(--space-3, 0.75rem);
  background: var(--color-bg-secondary, #0A0A0A);
  border: 1px solid var(--color-border, #3F3F46);
  border-radius: var(--radius-lg, 0.75rem);
  color: var(--color-text, #FAFAFA);
  font-size: var(--text-sm, 0.875rem);
  font-family: inherit;
}

.ai-input:focus {
  outline: none;
  border-color: var(--color-primary, #2563EB);
}

.ai-send {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg, 0.75rem);
  background: var(--color-primary, #2563EB);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.ai-send:hover {
  background: var(--color-primary-dark, #1D4ED8);
}

/* Mobile: Full screen */
@media (max-width: 640px) {
  .ai-drawer {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    border: none;
  }

  .ai-fab {
    bottom: 16px;
    right: 16px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ai-fab,
  .ai-drawer,
  .ai-close,
  .ai-suggested-chip,
  .ai-send {
    transition: none;
  }

  .ai-typing-indicator span {
    animation: none;
    transform: scale(1);
  }
}

/* Light theme adjustments */
[data-theme="light"] .ai-message-bot .ai-message-content {
  background: var(--color-bg-secondary, #F1F5F9);
  border-color: var(--color-border, #E2E8F0);
}

[data-theme="light"] .ai-suggested-chip {
  background: var(--color-bg-secondary, #F1F5F9);
  border-color: var(--color-border, #E2E8F0);
}
