/* Streaming content styles - Keeping only styles for markdown, tables and charts */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap");

/* Animation for typing indicator */
@keyframes typing {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* Animation for fade in effect */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Style for follow-up questions loading state */
.follow-up-loading span {
  animation-name: typing;
  display: inline-block;
  margin-right: 2px;
}

/* Enhanced scroll behavior */
#chat-container {
  scroll-behavior: smooth;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  height: 100%;
}

/* Ensure chat containers have proper scroll behavior */
.fixed.h-\[calc\(100vh-140px\)\] {
  height: calc(100vh - 140px) !important;
  overflow-y: auto !important;
  scroll-behavior: smooth !important;
}

/* Mini-chat mode adjustments */
.mini-chat + #chat-outer-container,
#chat-outer-container:has(.mini-chat) {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
  max-height: 95vh !important;
  height: 95vh !important;
  padding-bottom: 20px !important;
}

/* Add scroll visibility for debugging if needed */
.scroll-debug {
  border: 2px solid red;
}

/* Ensure message containers don't overflow */
.message-transition {
  max-width: 100%;
  overflow-x: hidden;
}

/* Streaming content */
.streaming-content {
  padding: 0.75rem;
  line-height: 1.6;
}

/* Article link styles */
.article-link {
  color: #192342;
  text-decoration: none;
  border-bottom: none;
  transition: color 0.2s ease-in-out;
  font-weight: 500;
  margin-left: 1px;
}

.article-link:hover {
  color: #192342;
  opacity: 0.8;
  text-decoration: none;
}

.article-link i {
  font-size: 0.8em;
}

/* Hide any raw JSON in the streaming content */
.streaming-content > p[data-type="json"],
.raw-json {
  display: none !important;
}

/* Markdown content styling */
.markdown-content pre {
  background-color: #fafafa;
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.9rem;
  border: 1px solid #f4f4f5;
}

.markdown-content code {
  font-family: "JetBrains Mono", monospace;
  background-color: #f4f4f5;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  color: #3f3f46;
  font-size: 0.85rem;
}

.markdown-content pre code {
  padding: 0;
  background-color: transparent;
}

/* Add proper spacing for Markdown content */
.markdown-content p {
  margin-bottom: 1em;
  line-height: 1.6;
}

.markdown-content ul,
.markdown-content ol {
  list-style-type: disc;
  margin-top: 0.5em;
  margin-bottom: 1em;
  padding-left: 1.5em;
}

.markdown-content li {
  margin-bottom: 0.5em;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  font-weight: 500;
}

.markdown-content h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.markdown-content h2 {
  font-size: 1.3rem;
  font-weight: 500;
}

.markdown-content h3 {
  font-size: 1.1rem;
  font-weight: 500;
}

.markdown-content blockquote {
  border-left: 2px solid #e4e4e7;
  padding-left: 1em;
  margin: 1em 0;
  color: #52525b;
}

/* Table styles - keeping these as requested */
.table-responsive {
  overflow-x: auto;
  margin: 1.5rem 0;
  width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th,
.table td {
  padding: 10px;
  border-bottom: 1px solid #f4f4f5;
  font-size: 14px;
}

.table th {
  font-weight: 500;
  color: #52525b;
}

.streaming-content table {
  margin: 1em 0;
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
}

.streaming-content table th,
.streaming-content table td {
  padding: 8px;
  border: 1px solid #ddd;
  text-align: left;
}

.streaming-content table th {
  background-color: #f5f5f5;
  font-weight: 500;
}

/* Chart container */
.chart-container {
  margin: 1rem 0;
  border-radius: 6px;
  overflow: hidden;
  width: 100% !important;
  max-width: 100%;
}

/* Visualization placeholders */
.chart-placeholder,
.table-placeholder {
  padding: 1.5rem;
  margin: 1rem 0;
  background-color: #f8f9fa;
  border-radius: 0.5rem;
  border: 1px dashed #dee2e6;
  color: #495057;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  font-weight: 500;
  animation: pulse-soft 2s infinite ease-in-out;
}

@keyframes pulse-soft {
  0% {
    background-color: #f8f9fa;
  }
  50% {
    background-color: #f0f0f0;
  }
  100% {
    background-color: #f8f9fa;
  }
}

/* Error styling */
.error {
  color: #d00;
  background-color: #fff8f8;
  padding: 0.5rem;
  border-radius: 4px;
  border-left: 3px solid #d00;
}

/* Conversation item styling */
.conversation-item {
  position: relative;
}

.conversation-item:hover .delete-conversation-btn {
  opacity: 1;
}

.delete-conversation-btn {
  transition: all 0.2s ease-in-out;
}

.delete-conversation-btn:hover {
  background-color: rgba(239, 68, 68, 0.1);
  border-radius: 4px;
}

/* News mode styles */
body.news-mode {
  margin: 0;
  padding: 0;
}

body.news-mode header h1 {
  margin-left: 20px;
}

body.news-mode .container {
  padding: 0;
  width: 100%;
  max-width: 100%;
}

body.news-mode main {
  width: 100%;
  max-width: 100%;
}

body.news-mode .container .max-w-3xl {
  max-width: 100% !important;
  width: 100%;
}

body.news-mode .markdown-content {
  font-size: 1rem;
}

/* Make charts wider in news mode */
body.news-mode .chart-container {
  max-width: 800px;
  margin: 2rem auto;
}

/* Make tables more readable in news mode */
body.news-mode table {
  margin: 2rem auto;
  max-width: 1200px;
}

body.news-mode .markdown-content h1 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-family: Nunito Sans, sans-serif;
  font-size: 2em;
  font-weight: 500;
}

