/* AI Chat Popup Styles */
.ai-chat-toggle-btn {
  position: fixed;
  bottom: 75px;
  right: 30px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-1) 0%, var(--color-1) 100%);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  outline: none;
}

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

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

.ai-chat-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.ai-chat-popup {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 380px;
  height: 600px;
  max-height: 80vh;
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

.ai-chat-popup.active {
  display: flex;
}

.ai-chat-popup.minimized {
  height: 60px;
  overflow: visible;
}

.ai-chat-popup.minimized .ai-chat-popup-body,
.ai-chat-popup.minimized .ai-chat-popup-footer {
  display: none;
}

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

.ai-chat-popup-header {
  background: linear-gradient(135deg, var(--color-1) 0%, var(--color-1) 100%);
  color: white;
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: move;
}

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

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

.ai-chat-header-text h5 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.ai-chat-header-text small {
  font-size: 12px;
  opacity: 0.9;
}

.ai-chat-header-actions {
  display: flex;
  gap: 10px;
}

.ai-chat-btn-minimize,
.ai-chat-btn-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 5px;
  transition: background 0.2s;
}

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

.ai-chat-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
}

.ai-chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.ai-chat-message {
  display: flex;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

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

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

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

.ai-chat-message-bot .ai-chat-message-avatar {
  background: linear-gradient(135deg, var(--color-1) 0%, var(--color-1) 100%);
  color: white;
}

.ai-chat-message-user .ai-chat-message-avatar {
  background: #e9ecef;
  color: #667eea;
}

.ai-chat-message-content {
  flex: 1;
  max-width: 75%;
}

.ai-chat-message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
  overflow-wrap: break-word;
}

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

.ai-chat-message-user .ai-chat-message-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-chat-message-user .ai-chat-message-bubble p {
  margin: 0;
  color: white;
}

.ai-chat-message-bubble p {
  margin: 0 0 8px 0;
  font-size: 14px;
  line-height: 1.6;
}

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

/* Formatted content styles */
.ai-chat-message-bubble h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 12px 0 8px 0;
  color: #333;
  line-height: 1.4;
}

.ai-chat-message-bubble h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 10px 0 6px 0;
  color: #333;
  line-height: 1.4;
}

.ai-chat-message-bubble h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 8px 0 4px 0;
  color: #333;
  line-height: 1.4;
}

.ai-chat-message-bubble strong {
  font-weight: 600;
  color: #333;
}

.ai-chat-message-bubble em {
  font-style: italic;
}

.ai-chat-message-bubble ul,
.ai-chat-message-bubble ol {
  margin: 8px 0;
  padding-left: 24px;
}

.ai-chat-message-bubble li {
  margin: 4px 0;
  line-height: 1.5;
}

.ai-chat-message-bubble ul li {
  list-style-type: disc;
}

.ai-chat-message-bubble ol li {
  list-style-type: decimal;
}

.ai-chat-message-bubble code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
}

.ai-chat-message-bubble .ai-inline-code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: #d63384;
}

.ai-chat-message-bubble .ai-code-block {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}

.ai-chat-message-bubble .ai-code-block code {
  display: block;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #333;
}

.ai-chat-message-bubble a {
  color: #667eea;
  text-decoration: underline;
  word-break: break-all;
}

.ai-chat-message-bubble a:hover {
  color: #764ba2;
  text-decoration: none;
}

/* Ensure proper spacing between formatted elements */
.ai-chat-message-bubble > *:first-child {
  margin-top: 0;
}

.ai-chat-message-bubble > *:last-child {
  margin-bottom: 0;
}

/* Better spacing for mixed content */
.ai-chat-message-bubble h2 + p,
.ai-chat-message-bubble h3 + p,
.ai-chat-message-bubble h4 + p {
  margin-top: 4px;
}

.ai-chat-message-bubble p + ul,
.ai-chat-message-bubble p + ol {
  margin-top: 4px;
}

.ai-chat-message-bubble ul + p,
.ai-chat-message-bubble ol + p {
  margin-top: 8px;
}

.ai-chat-message-time {
  font-size: 11px;
  color: #6c757d;
  margin-top: 5px;
  padding: 0 5px;
}

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

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

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

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

.ai-typing-dots 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;
  }
}

.ai-chat-popup-footer {
  padding: 15px;
  background: white;
  border-top: 1px solid #e9ecef;
}

.ai-chat-input-container {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-chat-input {
  flex: 1;
  border: 1px solid #e9ecef;
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 14px;
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

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

.ai-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-1) 0%, var(--color-1) 100%);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.ai-chat-send-btn:hover {
  transform: scale(1.1);
}

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

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

/* Scrollbar styling */
.ai-chat-popup-body::-webkit-scrollbar {
  width: 6px;
}

.ai-chat-popup-body::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.ai-chat-popup-body::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.ai-chat-popup-body::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Responsive */
@media (max-width: 768px) {
  .ai-chat-popup {
    width: calc(100% - 20px);
    right: 10px;
    bottom: 90px;
    height: calc(100vh - 120px);
    max-height: calc(100vh - 120px);
  }
  
  .ai-chat-toggle-btn {
    bottom: 20px;
    right: 20px;
    width: 55px;
    height: 55px;
  }
}

