/* Chat interface styles */
.chat-container {
  max-width: 800px;
  margin: 2rem auto;
  border: 1px solid var(--color-border, #30363d);
  border-radius: var(--radius-soft, 8px);
  background: var(--color-bg-surface, #161b22);
  box-shadow: var(--shadow-md, 0 4px 8px rgba(0, 0, 0, 0.3));
}

.chat-messages {
  height: 400px;
  overflow-y: auto;
  padding: 1rem;
  background: var(--color-bg-dark, #0d1117);
  border-radius: var(--radius-soft, 8px) var(--radius-soft, 8px) 0 0;
}

.chat-message {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-soft, 8px);
  max-width: 85%;
}

.chat-message.user {
  background: var(--color-primary, #58a6ff);
  color: var(--color-bg-dark, #0d1117);
  margin-left: auto;
  text-align: right;
  font-weight: 500;
}

.chat-message.assistant {
  background: var(--color-bg-surface, #161b22);
  border: 1px solid var(--color-border, #30363d);
  color: var(--color-text, #f0f6fc);
}

.message-content {
  word-wrap: break-word;
  color: inherit;
}

.message-content strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  opacity: 0.9;
  font-weight: 600;
}

.chat-input-container {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--color-border, #30363d);
  background: var(--color-bg-surface, #161b22);
  border-radius: 0 0 var(--radius-soft, 8px) var(--radius-soft, 8px);
}

.chat-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--color-border, #30363d);
  border-radius: 4px;
  font-size: 1rem;
  background: var(--color-bg-dark, #0d1117);
  color: var(--color-text, #f0f6fc);
}

.chat-input::placeholder {
  color: var(--color-text-muted, #8b949e);
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary, #58a6ff);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.chat-send-btn {
  padding: 0.75rem 1.5rem;
  background: var(--color-primary, #58a6ff);
  color: var(--color-bg-dark, #0d1117);
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  transition: background var(--transition-fast, 0.15s);
}

.chat-send-btn:hover {
  background: var(--color-accent, #238636);
}

.chat-send-btn:disabled {
  background: var(--color-text-muted, #8b949e);
  cursor: not-allowed;
  opacity: 0.5;
}

.chat-loading {
  padding: 0.5rem 1rem;
  text-align: center;
  color: var(--color-text-muted, #8b949e);
  font-style: italic;
}

.loading-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--color-border, #30363d);
  border-top-color: var(--color-primary, #58a6ff);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--color-bg-dark, #0d1117);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border, #30363d);
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted, #8b949e);
}

.chat-messages::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Message content formatting */
.message-content p {
  margin: 0.5rem 0;
}

.message-content p:first-of-type {
  margin-top: 0.25rem;
}

.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin: 0.25rem 0;
  line-height: 1.5;
}

.message-content strong {
  color: var(--color-accent, #58a6ff);
}

.message-content em {
  color: var(--color-text-muted, #8b949e);
}

/* Rule citations highlight */
.rule-citation {
  background: rgba(88, 166, 255, 0.15);
  color: var(--color-primary, #58a6ff);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

/* Sources section */
.message-sources {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border, #30363d);
  font-size: 0.85rem;
  color: var(--color-text-muted, #8b949e);
}

.sources-label {
  font-weight: 600;
}

/* User message styling override for strong tag */
.chat-message.user .message-content strong {
  color: inherit;
}
