/* Message item base styles */
.message-item-base {
  @apply flex flex-col gap-2 p-3 w-full;
}

.message-item-header {
  @apply flex justify-between items-start gap-2.5;
}

.message-speaker {
  @apply flex flex-col gap-0.5 text-xs;
}

.message-speaker-label {
  font-weight: var(--font-weight-semibold);
}

.message-speaker-label[data-role="user"] {
  color: var(--message-user-border);
}

.message-speaker-label[data-role="assistant"] {
  color: var(--message-assistant-border);
}

.message-agent-meta {
  @apply text-xs text-[var(--message-assistant-border)];
}

.message-item-actions {
  @apply flex items-center gap-2;
}

.message-action-group {
  @apply flex items-center gap-2;
}

.message-action-button {
  @apply bg-transparent border border-[var(--border-base)] text-[var(--text-muted)] cursor-pointer px-3 py-0.5 rounded text-xs font-semibold leading-none transition-all duration-200 flex items-center justify-center h-6;
}

.message-action-button:hover {
  background-color: var(--surface-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.message-action-button:active {
  transform: scale(0.95);
}

.message-timestamp {
  @apply text-[11px] text-[var(--text-muted)];
}

.message-model-badge {
  @apply inline-flex items-center px-2 py-1 rounded-full border;
  border-color: var(--border-base);
  background-color: var(--surface-secondary);
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.message-model-badge:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background-color: var(--surface-hover);
}

.assistant-message {
  /* gap: 0.25rem; */
  padding: 0.6rem 0.65rem;
  margin-top: 0;
  margin-bottom: 0;
}

.message-item-base:not(.assistant-message) {
  margin-top: 0;
  margin-bottom: 0;
}

.message-step-start {
  background-color: var(--message-assistant-bg);
  border-left: 4px solid var(--message-assistant-border);
  margin-top: 0;
}

.message-step-finish {
  background-color: var(--message-assistant-bg);
  border-left: 4px solid var(--message-assistant-border);
  margin: 0;
}

.message-step-finish-flush {
  margin-top: -0.125rem;
}

.message-step-usage {
  @apply flex flex-wrap items-center gap-1 text-[10px] text-[var(--text-muted)];
}

.message-step-usage-chip {
  @apply inline-flex items-center rounded-full border border-[var(--border-base)] px-2 py-0.5 text-[10px];
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
}

.message-step-usage-chip::before {
  content: attr(data-label);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
  margin-right: 0.35rem;
}

.message-step-heading {
  @apply flex flex-wrap items-center gap-2 text-xs;
  color: var(--text-muted);
}



.message-queued-badge {
  @apply inline-block font-bold px-3 py-1 rounded mb-3 text-xs tracking-wide;
  background-color: var(--accent-primary);
  color: var(--text-inverted);
}

.message-error-block {
  @apply text-sm p-3 rounded border-l-[3px] my-2;
  color: var(--status-error);
  background-color: var(--message-error-bg);
  border-color: var(--status-error);
}

.compact-button {
  @apply ml-2 px-2 py-1 rounded bg-emerald-500/20 border border-emerald-500/40 text-emerald-400 text-xs font-semibold hover:bg-emerald-500/30 transition-all;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.message-generating {
  @apply text-sm italic py-2;
  color: var(--text-muted);
}

.message-sending {
  @apply text-xs italic mt-1;
  color: var(--text-muted);
}

.message-attachments {
  @apply flex flex-wrap gap-1.5 pt-2 mt-1;
  border-top: 1px solid var(--border-base);
}

.message-error {
  @apply text-xs mt-1;
  color: var(--status-error);
}

.generating-spinner {
  @apply inline-block;
  animation: pulse 1.5s ease-in-out infinite;
}

.message-streaming-indicator {
  @apply inline-flex items-center gap-2 px-3 py-2 rounded-lg border border-purple-500/50 bg-purple-500/10 mb-2;
}

.streaming-status {
  @apply inline-flex items-center gap-2 text-sm;
}

.streaming-pulse {
  @apply inline-block w-2 h-2 rounded-full bg-purple-500;
  animation: streaming-pulse 1s ease-in-out infinite;
}

@keyframes streaming-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 8px 4px rgba(168, 85, 247, 0.6);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.8);
    box-shadow: 0 0 12px 6px rgba(168, 85, 247, 0.8);
  }
}

