/* ── Arix Chat UI — Custom Styles ─────────────────────────── */

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ── Activity Bar ──────────────────────────────────────────── */
.activity-bar {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease;
}

.activity-bar.active {
  max-height: 48px;
  opacity: 1;
  margin-bottom: 0.75rem;
}

.activity-pulse {
  background: linear-gradient(90deg, #6366f1, #818cf8, #6366f1);
  background-size: 200% 100%;
  animation: pulse-gradient 2s ease-in-out infinite;
}

@keyframes pulse-gradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ── Tool Cards ────────────────────────────────────────────── */
.tool-card {
  border: 1px solid #1e293b;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.3s ease;
  animation: card-enter 0.25s ease-out;
}

.tool-card--running {
  border-color: #6366f1;
  animation: card-enter 0.25s ease-out, border-pulse 1.5s ease-in-out infinite;
}

@keyframes border-pulse {
  0%, 100% { border-color: #6366f1; }
  50% { border-color: #818cf8; }
}

.tool-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #0f172a;
  cursor: pointer;
  user-select: none;
}

.tool-card-header:hover { background: #1e293b; }

.tool-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.tool-card-body.expanded {
  max-height: 300px;
  overflow-y: auto;
}

.tool-icon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tool-icon--running {
  background: #6366f1;
  animation: dot-pulse 1s ease-in-out infinite;
}

.tool-icon--done {
  background: #22c55e;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

/* ── Messages ──────────────────────────────────────────────── */
.message-enter {
  animation: msg-fade 0.2s ease-out;
}

@keyframes msg-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-message {
  background: rgba(99, 102, 241, 0.08);
  border-left: 2px solid rgba(99, 102, 241, 0.3);
}

.assistant-message {
  border-left: 2px solid transparent;
}

/* ── Markdown Rendered Content ─────────────────────────────── */
.prose h1 { font-size: 1.5rem; font-weight: 700; margin: 1rem 0 0.5rem; color: #f1f5f9; }
.prose h2 { font-size: 1.25rem; font-weight: 600; margin: 1rem 0 0.5rem; color: #f1f5f9; }
.prose h3 { font-size: 1.1rem; font-weight: 600; margin: 0.75rem 0 0.375rem; color: #e2e8f0; }
.prose h4, .prose h5, .prose h6 { font-size: 1rem; font-weight: 600; margin: 0.5rem 0 0.25rem; color: #e2e8f0; }
.prose p { margin: 0.5rem 0; line-height: 1.7; }
.prose a { color: #818cf8; text-decoration: underline; }
.prose a:hover { color: #a5b4fc; }
.prose strong { color: #f1f5f9; font-weight: 600; }
.prose em { font-style: italic; color: #cbd5e1; }
.prose ul, .prose ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.prose li { margin: 0.25rem 0; line-height: 1.6; }
.prose blockquote {
  border-left: 3px solid #475569;
  padding: 0.375rem 0.75rem;
  margin: 0.5rem 0;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.5);
  border-radius: 0 4px 4px 0;
}
.prose hr { border: none; border-top: 1px solid #334155; margin: 1rem 0; }

/* Inline code */
.prose .inline-code {
  background: #1e293b;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  color: #e2e8f0;
}

/* Code blocks */
.code-block {
  margin: 0.75rem 0;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid #1e293b;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0.75rem;
  background: #1e293b;
  font-size: 0.75rem;
}

.code-lang {
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.copy-btn {
  background: none;
  border: 1px solid #334155;
  color: #94a3b8;
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}

.copy-btn:hover {
  background: #334155;
  color: #e2e8f0;
}

.code-block pre {
  margin: 0;
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

.code-block code {
  font-family: 'JetBrains Mono', monospace;
  color: #e2e8f0;
}

/* Syntax highlight tokens */
.hl-keyword { color: #c084fc; }
.hl-string { color: #34d399; }
.hl-comment { color: #64748b; font-style: italic; }
.hl-number { color: #f59e0b; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0.5rem 0; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.prose th, .prose td {
  padding: 0.375rem 0.75rem;
  border: 1px solid #1e293b;
  text-align: left;
}
.prose th { background: #0f172a; color: #94a3b8; font-weight: 600; }
.prose td { color: #cbd5e1; }

/* ── Typewriter ────────────────────────────────────────────── */
.typewriter-cursor::after {
  content: '▊';
  color: #6366f1;
  animation: blink 0.8s step-end infinite;
  margin-left: 1px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ── Input Area ────────────────────────────────────────────── */
.chat-input {
  resize: none;
  scrollbar-width: thin;
  transition: border-color 0.2s;
  field-sizing: content;
}

.chat-input:focus {
  border-color: #6366f1;
  outline: none;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar-item {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  color: #94a3b8;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item:hover { background: #1e293b; color: #e2e8f0; }
.sidebar-item.active { background: #1e293b; color: #f1f5f9; }

/* ── Connection Status ─────────────────────────────────────── */
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.3s;
}

.conn-dot.connected { background: #22c55e; }
.conn-dot.connecting { background: #f59e0b; animation: dot-pulse 1s ease-in-out infinite; }
.conn-dot.disconnected { background: #ef4444; }

/* ── Login Form ────────────────────────────────────────────── */
.login-input {
  background: #0f172a;
  border: 1px solid #334155;
  color: #f1f5f9;
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.2s;
}

.login-input:focus {
  border-color: #6366f1;
  outline: none;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-desktop { display: none; }
  .main-content { margin-left: 0 !important; }
}

@media (min-width: 769px) {
  .sidebar-mobile-toggle { display: none !important; }
}

/* ── Scrollbar in messages area ────────────────────────────── */
#messages {
  scroll-behavior: smooth;
}