.mini-chat h2 {
  margin-top: 0.25rem;
}

/* Fix scrollbar issue in mini-chat mode by adding bottom padding for fixed form */
#chat-outer-container .mini-chat {
  padding-bottom: 90px !important;
}

/* Hide heading and position controls on right when hideConversationSidebar is true */
body[style*="zoom: 0.9"] #main-heading {
  display: none !important;
}

body[style*="zoom: 0.9"] header .flex.items-center.justify-center {
  justify-content: flex-end !important;
}

/* Add follow-up question button styles to match suggestions */
.follow-up-button,
.suggestion-btn {
  background-color: #eff6ff;
  border: 1px solid #dbeafe;
  color: #1d4ed8;
  border-radius: 0.375rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
}

.follow-up-button:hover,
.suggestion-btn:hover {
  background-color: #dbeafe;
}

.suggestion-btn {
  display: inline-block;
  text-align: left;
}

/* Remove the complex styling for suggestion buttons */
.suggestion-btn.flex.items-center.gap-2.p-3 {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: #eff6ff;
  border: 1px solid #dbeafe;
  color: #1d4ed8;
}

.follow-up-questions-container {
  width: 100%;
}

/* Typing effect animations */
@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

@keyframes typing-cursor-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.typing-cursor {
  animation: blink 1s infinite;
  color: #4caf50;
  font-weight: bold;
  font-size: 1em;
  line-height: 1;
  margin-left: 1px;
}

/* Add a subtle fade-in animation for the entire typing message */
.typing-welcome {
  animation: typing-cursor-fade-in 0.3s ease-in;
}

/* Signup card styles */
.signup-card-container {
  max-width: 400px;
  margin: 1rem auto;
}

