/* ===== CHAT MESSAGES ===== */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  overflow-y: auto;
  padding-bottom: var(--space-md);
}

/* Welcome card */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
  flex: 1;
}

.chat-welcome__icon {
  font-size: 48px;
}

.chat-welcome__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-welcome__body {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.6;
}

/* Message row */
.msg {
  display: flex;
  gap: var(--space-sm);
  max-width: 85%;
  animation: msg-in 0.25s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.msg--ai {
  align-self: flex-start;
}

.msg__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.msg__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.msg__bubble {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}

.msg--user .msg__bubble {
  background: var(--accent-blue);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.msg--ai .msg__bubble {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.msg__meta {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 0 var(--space-xs);
}

.msg--user .msg__meta {
  text-align: right;
}

/* Code blocks inside messages */
.msg__bubble code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(0, 255, 136, 0.08);
  color: var(--text-code);
  padding: 2px 6px;
  border-radius: 4px;
}

.msg__bubble pre {
  position: relative;
  margin: var(--space-sm) 0;
  padding: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.msg__bubble pre code {
  display: block;
  padding: var(--space-md);
  padding-right: 60px;
  background: var(--bg-base);
  color: var(--text-code);
  overflow-x: auto;
  white-space: pre;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.btn-copy {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  z-index: 1;
}

.btn-copy:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-copy--copied {
  color: var(--accent-green);
}

/* Typing indicator */
.msg--typing .msg__bubble {
  padding: var(--space-md) var(--space-lg);
}

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

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing-bounce 1.4s infinite ease-in-out;
}

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

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

@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Error message */
.msg--error .msg__bubble {
  background: rgba(255, 79, 79, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(255, 79, 79, 0.2);
}

/* Markdown in messages */
.msg__bubble strong {
  font-weight: 600;
  color: var(--text-primary);
}

.msg__bubble em {
  font-style: italic;
}

.msg__bubble ul,
.msg__bubble ol {
  padding-left: var(--space-lg);
  margin: var(--space-xs) 0;
}

.msg__bubble ul {
  list-style: disc;
}

.msg__bubble ol {
  list-style: decimal;
}

.msg__bubble li {
  margin: 4px 0;
}

.msg__bubble p {
  margin: var(--space-xs) 0;
}

.msg__bubble p:first-child {
  margin-top: 0;
}

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

/* Responsive */
@media (max-width: 768px) {
  .msg {
    max-width: 92%;
  }

  .chat-welcome {
    padding: var(--space-lg) var(--space-sm);
  }

  .chat-welcome__title {
    font-size: 19px;
  }
}
