/* ============================================
   Mr. Pronoia — Chat Interface
   The main experience. Centered. Clean.
   ============================================ */

.chat-container {
  max-width: 720px;
  margin: 0 auto;
}

.chat-messages {
  position: relative;
  min-height: 280px;
  max-height: 55vh;
  overflow-y: auto;
  border: 1px solid var(--mr-border, rgba(255, 255, 255, 0.06));
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 0.75rem;
  background: var(--mr-surface, #111113);
}

/* Welcome title — centered in empty chat */
.chat-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: inherit;
  font-family: 'Special Elite', 'Courier New', Courier, monospace;
  font-size: 2em;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--mr-text-muted, #71717a);
}

.chat-message {
  margin-bottom: 1.2rem;
  line-height: 1.65;
  animation: msgIn 0.25s ease;
}

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

/* User messages */
.chat-message.user {
  text-align: right;
}

.chat-message.user .bubble {
  display: inline-block;
  background: var(--md-default-fg-color, #fafafa);
  color: var(--md-default-bg-color, #09090b);
  padding: 0.55rem 1rem;
  border-radius: 16px 16px 4px 16px;
  max-width: 75%;
  text-align: left;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  font-size: 0.88em;
  font-weight: 400;
  opacity: 0.7;
}

/* Assistant messages — full-width like ChatGPT */
.chat-message.assistant .bubble {
  display: block;
  background: transparent;
  border: none;
  padding: 0.4rem 0;
  text-align: left;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  font-size: 0.88em;
}

.chat-message.assistant .bubble p {
  margin: 0.4rem 0;
}

.chat-message.assistant .bubble p:first-child { margin-top: 0; }
.chat-message.assistant .bubble p:last-child { margin-bottom: 0; }

/* Sources — minimal pills */
.chat-message .source-pill {
  display: inline-block;
  font-size: 0.72em;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--mr-glow-border, rgba(59, 130, 246, 0.15));
  color: var(--mr-glow, #3b82f6);
  padding: 0.1em 0.55em;
  border-radius: 4px;
  margin: 0.2em 0.25em 0.2em 0;
  text-decoration: none;
  transition: background 0.15s;
}

.chat-message .source-pill:hover {
  background: var(--mr-glow-subtle, rgba(59, 130, 246, 0.08));
}

/* Input row */
.chat-input-row {
  display: flex;
  gap: 0.5rem;
}

.chat-input {
  flex: 1;
  padding: 0.7rem 1rem;
  border: 1px solid var(--mr-border, rgba(255, 255, 255, 0.06));
  border-radius: 10px;
  background: var(--mr-surface, #111113);
  color: var(--md-default-fg-color);
  font-size: 0.88rem;
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
  outline: none;
  border-color: var(--mr-border-hover, rgba(255, 255, 255, 0.12));
  box-shadow: none;
}

.chat-input::placeholder {
  color: var(--mr-text-muted, #71717a);
}

.chat-send {
  padding: 0.7rem 1.4rem;
  background: var(--md-default-fg-color, #fafafa);
  color: var(--md-default-bg-color, #09090b);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: 'Special Elite', 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.chat-send:hover {
  opacity: 0.85;
}

.chat-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.chat-status {
  text-align: center;
  color: var(--mr-text-muted, #71717a);
  font-size: 0.78rem;
  margin-top: 0.4rem;
  font-family: 'JetBrains Mono', monospace;
}

/* Typing indicator */
.typing-indicator {
  display: inline-block;
}

.typing-indicator span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mr-glow, #3b82f6);
  margin: 0 2px;
  animation: pulse 1.2s infinite;
}

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

@keyframes pulse {
  0%, 60%, 100% { opacity: 0.2; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.3); }
}

/* Export button and menu */
.chat-export {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--mr-surface-2, #18181b);
  border: 1px solid var(--mr-border, rgba(255, 255, 255, 0.06));
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--mr-text-muted, #71717a);
  transition: border-color 0.15s, color 0.15s;
  z-index: 10;
}

.chat-export:hover {
  border-color: var(--mr-glow, #3b82f6);
  color: var(--mr-glow, #3b82f6);
}

.chat-export.visible {
  display: flex;
}

.export-menu {
  position: absolute;
  top: 2.5rem;
  right: 0.75rem;
  background: var(--mr-surface-2, #18181b);
  border: 1px solid var(--mr-border, rgba(255, 255, 255, 0.06));
  border-radius: 8px;
  padding: 0.35rem;
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 11;
  min-width: 160px;
  animation: menuIn 0.15s ease;
}

.export-menu.open {
  display: flex;
}

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

.export-option {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--md-default-fg-color);
  font-size: 0.82rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.export-option:hover {
  background: var(--mr-glow-subtle, rgba(59, 130, 246, 0.08));
}

.export-option.loading {
  opacity: 0.5;
  cursor: not-allowed;
}