.streaming-text {
  @apply text-purple-400 font-semibold tracking-wide;
  animation: streaming-text-pulse 1.5s ease-in-out infinite;
}

@keyframes streaming-text-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.streaming-tokens {
  @apply inline-flex items-center gap-1 px-2 py-1 rounded-full bg-purple-500/20 border border-purple-500/30;
}

.streaming-token-count {
  @apply text-purple-300 font-mono font-bold;
}

.streaming-token-label {
  @apply text-purple-400 text-xs font-medium;
}

.message-text {
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  word-wrap: break-word;
  overflow-wrap: break-word;
  color: inherit;
}

.message-text-assistant {
  white-space: normal;
}

.message-text pre {
  overflow-x: auto;
  padding: 8px;
  background-color: var(--surface-code);
  border-radius: 4px;
}

.message-error-part {
  color: var(--status-error);
  font-size: var(--font-size-base);
  padding: 8px;
  background-color: var(--message-error-bg);
  border-radius: 4px;
}

.message-reasoning {
  @apply my-2 border rounded;
  border-color: var(--border-base);
  background-color: var(--surface-secondary);
  color: inherit;
}

.reasoning-container {
  @apply p-2;
}

.reasoning-header {
  @apply flex items-center gap-1.5 text-xs cursor-pointer select-none;
  color: var(--text-muted);
}

.reasoning-header:hover {
  color: var(--accent-primary);
}

.reasoning-icon {
  @apply text-xs;
  transition: transform 150ms ease;
}

.reasoning-label {
  font-weight: var(--font-weight-medium);
}

.message-step-card {
  @apply flex flex-col gap-2 px-3 py-2;
  color: inherit;
  border-radius: 0;
}

.message-step-start {
  background-color: var(--message-assistant-bg);
  border-left: 4px solid var(--message-assistant-border);
}

.message-step-finish {
  background-color: var(--message-assistant-bg);
  border-left: 4px solid var(--message-assistant-border);
}

.message-step-heading {
  @apply flex flex-wrap items-center gap-2 text-xs;
  color: var(--text-muted);
}

.message-step-title {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  @apply flex items-center justify-between w-full;
}

.message-step-title-left {
  @apply flex items-center gap-2 text-[var(--text-muted)];
}

.message-step-title-left span:last-child {
  @apply font-medium text-[11px];
}

.message-step-time {
  @apply text-[11px] text-[var(--text-muted)] font-normal ml-auto;
}

.message-step-meta-inline {
  @apply inline-flex flex-wrap items-center gap-2 text-[11px] font-medium;
  color: var(--message-assistant-border);
}


.message-step-reason {
  @apply text-[11px] font-medium;
  color: var(--text-muted);
}

.message-step-finish-spacer {
  @apply mt-4;
}

.message-reasoning-card {
  background-color: var(--message-assistant-bg);
  border-left: 4px solid var(--message-assistant-border);
  margin-top: 0;
  margin-bottom: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.message-reasoning-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  background: none;
  border: none;
  padding: 0.25rem 0.6rem;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.message-reasoning-toggle:hover {
  background-color: var(--surface-hover);
}

.message-reasoning-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.message-reasoning-label {
  font-size: 0.75rem;
  font-weight: var(--font-weight-medium);
  color: var(--message-assistant-border);
}

.message-reasoning-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.message-reasoning-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border-base);
  border-radius: 0.375rem;
  background-color: transparent;
  color: var(--text-muted);
  font-weight: var(--font-weight-semibold);
  font-size: 0.75rem;
  line-height: 1;
  letter-spacing: 0.01em;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.message-reasoning-toggle:hover .message-reasoning-indicator {
  background-color: var(--surface-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.message-reasoning-indicator:active {
  transform: scale(0.97);
}

.message-reasoning-time {
  font-size: 11px;
  color: var(--text-muted);
}

.message-reasoning-expanded {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.message-reasoning-body {
  padding: 0;
  background-color: var(--surface-code);
  margin: 0.75rem;
}

.message-reasoning-output {
  @apply flex flex-col;
  margin: 0;
  padding: 0.75rem;
  max-height: 30rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-base) transparent;
  scrollbar-gutter: stable both-edges;
  background-color: var(--surface-code);
}

.message-reasoning-text {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-tight);
  color: var(--text-primary);
  white-space: pre-wrap;
  margin: 0;
}

