/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #F6F8FA;
  color: #333;
  line-height: 1.6;
}

/* Screen 1: Welcome Screen */
.welcome-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: #F6F8FA;
}

.welcome-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-bottom: 60px;
  text-align: center;
  gap: 16px;
}

.chat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.welcome-header h1 {
  font-size: 2.25rem;
  font-weight: 400;
  color: #1f2937;
  margin: 0;
  line-height: 1.2;
}

.welcome-form {
  width: 100%;
  max-width: 600px;
}

.input-container {
  position: relative;
  background: white;
  border: 2px solid #e1e8ed;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message-input {
  width: 100%;
  min-height: 120px;
  border: none;
  outline: none;
  font-size: 1rem;
  color: #374151;
  background: transparent;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
}

.message-input::placeholder {
  color: #9ca3af;
}

.send-button {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: #5661F6;
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  box-shadow: 0 2px 8px rgba(86, 97, 246, 0.3);
}

.send-button:hover {
  background: #4c56e0;
}

.send-button:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  box-shadow: none;
}

.send-button svg {
  width: 16px;
  height: 16px;
  display: block;
  margin: 0;
}

.send-button img {
  width: 16px;
  height: 16px;
  display: block;
  margin: 0;
  object-fit: contain;
}

/* Screen 2: Conversation Screen */
.conversation-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #F6F8FA;
}

/* Header */
.conversation-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 20px 24px;
  background: #F6F8FA;
}

.new-conversation-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #5661F6;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.new-conversation-btn:hover {
  background: #f0f1ff;
  text-decoration: none;
}

/* Messages Area */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #F6F8FA;
}

.message {
  display: flex;
  padding: 24px 0;
  align-items: baseline;
  max-width: 100%;
  position: relative;
}

.message:not(:last-child)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 1px;
  background-color: #5661F6;
}

.message:last-child {
  /* No separator for last message */
}

.message-avatar {
  margin-right: 12px;
  flex-shrink: 0;
  margin-top: 0;
  align-self: baseline;
}

.message-content {
  flex: 1;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  border: none;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #374151;
  max-width: none;
}

/* Markdown formatting in messages */
.message-content p {
  margin: 0 0 12px 0;
}

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

.message-content strong {
  font-weight: 600;
  color: #1f2937;
}

.message-content em {
  font-style: italic;
}

.message-content ol, .message-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

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

.message-content h1, .message-content h2, .message-content h3, 
.message-content h4, .message-content h5, .message-content h6 {
  font-weight: 600;
  color: #1f2937;
  margin: 16px 0 8px 0;
}

.message-content h1:first-child, .message-content h2:first-child, 
.message-content h3:first-child, .message-content h4:first-child, 
.message-content h5:first-child, .message-content h6:first-child {
  margin-top: 0;
}

.message-content code {
  background: #f3f4f6;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875em;
}

.message-content pre {
  background: #f3f4f6;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 12px 0;
}

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

.user-message {
  flex-direction: row;
}

.user-message .message-avatar {
  margin-right: 12px;
  margin-left: 0;
  align-self: baseline;
}

.user-message .message-content {
  background: transparent;
  color: #374151;
}

.assistant-message .message-content {
  background: transparent;
  color: #374151;
}

/* Typing indicator */
.typing-indicator {
  opacity: 0.7;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-indicator .typing-dots span {
  width: 8px;
  height: 8px;
  background: #5661F6 !important;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Input area */
.input-area {
  background: #F6F8FA;
  padding: 24px;
}

.chat-form .input-container {
  position: relative;
  background: white;
  border: 2px solid #e1e8ed;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chat-form .message-input {
  width: 100%;
  min-height: 120px;
  border: none;
  outline: none;
  font-size: 1rem;
  color: #374151;
  background: transparent;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
}

.chat-form .message-input::placeholder {
  color: #9ca3af;
}

.chat-form .send-button {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: #5661F6;
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  box-shadow: 0 2px 8px rgba(86, 97, 246, 0.3);
}

.chat-form .send-button:hover {
  background: #4c56e0;
}

.chat-form .send-button:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  box-shadow: none;
}

.chat-form .send-button svg {
  width: 16px;
  height: 16px;
  display: block;
  margin: 0;
}

/* Error message styles */
.error-message .message-content {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 16px;
}

.error-message .message-content p {
  color: #dc2626;
  margin-bottom: 12px;
}

.retry-button {
  background: #5661F6;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.retry-button:hover {
  background: #4c56e0;
}

.retry-button:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* Responsive design */
@media (max-width: 768px) {
  .welcome-header h1 {
    font-size: 1.875rem;
  }
  
  .welcome-container {
    padding: 15px;
  }
  
  .welcome-header {
    margin-bottom: 40px;
  }
  
  .input-container {
    padding: 16px;
  }
  
  .conversation-header {
    padding: 16px 20px;
  }
  
  .new-conversation-btn {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
  
  .messages-area {
    padding: 20px 16px;
  }
  
  .message {
    margin-bottom: 20px;
  }
  
  .message-content {
    padding: 14px 16px;
    font-size: 0.9rem;
  }
  
  .input-area {
    padding: 20px 16px;
  }
  
  .chat-form .send-button {
    bottom: 16px;
    right: 16px;
  }
}
