/* chat.css
 * Message bubbles, typing indicator, conversation list items.
 * INcibe corporate style — Rojo #E73137, Amarillo #FFDD00.
 */

/* ── Conversation list items ───────────────────────────── */

#conversation-list {
  list-style: none;
  padding: 0 var(--space-2);
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
  gap: var(--space-2);
}

.conversation-item:hover,
.conversation-item:focus-visible {
  background: var(--color-surface-hover);
  outline: none;
}

.conversation-item--active {
  background: var(--color-incibe-red-muted) !important;
  /* Red left stripe indicator */
  border-left: 3px solid var(--color-incibe-red);
}

.conversation-item--active .conversation-item__title {
  color: var(--color-incibe-red-light) !important;
}

.conversation-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversation-item__title {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item__meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item__delete {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast),
              background var(--transition-fast);
  line-height: 1;
}

.conversation-item:hover .conversation-item__delete,
.conversation-item--active .conversation-item__delete { opacity: 1; }

.conversation-item__delete:hover {
  color: var(--color-incibe-red);
  background: var(--color-incibe-red-muted);
}

.conversation-list__empty,
.conversation-list__loading {
  list-style: none;
  padding: var(--space-6) var(--space-4);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ── Message bubbles ───────────────────────────────────── */

.messages__empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-base);
  padding: var(--space-12);
}

.message {
  display: flex;
  gap: var(--space-3);
  max-width: var(--chat-max-width);
  margin: 0 auto var(--space-5);
  animation: messageFadeIn 0.2s ease both;
}

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

/* User message — right-aligned */
.message--user { flex-direction: row-reverse; }

.message__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* User avatar: red circle */
.message--user .message__avatar {
  background: var(--color-incibe-red);
  color: #ffffff;
}

/* AI avatar: yellow circle with dark icon */
.message--ai .message__avatar {
  background: var(--color-incibe-yellow);
  color: var(--color-text-on-yellow);
  box-shadow: var(--shadow-sm);
}

.message__content {
  max-width: 90%; /* Much wider blocks for long AI text and code */
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.message--user .message__content { align-items: flex-end; }
.message--ai   .message__content { align-items: flex-start; }

.message__role {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}

.message__text {
  padding: var(--space-5) var(--space-6); /* Even larger padding as requested */
  border-radius: var(--radius-lg);
  line-height: 1.65;
  font-size: var(--font-size-base);
  word-break: break-word;
}

.message--user .message__text {
  background: var(--color-bubble-user-bg);
  color: var(--color-bubble-user-text);
  border: 2px solid var(--color-incibe-red); /* Thicker border for clarity in light theme */
  border-bottom-right-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.message--ai .message__text {
  background: var(--color-bubble-ai-bg);
  color: var(--color-bubble-ai-text);
  border: 1px solid var(--color-incibe-yellow-dark); /* Subtle yellow border */
  border-bottom-left-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* Thin yellow top border on AI messages — INcibe accent */
.message--ai .message__text {
  border-top: 3px solid var(--color-incibe-yellow);
}

/* Code blocks inside messages */
.message__text pre {
  background: #282c34; /* Dark background for code blocks looks better even in light themes */
  color: #abb2bf;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  margin: var(--space-2) 0;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-md);
}

.message__text code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(0,0,0,0.06); /* Light grey for inline code */
  color: var(--color-incibe-red-dark);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
}

.message__text pre code { 
  background: transparent; 
  color: inherit;
  padding: 0; 
}

/* ── Typing indicator ──────────────────────────────────── */

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bubble-ai-bg);
  border: 1px solid var(--color-border);
  border-top: 2px solid var(--color-incibe-yellow);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-sm);
  min-width: 64px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--color-incibe-red);
  border-radius: var(--radius-full);
  animation: typingBounce 1.2s infinite;
  opacity: 0.8;
}

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.8; }
  40%            { transform: translateY(-6px); opacity: 1; }
}
