/* Chat Agent Floating Action Button */
.chat-agent-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-agent-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Chat Agent Container */
.chat-agent-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 400px;
  max-width: 90vw;
  height: 600px;
  max-height: 80vh;
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-agent-container.expanded {
  width: 600px;
  max-width: 85vw;
}

.chat-agent-container.floating {
  position: fixed;
  bottom: auto;
  right: auto;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.chat-agent-container.floating .chat-agent-header.draggable {
  cursor: move;
}

.chat-agent-container.minimized {
  height: 48px;
}

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

.chat-agent-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.chat-mode-indicator {
  font-size: 16px;
  opacity: 0.8;
}

.chat-icon {
  font-size: 20px;
}

.chat-agent-controls {
  display: flex;
  gap: 8px;
}

.chat-control-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-control-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Agent Selection */
.chat-agent-agents {
  padding: 12px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), rgba(248, 249, 250, 0.8));
  border-bottom: 1px solid rgba(224, 224, 224, 0.6);
  backdrop-filter: blur(5px);
}

.agents-selection-header {
  display: flex;
  flex-direction: column;
}

.agents-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s;
}

.agents-header-row:hover {
  opacity: 0.8;
}

.expand-chevron {
  display: inline-block;
  margin-right: 4px;
  font-size: 10px;
  transition: transform 0.2s;
}

.agents-count {
  font-size: 12px;
  color: #666;
  background: #e0e0e0;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.agents-label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.agents-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e5e5e5;
  animation: slideDown 0.2s ease-out;
}

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

.agent-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
}

.agent-checkbox input[type="checkbox"] {
  cursor: pointer;
}

.agent-checkbox span {
  cursor: pointer;
  user-select: none;
}

.agent-checkbox:hover span:not([style]) {
  color: #667eea;
}

.agent-checkbox:hover span[style] {
  opacity: 0.85;
  transform: scale(1.02);
  transition: all 0.2s ease;
}

.agent-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  font-size: 13px;
}

.agent-name.project {
  font-weight: 500;
}

.agent-name.global {
  font-weight: 500;
}

.agent-name.openai-agent {
  background: linear-gradient(135deg, #10a37f20, #10a37f10);
  color: #10a37f;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #10a37f40;
  font-weight: 500;
}

.agents-loading {
  font-size: 11px;
  color: #999;
  font-style: italic;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.no-agents-message {
  font-size: 12px;
  color: #999;
  font-style: italic;
  padding: 4px 8px;
}

/* Messages Area */
.chat-agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(5px);
}

.chat-welcome {
  color: #666;
  font-size: 14px;
  line-height: 1.6;
}

.chat-welcome ul {
  margin: 12px 0;
  padding-left: 0;
  list-style: none;
}

.chat-welcome li {
  margin: 4px 0;
}

.chat-context-info {
  margin-top: 12px;
  padding: 8px 12px;
  background: #f0f4ff;
  border-radius: 6px;
  font-size: 13px;
}

/* Chat Messages */
.chat-message {
  margin-bottom: 16px;
  animation: messageSlideIn 0.3s ease;
}

.chat-message.system {
  margin: 8px 0;
}

.system-message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #f0f4ff;
  border-left: 3px solid #667eea;
  border-radius: 4px;
  font-size: 12px;
  color: #555;
}

.system-icon {
  font-size: 14px;
}

.system-text {
  flex: 1;
  font-style: italic;
}

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

.chat-message.user {
  text-align: right;
}

.chat-message.user .message-content {
  background: #667eea;
  color: white;
  margin-left: auto;
}

.chat-message.assistant .message-content {
  background: #f1f3f5;
  color: #333;
}

.message-header {
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-message.user .message-header {
  justify-content: flex-end;
}

.message-role {
  font-weight: 600;
}

.message-agents {
  font-size: 11px;
  color: #999;
}

.message-content {
  display: inline-block;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

/* Markdown content styling within messages */
.message-content .w-md-editor-text-area,
.message-content .w-md-editor-text {
  background: transparent !important;
  color: inherit !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  padding: 0 !important;
  border: none !important;
}

.message-content .w-md-editor-text * {
  color: inherit !important;
  background: transparent !important;
}

.message-content .w-md-editor-text h1,
.message-content .w-md-editor-text h2,
.message-content .w-md-editor-text h3 {
  margin-top: 8px !important;
  margin-bottom: 4px !important;
  color: inherit !important;
}

.message-content .w-md-editor-text p {
  margin: 4px 0 !important;
  color: inherit !important;
}

.message-content .w-md-editor-text ul,
.message-content .w-md-editor-text ol {
  margin: 4px 0 4px 16px !important;
  color: inherit !important;
}

.message-content .w-md-editor-text li {
  margin: 2px 0 !important;
  color: inherit !important;
}

.message-content .w-md-editor-text code {
  background: rgba(0, 0, 0, 0.1) !important;
  color: inherit !important;
  padding: 2px 4px !important;
  border-radius: 3px !important;
  font-size: 13px !important;
}

.message-content .w-md-editor-text strong {
  color: inherit !important;
  font-weight: 600 !important;
}

.message-content .w-md-editor-text em {
  color: inherit !important;
}

.message-content .w-md-editor-text blockquote {
  border-left: 3px solid rgba(255, 255, 255, 0.3);
  padding-left: 8px;
  margin: 4px 0;
  color: inherit !important;
  background: transparent !important;
}

.message-timestamp {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

/* Loading Animation */
.chat-message.loading .message-content {
  padding: 12px 20px;
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #667eea;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Input Area */
.chat-agent-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: rgba(248, 249, 250, 0.8);
  border-top: 1px solid rgba(224, 224, 224, 0.6);
  border-radius: 0 0 12px 12px;
  backdrop-filter: blur(5px);
}

.chat-agent-input textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.chat-agent-input textarea:focus {
  border-color: #667eea;
}

.chat-agent-input textarea:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.chat-send-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
  .chat-agent-container {
    background: rgba(26, 26, 26, 0.90);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .chat-agent-agents {
    background: linear-gradient(to bottom, rgba(42, 42, 42, 0.9), rgba(31, 31, 31, 0.8));
    border-bottom-color: rgba(58, 58, 58, 0.6);
  }
  
  .agent-name.openai-agent {
    background: linear-gradient(135deg, #10a37f30, #10a37f20);
    color: #10a37f;
    border-color: #10a37f60;
  }
  
  .agents-count {
    background: #3a3a3a;
    color: #b0b0b0;
  }
  
  .agents-checkboxes {
    border-top-color: #3a3a3a;
  }
  
  .system-message {
    background: #2a3a4a;
    border-left-color: #667eea;
    color: #b0b0b0;
  }

  .chat-agent-messages {
    background: rgba(26, 26, 26, 0.8);
  }

  .chat-agent-input {
    background: rgba(42, 42, 42, 0.8);
    border-top-color: rgba(58, 58, 58, 0.6);
  }

  .chat-agent-input textarea {
    background: #1a1a1a;
    color: #e0e0e0;
    border-color: #3a3a3a;
  }

  .chat-message.assistant .message-content {
    background: #2a2a2a;
    color: #e0e0e0;
  }

  .agent-checkbox span {
    color: #e0e0e0;
  }

  .agents-label {
    color: #b0b0b0;
  }

  .chat-welcome {
    color: #b0b0b0;
  }

  .chat-context-info {
    background: #2a3a4a;
  }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .chat-agent-container {
    width: calc(100vw - 48px);
    right: 24px;
    height: 70vh;
  }

  .chat-agent-fab {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
}