.signup-card {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  padding: 1rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.signup-card .signup-button {
  background-color: #2563eb;
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
}

.signup-card .signup-button:hover {
  background-color: #1d4ed8;
}

.signup-card .signup-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6, 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Responsive adjustments for signup card */
@media (max-width: 640px) {
  .signup-card-container {
    max-width: none;
    margin: 1rem 0.5rem;
  }

  .signup-card {
    padding: 0.75rem;
  }
}

/* Custom dropdown styling */
.custom-select {
  position: relative;
  display: inline-block;
  min-width: 120px;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  color: #71717a; /* Grey font */
}

.custom-select-trigger:hover {
  color: #52525b;
}

.custom-select-options {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  min-width: 120px;
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
  margin-top: 4px;
}

.custom-select-options.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-select-option {
  padding: 6px 10px; /* Slightly smaller padding */
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-size: 12px; /* Smaller font size */
  color: #374151;
}

.custom-select-option:hover {
  background-color: #f0f0f0;
}

.custom-select-option.selected {
  background-color: #f8f8f8;
  color: #374151;
}

.custom-select-option:first-child {
  border-radius: 8px 8px 0 0;
}

.custom-select-option:last-child {
  border-radius: 0 0 8px 8px;
}

.custom-select-option:only-child {
  border-radius: 8px;
}

.custom-select-arrow {
  transition: transform 0.2s ease;
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

.status-loading,
.status-success,
.status-error {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.status-loading {
  background-color: #eff6ff;
  /* border: 1px solid #bfdbfe; */
  color: #1d4ed8;
}

.status-success {
  background-color: #f0fdf4;
  /* border: 1px solid #bbf7d0; */
  color: #166534;
}

.status-error {
  background-color: #fef2f2;
  /* border: 1px solid #fecaca; */
  color: #dc2626;
}

.status-spinner svg,
.status-icon svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.status-spinner svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Status message fade in animation */
.status-message-container {
  animation: fadeIn 0.3s ease-out;
}

/* Default loading state for status messages */
.status-default-loading {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

.status-default-loading span {
  animation-name: typing;
  display: inline-block;
}

#main-heading {
  display: flex;
  align-items: center;
  margin-right: 8px;
}

#main-heading img {
  height: 23px;
  margin-right: 7px;
  margin-bottom: 7px;
}

/* Custom tooltip styles */
#mode-tooltip {
  position: fixed;
  white-space: pre-line;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.375rem;
  max-width: 20rem;
  background-color: white !important;
  color: #374151 !important;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
  z-index: 9999 !important;
  pointer-events: none;
}

/* Tooltip arrow pointing right */
#mode-tooltip::before {
  content: "";
  position: absolute;
  right: -7px;
  top: var(--arrow-position, 50%);
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 7px solid #d1d5db;
  z-index: 1;
}

/* Tooltip arrow inner part (white fill) */
#mode-tooltip::after {
  content: "";
  position: absolute;
  right: -6px;
  top: var(--arrow-position, 50%);
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid white;
  z-index: 2;
}

/* Custom select styles */
.custom-select {
  position: relative;
  display: inline-block;
}

.custom-select-trigger {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
}

.custom-select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e4e4e7;
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 1000;
  min-width: 140px;
}

.custom-select-options.show {
  display: block;
}

.custom-select-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background-color 0.15s ease;
}

.custom-select-option:hover {
  background-color: #f4f4f5;
}

.custom-select-option.selected {
  background-color: #e4e4e7;
  font-weight: 500;
}

.custom-select-arrow {
  transition: transform 0.15s ease;
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

/* Scroll to bottom button styles */
#scroll-to-bottom-btn {
  transition: all 0.3s ease;
  z-index: 20;
}

#scroll-to-bottom-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
}

#scroll-to-bottom-btn:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

#scroll-to-bottom-btn button {
  animation: pulse-subtle 2s infinite;
}

@keyframes pulse-subtle {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

#scroll-to-bottom-btn button:hover {
  animation: none;
  transform: scale(1.1);
}

/* Media Viewer Styles */
.media-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-viewer.hidden {
  display: none;
}

.media-viewer-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(2, 0, 0, 0.75);
  cursor: pointer;
}

.media-viewer-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.media-container {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 85vh;
  overflow: hidden;
}

.media-container img,
.media-container video {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.media-viewer-close {
  position: absolute;
  top: 20px;
  right: 30px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 18px;
  z-index: 10001;
}

.media-viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

/* Media Preview Styles in Chat */
.media-preview {
  position: relative;
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
  padding: 8px;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
}

.media-preview:hover {
  border-color: #d1d5db;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.media-preview.image-preview img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: contain;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.media-preview.image-preview img:hover {
  transform: scale(1.02);
}

.media-preview.video-preview video {
  width: 100%;
  height: auto;
  max-height: 400px;
  border-radius: 6px;
  cursor: pointer;
}

.video-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

/* Video play button overlay */
.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 2;
}

.video-wrapper:hover .video-play-overlay {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.1);
}

/* Make the video itself non-interactive in preview mode */
.video-preview video {
  pointer-events: none;
}

/* Add a subtle overlay icon to indicate expandability - only for images */
.media-preview.image-preview::after {
  content: "\f065"; /* Font Awesome expand icon */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.media-preview.image-preview:hover::after {
  opacity: 1;
}

/* Hide expand icon for videos - they have their own play icon */
.media-preview.video-preview::after {
  display: none;
}

/* Animation for media viewer appearance */
@keyframes mediaViewerFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes mediaContentZoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.media-viewer:not(.hidden) {
  animation: mediaViewerFadeIn 0.2s ease;
}

.media-viewer:not(.hidden) .media-viewer-content {
  animation: mediaContentZoomIn 0.3s ease;
}
