/* ChatGPT-like styling */
body:has(.chat-wrapper) #main-container {
  max-width: 100%;
  padding: 0;
  margin: 0;
  height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
}

.chat-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 768px;
  margin: 0 auto;
  width: 100%;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
  background: #ffffff;
  scroll-behavior: smooth;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.welcome-message,
.user-message,
.bot-message {
  padding: 1.5rem 1rem;
  animation: fadeIn 0.3s ease-in;
  display: flex;
  width: 100%;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-message {
  background: transparent;
  justify-content: flex-end;
}

.user-message .message-content {
  background: #f4f4f4;
  border-radius: 18px;
  padding: 0.75rem 1rem;
  max-width: 85%;
  color: #353740;
  font-size: 16px;
  line-height: 1.75;
  font-weight: 400;
  font-family: inherit;
}

.bot-message {
  background: #ffffff;
  justify-content: flex-start;
}


.message-content {
  flex: 1;
  min-width: 0;
  line-height: 1.5;
  color: #353740;
  font-size: 16px;
  font-weight: 400;
  font-family: inherit;
}

/* Ensure all markdown-rendered elements have consistent font size */
.message-content *:not(code):not(pre) {
  font-size: inherit;
  line-height: inherit;
}

/* Ensure markdown headings, lists, etc. use base font size */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6,
.message-content li,
.message-content ul,
.message-content ol {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
}

/* Tighter spacing for lists */
.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin: 0.25rem 0;
}

/* Remove extra spacing for nested lists */
.message-content li>ul,
.message-content li>ol {
  margin: 0.25rem 0;
}

.bot-message .message-content {
  flex: 1;
}

.message-content p {
  margin: 0 0 0.5rem 0;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
}

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

.message-content code {
  background: #f1f1f1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Courier New', monospace;
}

.message-content pre {
  background: #f1f1f1;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.75rem 0;
}

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

.chat-input-container {
  border-top: 1px solid #e5e5e5;
  background: #ffffff;
  padding: 1rem;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 24px;
  padding: 0.75rem 1rem;
  transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: #10a37f;
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 16px;
  line-height: 1.5;
  color: #353740;
  background: transparent;
  max-height: 200px;
  overflow-y: auto;
  font-family: inherit;
}

.chat-input::placeholder {
  color: #8e8ea0;
}

.send-button {
  background: #10a37f;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 500;
}

.send-button:hover:not(:disabled) {
  background: #0d8f6e;
}

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

.connection-status {
  text-align: center;
  font-size: 12px;
  color: #8e8ea0;
  margin-top: 0.5rem;
  padding: 0.25rem 0;
}

.connection-status.connected {
  color: #10a37f;
}

.connection-status.disconnected {
  color: #ef4444;
}

/* Feedback section styling */
.feedback-section {
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 14px;
}

.feedback-section button {
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #353740;
}

.feedback-section button svg {
  display: block;
}

.feedback-section button:hover:not(:disabled) {
  background: #f7f7f8;
  border-color: #9ca3af;
}

.feedback-section button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Latency Display Styling */
.latency-display {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: #8e8ea0;
  text-align: center;
  border-top: 1px solid #e5e5e5;
  background: #f9f9f9;
}

/* Searching bubble */
.searching-bubble {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 20px 0 20px;
  margin: 0;
}

.searching-bubble .message-content {
  background: none;
  padding: 0;
  font-size: 13px;
  color: #8e8ea0;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 85%;
  text-align: right;
}

.searching-bubble .searching-dots {
  display: inline-flex;
  gap: 3px;
}

.searching-bubble .searching-dots span {
  width: 3px;
  height: 3px;
  background-color: #8e8ea0;
  border-radius: 50%;
  display: inline-block;
  animation: searching-pulse 1.4s infinite ease-in-out;
}

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

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

@keyframes searching-pulse {

  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 768px) {
  .searching-bubble .message-content {
    max-width: 90%;
  }
}

.better-answer-form {
  display: none;
  flex: 1;
  gap: 0.5rem;
  margin-left: 0.5rem;
}

.better-answer-form.active {
  display: flex;
}

.better-answer {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 14px;
  resize: none;
}

.feedback-thankyou {
  color: #10a37f;
  font-size: 14px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca3af;
  animation: typing 1.4s infinite;
}

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

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {

  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }

  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .chat-wrapper {
    height: calc(100vh - 150px);
    border-radius: 0;
  }

  .user-message,
  .bot-message {
    padding: 1rem 0.75rem;
  }

  .user-message .message-content {
    max-width: 90%;
  }

}

/* PDF Modal Styling */
.pdf-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.pdf-modal-content {
  position: relative;
  width: 95%;
  height: 95%;
  max-width: 1400px;
  background: #ffffff;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 1001;
}

.pdf-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e5e5e5;
  background: #f7f7f8;
  border-radius: 8px 8px 0 0;
}

.pdf-modal-header h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #353740;
}

.pdf-modal-close {
  background: transparent;
  border: none;
  font-size: 2rem;
  line-height: 1;
  color: #8e8ea0;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.pdf-modal-close:hover {
  background: #e5e5e5;
  color: #353740;
}

.pdf-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.pdf-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #e5e5e5;
  background: #f7f7f8;
  flex-wrap: wrap;
}

.pdf-controls button {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.pdf-controls button:hover:not(:disabled) {
  background: #f7f7f8;
  border-color: #9ca3af;
}

.pdf-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pdf-controls #pdf-page-info {
  font-size: 14px;
  color: #353740;
  min-width: 100px;
  text-align: center;
}

.pdf-controls #pdf-zoom-level {
  font-size: 14px;
  color: #353740;
  min-width: 50px;
  text-align: center;
}

.pdf-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #525252;
  padding: 1rem;
}

.pdf-container canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pdf-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #353740;
  display: none;
}

.pdf-loading.show {
  display: block;
}

/* Section link styling */
.section-link {
  color: #10a37f;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.2s;
}

.section-link:hover {
  color: #0d8f6e;
}