/* ── Messages area ─────────────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Message bubble */

.message {
  max-width: 90%;
  padding: 12px 16px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn 0.15s ease-out;
}

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

.message.user {
  align-self: flex-end;
  background: rgba(122, 122, 254, 0.1);
  color: #030712;
  border-start-start-radius: 16px;
  border-start-end-radius: 0;
  border-end-start-radius: 16px;
  border-end-end-radius: 16px;
}

.message.agent {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  color: #030712;
  border-start-start-radius: 4px;
  border-start-end-radius: 12px;
  border-end-start-radius: 12px;
  border-end-end-radius: 12px;
}

/* Content inside agent bubbles */

.message-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-content p {
  margin: 0 0 8px;
}

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

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 16px 0 8px;
  font-weight: 600;
  line-height: 1.3;
}

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

.message-content h1 { font-size: 1.4em; }
.message-content h2 { font-size: 1.2em; }
.message-content h3 { font-size: 1.05em; }
.message-content h4 { font-size: 1em; }

.message-content code {
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
}

.message-content pre {
  background: #f3f4f6;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid #e5e7eb;
}

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

.message-content strong {
  font-weight: 600;
}

.message-content .table-scroll {
  overflow-x: auto;
  margin: 10px 0;
}

.message-content table {
  border-collapse: collapse;
  width: auto;
  font-size: 13px;
}

.message-content thead {
  background: #f3f4f6;
}

.message-content th,
.message-content td {
  border: 1px solid #e5e7eb;
  padding: 7px 12px;
  text-align: start;
}

.message-content th {
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.message-content tr:nth-child(even) {
  background: #f9fafb;
}

.message-content ul,
.message-content ol {
  margin: 6px 0;
  padding-inline-start: 24px;
}

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

.message-content blockquote {
  border-inline-start: 3px solid #d1d5db;
  margin: 8px 0;
  padding: 4px 12px;
  color: #6b7280;
}

.message-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 12px 0;
}

.message-content a {
  color: #7a7afe;
  text-decoration: none;
}

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

/* Typing dots animation */

.typing-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 4px;
  vertical-align: middle;
}

.typing-dots span {
  animation: blink 1.4s infinite both;
  font-weight: bold;
  font-size: 16px;
  line-height: 1;
  color: #7a7afe;
}

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

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}
