/* ============================================
   AI AGENT PANEL STYLES
   ============================================ */

/* Agent Sidebar Container */
.ai-agent-sidebar {
  flex: 0 0 320px;
  min-width: 320px;
  max-width: 320px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  position: relative;
}

/* Collapsed state - moves to bottom left */
.ai-agent-sidebar.collapsed {
  position: fixed !important;
  bottom: 20px;
  left: 120px;
  width: auto !important;
  min-width: 200px !important;
  max-width: 280px;
  flex: none;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  border-right: none;
  overflow: visible;
}

/* Agent Panel */
.ai-agent-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: white;
}

/* Collapsed panel styling */
.ai-agent-sidebar.collapsed .ai-agent-panel {
  height: auto;
  border-radius: 12px;
  overflow: hidden;
}

/* Panel Header */
.agent-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Collapsed header styling */
.ai-agent-sidebar.collapsed .agent-panel-header {
  border-bottom: none;
  border-radius: 12px;
  padding: 12px 16px;
}

.ai-agent-sidebar.collapsed .agent-panel-header:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4);
}

.agent-header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.agent-icon {
  font-size: 24px;
  line-height: 1;
}

.agent-header-text h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 2px 0;
  color: white;
}

.agent-status {
  font-size: 11px;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.agent-toggle-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 12px;
  flex-shrink: 0;
}

.agent-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Hide toggle button when collapsed (entire header becomes clickable) */
.ai-agent-sidebar.collapsed .agent-toggle-btn {
  display: none;
}

/* Panel Body */
.agent-panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  transition: all 0.3s ease;
}

/* Hide body when collapsed */
.ai-agent-sidebar.collapsed .agent-panel-body {
  display: none;
}

/* Messages Container */
.agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: #f9fafb;
  min-height: 0;
}

/* Custom scrollbar for messages */
.agent-messages::-webkit-scrollbar {
  width: 6px;
}

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

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

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

/* Message */
.agent-message {
  margin-bottom: 14px;
  animation: fadeIn 0.3s ease;
}

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

.message-content {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 100%;
  word-wrap: break-word;
}

.user-message .message-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  margin-left: 16px;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.assistant-message .message-content {
  background: white;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  margin-right: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-content p {
  margin: 0 0 6px 0;
}

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

.message-content ul {
  margin: 6px 0;
  padding-left: 18px;
}

.message-content li {
  margin-bottom: 3px;
  font-size: 12px;
}

.message-content code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

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

.message-content strong {
  font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
  opacity: 0.7;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #667eea;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

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

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

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

/* Suggestions */
.agent-suggestions {
  padding: 10px 14px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.suggestions-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.suggestion-chip {
  background: white;
  border: 1px solid #d1d5db;
  color: #374151;
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Input Area */
.agent-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e5e7eb;
  background: white;
  flex-shrink: 0;
}

.agent-input-field {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  color: #1f2937;
  resize: none;
  font-family: inherit;
  transition: all 0.2s;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  min-height: 100px;
}

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

.agent-input-field::placeholder {
  color: #9ca3af;
  font-size: 13px;
}

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

.agent-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.agent-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.agent-send-btn svg {
  width: 18px;
  height: 18px;
}

/* Mobile Toggle Button - Only visible on mobile */
.agent-mobile-toggle {
  display: none;
  position: fixed;
  left: 16px;
  bottom: 80px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  z-index: 101;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.agent-mobile-toggle:active {
  transform: scale(0.95);
}

/* Mobile Backdrop */
.agent-mobile-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.agent-mobile-backdrop.active {
  opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .ai-agent-sidebar {
    flex: 0 0 280px;
    min-width: 280px;
    max-width: 280px;
  }
  
  .agent-messages {
    padding: 14px 12px;
  }
  
  .user-message .message-content {
    margin-left: 12px;
  }
  
  .assistant-message .message-content {
    margin-right: 12px;
  }
}

@media (max-width: 768px) {
  /* Show mobile toggle button */
  .agent-mobile-toggle {
    display: flex !important;
  }
  
  /* Show backdrop when panel is open */
  .ai-agent-sidebar.mobile-open ~ .agent-mobile-backdrop {
    display: block;
  }
  
  /* Agent sidebar becomes a slide-in panel */
  .ai-agent-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 85vw;
    max-width: 320px;
    min-width: 280px;
    flex: none;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }
  
  .ai-agent-sidebar.mobile-open {
    transform: translateX(0);
  }
  
  /* Adjust panel styling for mobile */
  .agent-panel-header {
    padding: 14px 16px;
  }
  
  .agent-header-text h3 {
    font-size: 14px;
  }
  
  .agent-status {
    font-size: 11px;
  }
  
  .agent-messages {
    padding: 12px 10px;
  }
  
  .message-content {
    font-size: 13px;
    padding: 9px 11px;
  }
  
  .user-message .message-content {
    margin-left: 8px;
  }
  
  .assistant-message .message-content {
    margin-right: 8px;
  }
  
  .agent-input-area {
    padding: 12px;
  }
  
  .agent-input-field {
    font-size: 14px;
    padding: 12px;
    min-height: 48px;
  }
  
  .agent-send-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }
  
  .agent-send-btn svg {
    width: 20px;
    height: 20px;
  }
  
  .suggestion-chip {
    font-size: 12px;
    padding: 6px 12px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .ai-agent-sidebar {
    width: 90vw;
    max-width: 100%;
  }
  
  .agent-messages {
    padding: 10px 8px;
  }
  
  .message-content {
    font-size: 12px;
  }
}
