/**
 * AI Chat Panel Styles
 * ====================
 */

/* Floating Chat Button */
.ai-chat-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
  transition: all 0.3s ease;
  z-index: 998;
  font-weight: 500;
  font-size: 14px;
}

.ai-chat-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(59, 130, 246, 0.5);
}

.ai-chat-button.active {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

.ai-chat-button i {
  width: 20px;
  height: 20px;
}

.chat-button-label {
  display: inline;
}

@media (max-width: 768px) {
  .chat-button-label {
    display: none;
  }
  
  .ai-chat-button {
    padding: 14px;
    border-radius: 50%;
  }
}

/* Chat Panel */
.ai-chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: var(--surface-color, #ffffff);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s ease;
  overflow: hidden;
}

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

@media (max-width: 768px) {
  .ai-chat-panel {
    bottom: 80px;
    right: 12px;
    left: 12px;
    width: auto;
    height: 60vh;
  }
}


/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

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

.chat-header-left i {
  width: 18px;
  height: 18px;
}

.chat-header-right {
  display: flex;
  gap: 4px;
}

.chat-header-right button {
  padding: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-header-right button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-header-right button i {
  width: 16px;
  height: 16px;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Welcome Screen */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  height: 100%;
}

.welcome-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.welcome-icon i {
  width: 28px;
  height: 28px;
  color: #3b82f6;
}

.chat-welcome h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: var(--text-primary, #1e293b);
}

.chat-welcome p {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: var(--text-secondary, #64748b);
}

/* Quick Suggestions */
.quick-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.suggestion-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-secondary, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: var(--text-primary, #1e293b);
  transition: all 0.2s;
}

.suggestion-btn:hover {
  background: var(--hover-bg, #e2e8f0);
  border-color: #3b82f6;
}

.suggestion-btn i {
  width: 16px;
  height: 16px;
  color: #3b82f6;
  flex-shrink: 0;
}


/* Chat Messages */
.chat-message {
  display: flex;
  gap: 10px;
  max-width: 90%;
}

.chat-message-user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-message-user .message-content {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-radius: 16px 16px 4px 16px;
}

.chat-message-assistant .message-content {
  background: var(--surface-secondary, #f1f5f9);
  color: var(--text-primary, #1e293b);
  border-radius: 16px 16px 16px 4px;
}

.message-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-avatar i {
  width: 16px;
  height: 16px;
  color: #3b82f6;
}

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

.message-content strong {
  color: inherit;
}

.message-content .list-number {
  font-weight: 600;
  color: #3b82f6;
}

.message-fallback {
  font-size: 11px;
  color: var(--text-tertiary, #94a3b8);
  margin-top: 4px;
  font-style: italic;
}

/* Typing Indicator */
.typing-indicator .message-content {
  padding: 12px 16px;
}

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

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

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

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


/* Chat Input Area */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: var(--surface-color, #ffffff);
}

.chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface-secondary, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  transition: all 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-primary, #1e293b);
  outline: none;
}

#chat-input::placeholder {
  color: var(--text-tertiary, #94a3b8);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn i {
  width: 16px;
  height: 16px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color, #e2e8f0);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary, #94a3b8);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .ai-chat-panel {
    background: #1e293b;
  }
  
  .chat-welcome h3 {
    color: #f1f5f9;
  }
  
  .chat-message-assistant .message-content {
    background: #334155;
    color: #f1f5f9;
  }
  
  .suggestion-btn {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
  }
  
  .suggestion-btn:hover {
    background: #475569;
  }
}

/* AI Insights Section in Dashboard */
.ai-insights-section {
  margin-top: 24px;
}

.dashboard-insights-container {
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  padding: 20px;
}

/* Config Validator Section in Admin */
.config-validator-section {
  margin-bottom: 24px;
}

#config-validator-status {
  background: var(--surface-color, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .ai-insights-section {
    margin-top: 16px;
  }
  
  .dashboard-insights-container {
    padding: 16px;
  }
  
  /* Move chat button up on mobile to avoid system navigation */
  .ai-chat-button {
    bottom: 80px !important;
  }
  
  .ai-chat-panel {
    bottom: 140px !important;
    width: calc(100vw - 32px) !important;
    max-width: none !important;
    right: 16px !important;
  }
}
