/**
 * Vigthoria Message Display Fix - CSS
 * Ensures messages are visually appealing in the chat history area
 * Version: 1.0.0 (May 2025)
 */

/* Ensure messages are visible with proper spacing */
.message {
  position: relative;
  display: flex;
  margin: 10px 0;
  padding: 12px;
  border-radius: 8px;
  animation: message-fade-in 0.3s ease-out;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

@keyframes message-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Style user messages */
.user-message {
  background-color: rgba(50, 150, 200, 0.1);
  border: 1px solid rgba(50, 150, 200, 0.3);
  margin-left: 40px;
  margin-right: 10px;
  align-self: flex-end;
}

/* Style assistant messages */
.assistant-message {
  background-color: rgba(20, 220, 220, 0.1);
  border: 1px solid rgba(20, 220, 220, 0.3);
  margin-right: 40px;
  margin-left: 10px;
  align-self: flex-start;
}

/* Message icons */
.message-icon {
  flex: 0 0 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  border-radius: 50%;
}

.user-message .message-icon {
  background: rgba(50, 150, 200, 0.2);
  color: rgb(50, 150, 200);
}

.assistant-message .message-icon {
  background: rgba(20, 220, 220, 0.2);
  color: rgb(20, 220, 220);
}

/* Message content */
.message-content {
  flex: 1;
  line-height: 1.5;
  margin-right: 30px;
}

/* Timestamp */
.message-timestamp {
  position: absolute;
  bottom: 5px;
  right: 10px;
  font-size: 10px;
  opacity: 0.7;
}

/* Code blocks */
.message-content pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 5px;
  overflow-x: auto;
  margin: 8px 0;
  border-left: 3px solid #0df;
}

.message-content code {
  font-family: 'Share Tech Mono', monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 4px;
  border-radius: 3px;
}

/* Ensure chat container scrolls properly */
.chat-messages {
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 10px;
  height: calc(100% - 150px); /* Fixed height calculation to leave room for the chat form */
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Fix for empty chat */
.chat-messages:empty::before {
  content: "No messages yet. Start a conversation!";
  display: block;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  padding: 20px;
  font-style: italic;
}

/* Adjust message width on mobile */
@media (max-width: 768px) {
  .user-message {
    margin-left: 20px;
    margin-right: 5px;
  }
  
  .assistant-message {
    margin-right: 20px;
    margin-left: 5px;
  }
  
  .message-content {
    margin-right: 20px;
  }
}

/* Loading animation for assistant responses */
.assistant-message.loading .message-content:after {
  content: "";
  display: inline-block;
  width: 30px;
  height: 10px;
  background-image: linear-gradient(90deg, rgba(20, 220, 220, 0), rgba(20, 220, 220, 0.5), rgba(20, 220, 220, 0));
  background-size: 200% 100%;
  animation: loading-gradient 1.5s infinite;
  border-radius: 10px;
  margin-left: 5px;
}

/* Add chat container structure styles */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.chat-form {
  position: relative;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 1rem;
  background-color: var(--bg-secondary, #1a1a2e);
  border-top: 1px solid var(--border-primary, rgba(50, 150, 200, 0.3));
  z-index: 10; /* Ensure the form stays on top */
  height: auto;
  min-height: 150px;
}
