/* ========== Messages Container ========== */
.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100%;
}

/* ========== Message Bubble ========== */
.message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: msgFadeIn 0.35s ease forwards;
  opacity: 0;
}

.message.no-animate {
  animation: none;
  opacity: 1;
}

.message.bot {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Mini avatar in chat */
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.user .msg-avatar {
  display: none;
}

/* Bubble */
.bubble {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  line-height: 1.65;
  font-size: 15px;
  word-break: break-word;
  position: relative;
}

.message.bot .bubble {
  background: var(--bot-bubble);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.message.user .bubble {
  background: linear-gradient(135deg, var(--user-bubble-start), var(--user-bubble-end));
  border-top-right-radius: 4px;
  color: #fff;
}

/* Timestamp */
.msg-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 0 4px;
}

.message.bot .msg-time {
  text-align: left;
}

.message.user .msg-time {
  text-align: right;
}

/* ========== Typing Indicator ========== */
.typing-indicator {
  display: none;
  align-self: flex-start;
  gap: 10px;
  max-width: 85%;
  animation: msgFadeIn 0.3s ease forwards;
}

.typing-indicator.active {
  display: flex;
}

.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: var(--bot-bubble);
  border-radius: var(--radius-sm);
  border-top-left-radius: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ========== Message Animation ========== */
@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== Markdown Content Styles ========== */
.bubble p {
  margin: 0 0 8px 0;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble strong {
  font-weight: 600;
  color: inherit;
}

.bubble em {
  font-style: italic;
}

.bubble code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: "Fira Code", "Consolas", monospace;
  font-size: 12px;
}

.bubble pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  overflow-x: auto;
  margin: 8px 0;
}

.bubble pre code {
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}

.bubble ul, .bubble ol {
  padding-left: 20px;
  margin: 6px 0;
}

.bubble li {
  margin: 2px 0;
}

.bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
}

.bubble a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ========== Welcome Message ========== */
/* ========== Quick Topics ========== */
.quick-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0 8px 46px;
  animation: msgFadeIn 0.4s ease forwards;
  opacity: 0;
}

.topic-btn {
  padding: 10px 18px;
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 20px;
  background: rgba(167, 139, 250, 0.06);
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
  user-select: none;
}

.topic-btn:active {
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.45);
  transform: translateY(0);
}

/* ========== Welcome Divider ========== */
.welcome-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
  color: var(--text-dim);
  font-size: 11px;
}

.welcome-divider::before,
.welcome-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--card-border);
}

/* ========== Hover: Mouse devices only ========== */
@media (hover: hover) and (pointer: fine) {
  .topic-btn:hover {
    background: rgba(167, 139, 250, 0.15);
    border-color: rgba(167, 139, 250, 0.45);
    transform: translateY(-1px);
  }
}
