/* Fixed Chatbot Widget - Bottom Corner */
.ai-chatbot-widget {
  position: fixed;
  bottom: 20px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
}

.ai-chatbot-widget.position-left {
  left: 20px;
}

.ai-chatbot-widget.position-right {
  right: 20px;
}

/* Toggle Button */
.chatbot-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: transform 0.3s, box-shadow 0.3s;
  position: relative;
}

.chatbot-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chatbot-icon {
  font-size: 28px;
  transition: opacity 0.3s, transform 0.3s;
}

.chatbot-close-icon {
  position: absolute;
  font-size: 24px;
  font-weight: bold;
  opacity: 0;
  transform: rotate(-90deg);
  transition: opacity 0.3s, transform 0.3s;
}

.ai-chatbot-widget.active .chatbot-icon {
  opacity: 0;
  transform: rotate(90deg);
}

.ai-chatbot-widget.active .chatbot-close-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* Chat Window */
.chatbot-window {
  position: absolute;
  bottom: 80px;
  width: 380px;
  height: 550px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

.ai-chatbot-widget.position-left .chatbot-window {
  left: 0;
}

.ai-chatbot-widget.position-right .chatbot-window {
  right: 0;
}

.ai-chatbot-widget.active .chatbot-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

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

.chatbot-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  font-size: 32px;
}

.chatbot-title {
  display: flex;
  flex-direction: column;
}

.chatbot-title strong {
  font-size: 16px;
  margin-bottom: 2px;
}

.chatbot-status {
  font-size: 12px;
  opacity: 0.9;
}

.chatbot-status::before {
  content: "●";
  color: #4ade80;
  margin-right: 4px;
}

.chatbot-minimize-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  transition: background 0.2s;
}

.chatbot-minimize-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  scroll-behavior: smooth;
}

.message {
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: messageSlideIn 0.3s ease-out;
}

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

.message-avatar {
  font-size: 24px;
  flex-shrink: 0;
}

.message-content {
  background: white;
  padding: 12px 14px;
  border-radius: 12px;
  max-width: 80%;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-content a {
  color: #667eea;
  text-decoration: underline;
}

.message-content a:hover {
  color: #764ba2;
}

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

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

.user-message strong {
  color: white;
}

.bot-message .message-content strong {
  color: #667eea;
}

/* Input Area */
.chatbot-input-area {
  padding: 16px;
  background: white;
  border-radius: 0 0 16px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 10px;
}

#ai-query-input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  resize: none;
  transition: border-color 0.2s;
}

#ai-query-input:focus {
  outline: none;
  border-color: #667eea;
}

.chatbot-send-btn {
  padding: 10px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

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

.chatbot-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.send-icon {
  font-size: 10px;
}

/* API Response Display */
.api-response {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  overflow-x: auto;
  margin: 8px 0;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Status Messages */
.result-count {
  display: inline-block;
  background: #4ade80;
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.error-message {
  color: #dc2626;
  font-weight: 600;
  display: block;
  padding: 8px 12px;
  background: #fee2e2;
  border-radius: 6px;
  border-left: 3px solid #dc2626;
}

.loading-dots::after {
  content: "...";
  animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
  0%,
  20% {
    content: ".";
  }
  40% {
    content: "..";
  }
  60%,
  100% {
    content: "...";
  }
}

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

.chatbot-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

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

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

/* Responsive Design */
@media (max-width: 480px) {
  .chatbot-window {
    width: calc(100vw - 40px);
    height: calc(100vh - 140px);
    left: 20px !important;
    right: 20px !important;
  }

  .ai-chatbot-widget.position-right {
    right: 20px;
  }

  .message-content {
    max-width: 75%;
  }
}

/* Admin Settings Styles */
.form-table th {
  width: 200px;
}

.card {
  background: white;
  padding: 20px;
  margin: 20px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.card h2 {
  margin-top: 0;
  border-bottom: 2px solid #667eea;
  padding-bottom: 10px;
}

.card code {
  background: #f0f0f1;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
  display: inline-block;
  margin: 4px 0;
}

/* Query Results Cards */
.query-results-cards {
  display: grid;
  gap: 16px;
  margin-top: 10px;
}

.result-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.card-content {
  padding: 16px;
}

.card-title {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.4;
}

.card-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-field {
  display: flex;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.card-field:last-child {
  border-bottom: none;
}

.field-label {
  font-weight: 600;
  color: #555;
  min-width: 140px;
  flex-shrink: 0;
  text-transform: capitalize;
}

.field-value {
  color: #333;
  word-break: break-word;
  flex: 1;
}

.null-value {
  color: #999;
  font-style: italic;
}

.result-note {
  display: block;
  margin-top: 8px;
  color: #6b7280;
  font-size: 12px;
  text-align: center;
}

.no-results {
  color: #6b7280;
  font-style: italic;
  display: block;
  text-align: center;
  padding: 20px;
}
