/**
 * AI Assistant Styles - Modern Design System
 * Enhanced with animations, responsive design, and accessibility features
 */

/* AI Assistant Container */
.ai-assistant {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  font-family: 'Inter', sans-serif;
}

/* Toggle Button */
.ai-assistant-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 12px 16px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  font-weight: 500;
}

.ai-assistant-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.ai-assistant-toggle.active {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  box-shadow: 0 4px 20px rgba(245, 87, 108, 0.3);
}

.ai-icon {
  font-size: 20px;
  animation: pulse 2s infinite;
}

.ai-label {
  font-size: 14px;
  font-weight: 600;
}

/* AI Panel */
.ai-assistant-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 400px;
  max-height: 600px;
  background: var(--background-primary, #ffffff);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color, #e5e7eb);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.ai-assistant-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* AI Header */
.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 16px 16px 0 0;
}

.ai-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.ai-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background-color 0.2s;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* AI Tabs */
.ai-tabs {
  display: flex;
  background: var(--background-secondary, #f9fafb);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.ai-tab {
  flex: 1;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary, #6b7280);
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.ai-tab:hover {
  color: var(--text-primary, #111827);
  background: var(--background-tertiary, #f3f4f6);
}

.ai-tab.active {
  color: var(--primary-color, #667eea);
  border-bottom-color: var(--primary-color, #667eea);
  background: var(--background-primary, #ffffff);
}

/* AI Content */
.ai-content {
  height: 500px;
  display: flex;
  flex-direction: column;
}

.ai-tab-content {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

.ai-tab-content.active {
  display: flex;
}

/* Chat Tab */
.ai-conversation {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-message {
  display: flex;
  gap: 12px;
  animation: slideIn 0.3s ease-out;
}

.ai-user-message {
  flex-direction: row-reverse;
}

.ai-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--background-secondary, #f3f4f6);
}

.ai-assistant-message .ai-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.ai-user-message .ai-avatar {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.ai-message-content {
  flex: 1;
  max-width: 280px;
}

.ai-message-text {
  background: var(--background-secondary, #f3f4f6);
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary, #111827);
}

.ai-user-message .ai-message-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.ai-message-text p {
  margin: 0 0 8px 0;
}

.ai-message-text p:last-child {
  margin-bottom: 0;
}

.ai-message-text ul {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-message-text li {
  margin-bottom: 4px;
}

.ai-message-text code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}

.ai-user-message .ai-message-text code {
  background: rgba(255, 255, 255, 0.2);
}

.ai-message-time {
  font-size: 11px;
  color: var(--text-tertiary, #9ca3af);
  margin-top: 4px;
  text-align: right;
}

.ai-user-message .ai-message-time {
  text-align: left;
}

/* Typing Indicator */
.ai-typing .ai-message-text {
  background: var(--background-secondary, #f3f4f6);
  padding: 16px;
}

.ai-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ai-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary, #9ca3af);
  animation: typing 1.4s infinite ease-in-out;
}

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

/* Input Container */
.ai-input-container {
  padding: 16px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#ai-message-input {
  flex: 1;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  background: var(--background-primary, #ffffff);
  color: var(--text-primary, #111827);
}

#ai-message-input:focus {
  border-color: var(--primary-color, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-send-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Code Analysis Tab */
.ai-code-analysis {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.ai-code-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-code-input label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #111827);
}

#ai-code-language {
  padding: 8px 12px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  background: var(--background-primary, #ffffff);
  color: var(--text-primary, #111827);
  outline: none;
}

#ai-code-input {
  flex: 1;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  resize: vertical;
  min-height: 200px;
  outline: none;
  background: var(--background-primary, #ffffff);
  color: var(--text-primary, #111827);
}

#ai-code-input:focus {
  border-color: var(--primary-color, #667eea);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-analyze-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ai-analyze-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.ai-analysis-result {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 16px;
  background: var(--background-secondary, #f9fafb);
}

.ai-analysis-content h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary, #111827);
  font-size: 16px;
  font-weight: 600;
}

.ai-analysis-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary, #111827);
}

/* Recommendations Tab */
.ai-recommendations {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.ai-recommendations-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
  padding: 16px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ai-recommendations-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.ai-recommendations-result {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  padding: 16px;
  background: var(--background-secondary, #f9fafb);
}

.ai-recommendations-content h4 {
  margin: 0 0 12px 0;
  color: var(--text-primary, #111827);
  font-size: 16px;
  font-weight: 600;
}

.ai-recommendations-text {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary, #111827);
}

/* Loading States */
.ai-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-secondary, #6b7280);
  font-size: 14px;
  gap: 8px;
}

.ai-error {
  color: var(--error-color, #ef4444);
  font-size: 14px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Animations */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

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

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  .ai-assistant {
    bottom: 10px;
    right: 10px;
  }
  
  .ai-assistant-panel {
    width: calc(100vw - 20px);
    right: -10px;
    bottom: 60px;
    max-height: 70vh;
  }
  
  .ai-assistant-toggle {
    padding: 10px 12px;
  }
  
  .ai-label {
    display: none;
  }
  
  .ai-message-content {
    max-width: 200px;
  }
}

/* Dark Mode Support */
[data-theme="dark"] .ai-assistant-panel {
  background: var(--background-primary, #1f2937);
  border-color: var(--border-color, #374151);
}

[data-theme="dark"] .ai-message-text {
  background: var(--background-secondary, #374151);
  color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] #ai-message-input,
[data-theme="dark"] #ai-code-input,
[data-theme="dark"] #ai-code-language {
  background: var(--background-primary, #1f2937);
  color: var(--text-primary, #f9fafb);
  border-color: var(--border-color, #374151);
}

[data-theme="dark"] .ai-analysis-result,
[data-theme="dark"] .ai-recommendations-result {
  background: var(--background-secondary, #374151);
  border-color: var(--border-color, #4b5563);
}

[data-theme="dark"] .ai-tab {
  background: var(--background-secondary, #374151);
  color: var(--text-secondary, #d1d5db);
}

[data-theme="dark"] .ai-tab:hover {
  background: var(--background-tertiary, #4b5563);
  color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .ai-tab.active {
  background: var(--background-primary, #1f2937);
  color: var(--primary-color, #667eea);
}

/* Accessibility */
.ai-assistant-toggle:focus,
.ai-close:focus,
.ai-tab:focus,
.ai-send-btn:focus,
.ai-analyze-btn:focus,
.ai-recommendations-btn:focus {
  outline: 2px solid var(--primary-color, #667eea);
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .ai-assistant-toggle {
    border: 2px solid currentColor;
  }
  
  .ai-assistant-panel {
    border: 2px solid var(--border-color, #000000);
  }
  
  .ai-tab.active {
    border-bottom-width: 3px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .ai-assistant-toggle,
  .ai-assistant-panel,
  .ai-message,
  .ai-send-btn,
  .ai-analyze-btn,
  .ai-recommendations-btn {
    transition: none;
  }
  
  .ai-icon {
    animation: none;
  }
  
  .ai-typing-dots span {
    animation: none;
  }
} 