/* CodeShaala Chatbot Widget Styles */
.codeshaala-chatbot * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
}

/* Floating chat button - New Animated Design */
.button.chat-toggle-btn {
  cursor: pointer;
  border: none;
  background: #7808d0;
  color: #fff;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  position: fixed;
  bottom: 30px;
  left: 30px;
  display: grid;
  place-content: center;
  transition: background 300ms, transform 200ms;
  font-weight: 600;
  z-index: 10000;
  box-shadow: 0 8px 32px rgba(120, 8, 208, 0.4);
}

.button__text {
  position: absolute;
  inset: 0;
  animation: text-rotation 8s linear infinite;
}

.button__text > span {
  position: absolute;
  transform: rotate(calc(21deg * var(--index)));
  inset: 7px;
  font-size: 12px;
  font-weight: 600;
}

.button__circle {
  position: relative;
  width: 40px;
  height: 40px;
  overflow: hidden;
  background: #fff;
  color: #7808d0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.button__icon--copy {
  position: absolute;
  transform: translate(-150%, 150%);
}

.button.chat-toggle-btn:hover {
  background: #000;
  transform: scale(1.05);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.button.chat-toggle-btn:hover .button__icon {
  color: #000;
}

.button.chat-toggle-btn:hover .button__icon:first-child {
  transition: transform 0.3s ease-in-out;
  transform: translate(150%, -150%);
}

.button.chat-toggle-btn:hover .button__icon--copy {
  transition: transform 0.3s ease-in-out 0.1s;
  transform: translate(0);
}

@keyframes text-rotation {
  to {
    rotate: 360deg;
  }
}

/* Chat widget container - moved to left */
.chat-widget {
  position: fixed;
  bottom: 150px; /* Adjusted for larger button (100px + 50px spacing) */
  left: 30px; /* Changed from right to left */
  width: 420px;
  height: 650px;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(120, 8, 208, 0.3);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.chat-widget.active {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* Chat header */
.chat-header {
  background: linear-gradient(135deg, #000 0%, #333 100%);
  color: white;
  padding: 20px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(120, 8, 208, 0.3);
}

.chat-header::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 70%
  );
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0%,
  100% {
    transform: translateX(-100%) translateY(-100%);
  }
  50% {
    transform: translateX(0) translateY(0);
  }
}

.chat-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.chat-avatar {
  width: 60px;
  height: 60px;
  background: transparent;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: none;
  padding: 0;
  margin-right: 12px;
}

/* Custom AI button styling for dark theme */
.chat-avatar.group {
  background: linear-gradient(45deg, #7808d0, #000) !important;
  box-shadow: rgba(120, 8, 208, 0.3) 0 1px 2px 0,
    rgba(120, 8, 208, 0.15) 0 2px 6px 2px, rgba(0, 0, 0, 0.3) 0 30px 60px -30px,
    rgba(120, 8, 208, 0.2) 0 -2px 6px 0 inset !important;
}

.chat-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: linear-gradient(180deg, #111 0%, #222 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 8, 208, 0.5) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(120, 8, 208, 0.5);
  border-radius: 2px;
}

.message {
  margin-bottom: 16px;
  display: flex;
  animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  justify-content: flex-end;
}

.message-content {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
}

.message.user .message-content {
  background: linear-gradient(135deg, #7808d0 0%, #000 100%);
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 12px rgba(120, 8, 208, 0.4);
}

.message.assistant .message-content {
  background: rgba(40, 40, 40, 0.9);
  color: #e5e5e5;
  border: 1px solid rgba(120, 8, 208, 0.2);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Enhanced formatting for assistant messages */
.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3,
.message.assistant .message-content h4 {
  color: #ffffff;
  margin: 8px 0 4px 0;
  font-weight: 600;
}

.message.assistant .message-content h1 {
  font-size: 16px;
}
.message.assistant .message-content h2 {
  font-size: 15px;
}
.message.assistant .message-content h3 {
  font-size: 14px;
}
.message.assistant .message-content h4 {
  font-size: 13px;
}

.message.assistant .message-content p {
  margin: 8px 0;
  line-height: 1.6;
}

.message.assistant .message-content ul,
.message.assistant .message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message.assistant .message-content li {
  margin: 4px 0;
  line-height: 1.5;
}

.message.assistant .message-content strong {
  font-weight: 600;
  color: #ffffff;
}

.message.assistant .message-content em {
  font-style: italic;
  color: #4a5568;
}

.message.assistant .message-content blockquote {
  border-left: 3px solid #667eea;
  padding-left: 12px;
  margin: 8px 0;
  color: #4a5568;
  font-style: italic;
}

/* Code blocks styling */
.message.assistant .message-content pre {
  background: #1a202c;
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
  position: relative;
  border: 1px solid #2d3748;
}

.message.assistant .message-content code {
  font-family: "Fira Code", "Monaco", "Menlo", "Ubuntu Mono", monospace;
  font-size: 13px;
  line-height: 1.4;
}

.message.assistant .message-content pre code {
  background: none;
  padding: 0;
  border: none;
  color: #e2e8f0;
}

.message.assistant .message-content p code,
.message.assistant .message-content li code {
  background: #f7fafc;
  color: #2d3748;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid #e2e8f0;
}

/* Copy button for code blocks */
.code-block-container {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  opacity: 1;
}

.copy-btn.copied {
  background: #10b981;
  color: white;
}

/* Language label for code blocks */
.code-language {
  position: absolute;
  top: 8px;
  left: 12px;
  background: rgba(102, 126, 234, 0.8);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  max-width: 75%;
}

.typing-text {
  font-size: 14px;
  color: #6b7280;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* Chat input */
.chat-input-container {
  padding: 20px;
  background: #000;
  border-top: 1px solid rgba(120, 8, 208, 0.3);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: rgba(40, 40, 40, 0.8);
  border-radius: 24px;
  padding: 8px;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.chat-input-wrapper:focus-within {
  border-color: #7808d0;
  background: rgba(60, 60, 60, 0.9);
  box-shadow: 0 0 0 4px rgba(120, 8, 208, 0.2);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 20px;
  max-height: 80px;
  font-family: inherit;
  color: #ffffff;
  placeholder-color: #aaa;
}

.send-button {
  background: linear-gradient(135deg, #7808d0 0%, #000 100%);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 16px;
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(120, 8, 208, 0.5);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Welcome message */
.welcome-message {
  text-align: center;
  color: #d1d5db;
  margin: 40px 0;
  font-size: 14px;
  line-height: 1.5;
}

.welcome-emoji {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
}

/* Error message */
.error-message {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  color: #dc2626;
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid #fecaca;
  max-width: 75%;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.1);
}

/* Mobile responsiveness */
@media (max-width: 480px) {
  .chat-widget {
    bottom: 100px;
    left: 20px; /* Changed from right to left */
    right: 20px;
    width: auto;
    height: 70vh;
    max-height: 500px;
  }

  .chat-toggle-btn {
    bottom: 20px;
    left: 20px; /* Changed from right to left */
    width: 60px;
    height: 60px;
    font-size: 24px;
  }

  .message-content {
    max-width: 90%;
    font-size: 13px;
  }

  .message.assistant .message-content pre {
    padding: 12px;
    font-size: 12px;
  }
}

/* Smooth entrance animation */
@keyframes slideInFromBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.chat-toggle-btn {
  animation: slideInFromBottom 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.5s both;
}

/* Prism.js theme overrides for better integration */
pre[class*="language-"] {
  background: #1a202c !important;
  border: 1px solid #2d3748 !important;
}

code[class*="language-"] {
  color: #e2e8f0 !important;
}
