/* AI Chat Widget Styles */

/* Floating Chat Button */
.ai-chat-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(22, 163, 74, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 999;
}

.ai-chat-trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(22, 163, 74, 0.5);
}

.ai-chat-trigger svg {
  width: 28px;
  height: 28px;
}

.ai-chat-trigger .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #fbbf24;
  color: #1f2937;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Chat Widget Container */
.ai-chat-widget {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 500px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.ai-chat-widget.open {
  display: flex;
  animation: slideUp 0.3s ease;
}

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

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

.ai-chat-header-left {
  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-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.ai-chat-header-info span {
  font-size: 12px;
  opacity: 0.9;
}

.ai-chat-credits {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

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

.ai-chat-header-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.ai-chat-header-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

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

.ai-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.ai-message.user {
  align-self: flex-end;
  background: #16a34a;
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-message.assistant {
  align-self: flex-start;
  background: white;
  color: #1f2937;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-message.assistant p {
  margin: 0 0 8px;
}

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

.ai-message.assistant code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

.ai-message.assistant pre {
  background: #1f2937;
  color: #f9fafb;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  margin: 8px 0;
}

.ai-message.assistant pre code {
  background: none;
  padding: 0;
}

.ai-message.assistant ul,
.ai-message.assistant ol {
  margin: 8px 0;
  padding-left: 20px;
}

/* Typing Indicator */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  max-width: 80px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typing 1.4s infinite ease-in-out;
}

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

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

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

/* Chat Input */
.ai-chat-input-area {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.ai-chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 8px 12px;
}

.ai-chat-input {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-size: 14px;
  line-height: 1.4;
  max-height: 100px;
  font-family: inherit;
}

.ai-chat-input:focus {
  outline: none;
}

.ai-chat-input::placeholder {
  color: #9ca3af;
}

.ai-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #16a34a;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.ai-chat-send-btn:hover {
  background: #15803d;
}

.ai-chat-send-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

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

/* Welcome Screen */
.ai-chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: #f9fafb;
}

.ai-chat-welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  margin-bottom: 16px;
}

.ai-chat-welcome h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 8px;
}

.ai-chat-welcome p {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 20px;
}

.ai-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.ai-chat-suggestion {
  padding: 10px 14px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.ai-chat-suggestion:hover {
  border-color: #16a34a;
  background: #f0fdf4;
}

/* No Credits Screen */
.ai-chat-no-credits {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: #f9fafb;
}

.ai-chat-no-credits-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d97706;
  font-size: 24px;
  margin-bottom: 12px;
}

.ai-chat-no-credits h3 {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 8px;
}

.ai-chat-no-credits p {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 16px;
}

.ai-chat-buy-btn {
  padding: 10px 20px;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.ai-chat-buy-btn:hover {
  background: #15803d;
}

/* Error Message */
.ai-message.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .ai-chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .ai-chat-trigger {
    bottom: 16px;
    right: 16px;
  }
}

/* Full Page AI Tutor Styles */
.ai-tutor-page {
  display: flex;
  height: calc(100vh - 80px); /* Adjust for header */
  background: #f9fafb;
}

.ai-tutor-sidebar {
  width: 280px;
  background: white;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
}

.ai-tutor-sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.ai-new-chat-btn {
  width: 100%;
  padding: 10px 16px;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}

.ai-new-chat-btn:hover {
  background: #15803d;
}

.ai-conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.ai-conversation-item {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
  margin-bottom: 4px;
}

.ai-conversation-item:hover {
  background: #f3f4f6;
}

.ai-conversation-item.active {
  background: #f0fdf4;
}

.ai-conversation-title {
  font-size: 14px;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.ai-conversation-time {
  font-size: 11px;
  color: #9ca3af;
}

.ai-tutor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ai-tutor-header {
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-tutor-credits {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-tutor-credits-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0fdf4;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  color: #15803d;
  font-weight: 500;
}

.ai-tutor-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-tutor-input-area {
  padding: 16px 24px 24px;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.ai-tutor-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: #f3f4f6;
  border-radius: 16px;
  padding: 12px 16px;
  max-width: 800px;
  margin: 0 auto;
}

.ai-tutor-input {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 150px;
  font-family: inherit;
}

.ai-tutor-input:focus {
  outline: none;
}

@media (max-width: 768px) {
  .ai-tutor-sidebar {
    display: none;
  }
}
