/* Chat Messages Container */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 20px 40px;
  position: relative;
  z-index: 2;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) rgba(255, 255, 255, 0.03);
  width: 100%;
  min-height: 0;
  max-height: 100%;
  scroll-behavior: smooth;
}

/* Spacer to push content to bottom initially */
.chat-messages::before {
  content: '';
  flex: 1 0 auto;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  margin: 10px 0;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.1) 100%);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.15) 100%);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Message Styles */
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  animation: messageSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: auto;
  max-width: 70%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #FFFFFF 0%, #DCE1FF 100%);
  color: #1b212d;
}

.message.assistant .message-avatar {
  background: transparent;
  color: #ffffff;
  border: none;
  padding: 0;
  overflow: hidden;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-role {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.message.user .message-role {
  color: #ffffff;
}

.message.assistant .message-role {
  color: #9ca3af;
}

.message-text {
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message.user .message-text {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 18px 4px 18px 18px;
}

.message.assistant .message-text {
  border-radius: 4px 18px 18px 18px;
}

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

.loading-dot {
  width: 8px;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  animation: loadingBounce 1.4s infinite ease-in-out both;
}

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

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

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

/* Error Message */
.error-message {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 14px;
  text-align: center;
}

/* Suggestion container animations */
.chat-suggestions {
  opacity: 1;
  transform: scale(1) translateY(0);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide suggestions when messages are present */
.chat-messages.has-messages .chat-suggestions {
  opacity: 0;
  transform: scale(0.95) translateY(-20px);
  pointer-events: none;
  height: 0;
  overflow: hidden;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Center chat messages container when empty */
.chat-messages:not(.has-messages) {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.chat-messages:not(.has-messages)::before {
  display: none;
}

/* Ensure messages don't shrink */
.message {
  flex-shrink: 0;
}

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

.typing-cursor {
  color: rgba(255, 255, 255, 0.7);
  font-weight: normal;
  margin-left: 2px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .message {
    gap: 8px;
  }
  
  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .message-text {
    font-size: 14px;
    padding: 10px 14px;
  }
}

/* Markdown styling in chat messages */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4 {
  margin: 16px 0 12px 0;
  font-weight: 600;
  line-height: 1.3;
}

.message-text h1 {
  font-size: 1.8em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.message-text h2 {
  font-size: 1.4em;
  color: rgba(255, 255, 255, 0.95);
}

.message-text h3 {
  font-size: 1.2em;
  color: rgba(255, 255, 255, 0.9);
}

.message-text h4 {
  font-size: 1.1em;
  color: rgba(255, 255, 255, 0.85);
}

.message-text code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 0.9em;
  color: #e6e6e6;
}

.message-text pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
}

.message-text pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.5;
}

.message-text ul,
.message-text ol {
  margin: 12px 0;
  padding-left: 24px;
}

.message-text li {
  margin: 6px 0;
  line-height: 1.6;
}

.message-text a {
  color: #4a9eff;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.message-text a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.message-text strong {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
}

.message-text em {
  font-style: italic;
  color: rgba(255, 255, 255, 0.85);
}