/* AI Chat Plugin Styles */

/* Overlay for mobile/tablet */
.ai-chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ai-chat-overlay.show {
  display: block;
  opacity: 1;
}

/* Right Side Drawer */
.ai-chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--mainBackgroundColor);
  border-left: 1px solid var(--mainBorderColor);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.ai-chat-drawer.open {
  transform: translateX(0);
}

/* Chat Header */
.ai-chat-header {
  padding: 20px;
  border-bottom: 1px solid var(--mainBorderColor);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--mainBackgroundColor);
  flex-shrink: 0;
}

.ai-chat-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--mainForegroundColor);
}

.ai-chat-close {
  background: transparent;
  border: none;
  color: var(--greyForegroundColor);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.ai-chat-close:hover {
  background: var(--mainColorLightest);
  color: var(--mainForegroundColor);
}

.ai-chat-close svg {
  width: 20px;
  height: 20px;
}

/* Chat Body */
.ai-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Messages Container */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--mainBackgroundColor);
}

.ai-chat-messages::-webkit-scrollbar {
  width: 6px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--greyBackgroundColor);
  border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--greyForegroundColor);
}

/* Welcome Message */
.ai-chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--greyForegroundColor);
}

.ai-chat-welcome .welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.ai-chat-welcome h4 {
  color: var(--mainForegroundColor);
  font-size: 18px;
  margin: 0 0 12px 0;
}

.ai-chat-welcome p {
  font-size: 14px;
  margin: 0 0 16px 0;
  color: var(--greyForegroundColor);
}

.ai-chat-welcome ul {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
  display: inline-block;
  font-size: 13px;
}

.ai-chat-welcome ul li {
  padding: 8px 0;
  position: relative;
  padding-left: 24px;
}

.ai-chat-welcome ul li:before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--mainColor);
  font-weight: bold;
}

/* Processing Status Messages */
.ai-chat-processing,
.ai-chat-not-processed {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.ai-chat-processing {
  background: var(--mainColorLightest);
  color: var(--mainForegroundColor);
  border: 1px solid var(--mainColor);
}

.ai-chat-not-processed {
  background: rgba(255, 193, 7, 0.1);
  color: var(--greyForegroundColor);
  border: 1px solid rgba(255, 193, 7, 0.3);
}

.processing-icon,
.warning-icon {
  font-size: 20px;
  flex-shrink: 0;
}

/* Chat Messages */
.ai-chat-message {
  max-width: 85%;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease;
}

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

.ai-chat-message.user {
  align-self: flex-end;
}

.ai-chat-message.assistant {
  align-self: flex-start;
}

.ai-chat-message .message-role {
  font-size: 11px;
  color: var(--greyForegroundColor);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-chat-message .message-content {
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 14px;
}

.ai-chat-message.user .message-content {
  background: var(--mainColor);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant .message-content {
  background: var(--mainColorLightest);
  color: var(--mainForegroundColor);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--mainBorderColor);
}

/* Loading Animation */
.loading-dots {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mainColor);
  animation: loading-bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

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

/* Input Container */
.ai-chat-input-container {
  padding: 16px;
  border-top: 1px solid var(--mainBorderColor);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--mainBackgroundColor);
  flex-shrink: 0;
}

/* Input Field */
.ai-chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--inputBorderColor);
  border-radius: 8px;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s;
  max-height: 120px;
  background: var(--inputBackgroundColor);
  color: var(--inputForegroundColor);
  font-family: inherit;
}

.ai-chat-input::placeholder {
  color: var(--inputPlaceholderColor);
}

.ai-chat-input:focus {
  border-color: var(--mainColor);
  box-shadow: 0 0 0 3px rgba(var(--mainColorRGB, 226, 50, 50), 0.1);
}

.ai-chat-input:disabled {
  background: var(--inputBackgroundColor);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Send Button */
.ai-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--mainColor);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-chat-send:hover:not(:disabled) {
  background: var(--mainHoverColor);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ai-chat-send:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

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

/* Floating Toggle Button */
.ai-chat-toggle-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--mainColor);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  z-index: 9997;
}

.ai-chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.ai-chat-toggle-btn.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

.ai-chat-toggle-btn svg {
  width: 24px;
  height: 24px;
}

.ai-chat-toggle-btn .chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ffffff;
  color: var(--mainColor);
  font-size: 10px;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Timestamp Links */
.timestamp-link {
  color: var(--mainColor);
  text-decoration: none;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(var(--mainColorRGB, 226, 50, 50), 0.1);
  transition: all 0.2s;
  display: inline-block;
  cursor: pointer;
}

.timestamp-link:hover {
  background: rgba(var(--mainColorRGB, 226, 50, 50), 0.2);
  text-decoration: underline;
}

/* Video Links */
.video-link {
  color: #00a0d2;
  text-decoration: none;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 160, 210, 0.1);
  transition: all 0.2s;
  display: inline-block;
}

.video-link:hover {
  background: rgba(0, 160, 210, 0.2);
  text-decoration: underline;
}

/* Process Button in Dropdown */
.ai-chat-process-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.ai-chat-process-btn:hover {
  background-color: var(--mainColorLightest);
}

.ai-chat-process-btn.disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Tablet Responsive */
@media (max-width: 768px) {
  .ai-chat-drawer {
    width: 350px;
  }

  .ai-chat-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
  }

  .ai-chat-overlay.show {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .ai-chat-drawer {
    width: 100%;
  }

  .ai-chat-toggle-btn {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
  }

  .ai-chat-header {
    padding: 16px;
  }

  .ai-chat-messages {
    padding: 16px;
  }

  .ai-chat-input-container {
    padding: 12px;
  }

  .ai-chat-welcome {
    padding: 30px 16px;
  }

  .ai-chat-welcome .welcome-icon {
    font-size: 36px;
  }

  .ai-chat-welcome h4 {
    font-size: 16px;
  }
}

/* Dark mode improvements */
@media (prefers-color-scheme: dark) {
  .ai-chat-drawer {
    background: var(--mainBackgroundColor);
    border-left-color: rgba(255, 255, 255, 0.1);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
  }

  .ai-chat-overlay {
    background: rgba(0, 0, 0, 0.7);
  }

  .ai-chat-message.user .message-content {
    color: #ffffff;
  }

  .ai-chat-input {
    background: var(--inputBackgroundColor);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .ai-chat-input:focus {
    border-color: var(--mainColor);
  }
}

/* Animation for drawer entrance */
@keyframes slideIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Smooth scrolling for messages */
.ai-chat-messages {
  scroll-behavior: smooth;
}

/* Better text selection */
.ai-chat-message .message-content {
  user-select: text;
}

/* Improve readability */
.ai-chat-message .message-content p {
  margin: 0 0 8px 0;
}

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

/* List styles in messages */
.ai-chat-message .message-content ul,
.ai-chat-message .message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.ai-chat-message .message-content li {
  margin: 4px 0;
}

/* Code blocks in messages */
.ai-chat-message .message-content code {
  background: var(--mainColorLightest);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

.ai-chat-message .message-content pre {
  background: var(--mainColorLightest);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}

.ai-chat-message .message-content pre code {
  background: transparent;
  padding: 0;
}