/* app/static/css/ai_assistant.css */
/**
 * AI Assistant Styles
 * Floating Action Button and Chat Panel
 */

/* ===== Floating Action Button ===== */
.ai-assistant-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 998;
}

/* When inside fab-container, use static positioning */
.fab-container .ai-assistant-fab {
  position: static;
}

.ai-assistant-fab:hover {
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
  transform: scale(1.05);
}

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

.ai-assistant-fab svg {
  width: 28px;
  height: 28px;
}

/* Pulse animation when AI is "thinking" */
.ai-assistant-fab.thinking {
  animation: fabPulse 1.5s infinite;
}

@keyframes fabPulse {
  0%, 100% {
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  }
  50% {
    box-shadow: 0 4px 25px rgba(102, 126, 234, 0.8);
  }
}

/* Mobile adjustments - when standalone (not in container) */
@media (max-width: 768px) {
  .ai-assistant-fab:not(.fab-container .ai-assistant-fab) {
    bottom: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
  }
  
  .ai-assistant-fab svg {
    width: 24px;
    height: 24px;
  }
}

/* ===== Chat Panel ===== */
.ai-assistant-panel {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

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

/* Mobile: full-screen panel */
@media (max-width: 480px) {
  .ai-assistant-panel {
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}

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

.ai-assistant-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-assistant-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-assistant-avatar svg {
  width: 20px;
  height: 20px;
}

.ai-assistant-title {
  font-weight: 600;
  font-size: 16px;
  margin: 0;
}

.ai-assistant-subtitle {
  font-size: 12px;
  opacity: 0.9;
  margin: 0;
}

.ai-assistant-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

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

/* ===== Messages Container ===== */
.ai-assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
}

/* ===== Message Bubbles ===== */
.ai-message {
  display: flex;
  gap: 8px;
  max-width: 90%;
}

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

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

.ai-message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-message.user .ai-message-avatar {
  background: var(--tcc-primary, #2563eb);
  color: white;
}

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

.ai-message-avatar svg {
  width: 14px;
  height: 14px;
}

.ai-message-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

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

.ai-message.assistant .ai-message-content {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Markdown-like formatting in messages */
.ai-message-content p {
  margin: 0 0 8px 0;
}

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

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

.ai-message-content li {
  margin: 4px 0;
}

.ai-message-content code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

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

/* Typing indicator */
.ai-message.typing .ai-message-content {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* ===== Input Area ===== */
.ai-assistant-input-area {
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  background: white;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-assistant-input {
  flex: 1;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  font-family: inherit;
}

.ai-assistant-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-assistant-input::placeholder {
  color: #9ca3af;
}

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

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

.ai-assistant-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-assistant-send svg {
  width: 18px;
  height: 18px;
}

/* ===== Welcome Message ===== */
.ai-assistant-welcome {
  text-align: center;
  padding: 24px 16px;
  color: #6b7280;
}

.ai-assistant-welcome-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: white;
}

.ai-assistant-welcome-icon svg {
  width: 24px;
  height: 24px;
}

.ai-assistant-welcome h4 {
  margin: 0 0 8px;
  color: #374151;
  font-size: 16px;
}

.ai-assistant-welcome p {
  margin: 0 0 16px;
  font-size: 14px;
}

/* Quick action chips */
.ai-assistant-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.ai-quick-action {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-quick-action:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

/* ===== Error State ===== */
.ai-message.error .ai-message-content {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* ===== Scrollbar ===== */
.ai-assistant-messages::-webkit-scrollbar {
  width: 6px;
}

.ai-assistant-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-assistant-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.ai-assistant-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}
