/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ===== Top Bar ===== */
.topbar {
  height: 42px;
  background: #111220;
  border-bottom: 1px solid #1f2037;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 180px;
  background: #111220;
  border-right: 1px solid #1f2037;
}
.nav-link {
  display: flex;
  align-items: center;
  padding: 7px 14px;
  font-size: 13px;
  color: #6b7280;
  text-decoration: none;
  transition: all 0.12s;
}
.nav-link:hover {
  color: #e5e7eb;
  background: #1a1b2e;
}
.nav-link.active {
  color: #e5e7eb;
  background: #1a1b2e;
  border-right: 2px solid #818cf8;
}
.nav-icon {
  width: 18px;
  margin-right: 8px;
  text-align: center;
  font-size: 13px;
}
.nav-divider {
  height: 1px;
  background: #1f2037;
  margin: 4px 14px;
}

/* ===== Global Session Selector ===== */
.select-sm {
  padding: 3px 8px;
  background: #1a1b2e;
  border: 1px solid #374151;
  border-radius: 4px;
  font-size: 12px;
  color: #e5e7eb;
  outline: none;
  font-family: inherit;
  cursor: pointer;
  max-width: 220px;
}
.select-sm:focus { border-color: #818cf8; }

.session-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #374151;
}
.dot-ready { background: #34d399; }
.dot-busy { background: #fbbf24; animation: pulse-dot 1.2s ease-in-out infinite; }
.dot-error { background: #f87171; }
.dot-creating { background: #818cf8; animation: pulse-dot 1.2s ease-in-out infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== Page layout ===== */
.page-container {
  height: 100%;
}
.page-container.hidden {
  display: none !important;
}
.page-full {
  height: calc(100vh - 42px - 40px);
}

/* ===== Chat ===== */
.chat-user {
  background: #1e1b4b;
  border: 1px solid #312e81;
  border-radius: 10px 10px 4px 10px;
}
.chat-assistant {
  background: #151625;
  border: 1px solid #1f2037;
  border-radius: 10px 10px 10px 4px;
}
.streaming-cursor::after {
  content: '\25AE';
  animation: blink 0.8s step-end infinite;
  color: #818cf8;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

.chat-code {
  background: #0d0e18;
  border: 1px solid #1f2037;
  border-radius: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
  margin: 6px 0;
}
.chat-input-area {
  background: #111220;
  border: 1px solid #1f2037;
  border-radius: 8px;
  padding: 10px;
}

/* Drop zone highlight */
.chat-drop-zone.chat-drop-active {
  outline: 2px dashed #818cf8;
  outline-offset: -2px;
  background: #1e1b4b22;
}

/* ===== CLI error cards ===== */
.cli-error-card {
  background: #1c1017;
  border: 1px solid #991b1b;
  border-radius: 6px;
  padding: 12px 14px;
  margin: 6px 0;
}
.cli-error-icon {
  font-size: 20px;
  margin-bottom: 4px;
}
.cli-error-title {
  font-size: 13px;
  font-weight: 700;
  color: #fca5a5;
  margin-bottom: 4px;
}
.cli-error-msg {
  font-size: 11px;
  color: #d4a0a0;
  line-height: 1.4;
  word-break: break-word;
}
.cli-error-reset {
  margin-top: 6px;
  font-size: 12px;
  color: #fbbf24;
}
.cli-error-countdown {
  margin-top: 4px;
  font-size: 12px;
  color: #9ca3af;
}
.cli-error-hint {
  margin-top: 6px;
  font-size: 11px;
  color: #6b7280;
}

/* ===== Processes panel in chat ===== */
.procs-panel {
  background: #0d0e18;
  border: 1px solid #1f2037;
  border-radius: 6px;
  padding: 8px 10px;
  max-height: 180px;
  overflow: auto;
}
.procs-table {
  width: 100%;
  border-collapse: collapse;
}
.procs-table th {
  text-align: left;
  padding: 2px 6px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4b5563;
  border-bottom: 1px solid #1f2037;
}
.procs-table td {
  padding: 2px 6px;
  font-size: 11px;
  border-bottom: 1px solid #111220;
  white-space: nowrap;
}
.procs-table td:nth-child(4) {
  white-space: normal;
  word-break: break-all;
  max-width: 300px;
}
.procs-table tr:hover td { background: #151625; }

/* ===== Tool cards in chat ===== */
.tool-card {
  background: #0d0e18;
  border: 1px solid #1f2037;
  border-radius: 5px;
  padding: 6px 10px;
  margin: 5px 0;
  font-size: 12px;
}
.tool-card.tool-running {
  border-left: 3px solid #818cf8;
}
.tool-card.tool-done {
  border-left: 3px solid #34d399;
}
.tool-header {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
.tool-icon { font-size: 12px; }
.tool-name { font-weight: 600; color: #a5b4fc; font-size: 11px; }
.tool-spinner {
  width: 6px; height: 6px;
  background: #818cf8;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 1s ease-in-out infinite;
}
.tool-card.tool-error {
  border-left: 3px solid #f87171;
}
.tool-done .tool-spinner { display: none; }
.turn-sep {
  height: 1px;
  background: #1f2037;
  margin: 8px 0;
}
.tool-input {
  color: #9ca3af;
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
}
.tool-cmd {
  background: #111220;
  border-radius: 3px;
  padding: 3px 6px;
  color: #d1d5db;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 11px;
}
.tool-output {
  background: #111220;
  border-radius: 3px;
  padding: 4px 6px;
  margin-top: 4px;
  color: #6b7280;
  font-size: 10px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow: auto;
}
.tool-error .tool-output {
  color: #f87171;
}

/* ===== Terminal (xterm.js) ===== */
#term-container {
  border: 1px solid #1f2037;
}
#term-container .xterm {
  padding: 6px;
}
#term-container .xterm-viewport {
  overflow-y: auto !important;
}

/* ===== File Explorer ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: #6b7280;
  flex-wrap: wrap;
}
.breadcrumb-item {
  cursor: pointer;
  color: #818cf8;
  padding: 2px 4px;
  border-radius: 3px;
}
.breadcrumb-item:hover { background: #1a1b2e; color: #a5b4fc; }
.breadcrumb-sep { color: #374151; }

.file-viewer {
  background: #0d0e18;
  border: 1px solid #1f2037;
  border-radius: 6px;
  padding: 10px;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
}
.file-viewer-content {
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  color: #d1d5db;
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
  margin: 0;
}
.file-editor-content {
  width: 100%;
  flex: 1;
  min-height: 180px;
  background: #111220;
  border: 1px solid #374151;
  border-radius: 4px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #e5e7eb;
  font-family: monospace;
  resize: vertical;
  outline: none;
}
.file-editor-content:focus { border-color: #818cf8; }

.file-icon { font-size: 14px; text-align: center; }
.file-icon-folder { color: #fbbf24; }
.file-icon-file { color: #6b7280; }

.entry-actions { white-space: nowrap; }
.action-btn {
  background: none;
  border: 1px solid transparent;
  color: #4b5563;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 13px;
  transition: all 0.12s;
}
.action-btn:hover { color: #e5e7eb; background: #1a1b2e; border-color: #374151; }
.action-delete:hover { color: #fca5a5; background: #7f1d1d22; border-color: #991b1b; }

/* ===== Logs ===== */
.log-INFO  { color: #60a5fa; }
.log-WARN  { color: #fbbf24; }
.log-ERROR { color: #f87171; }
.log-entry {
  font-size: 11px;
  line-height: 1.5;
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== Tables ===== */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4b5563;
  border-bottom: 1px solid #1f2037;
}
.admin-table td {
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid #111220;
}
.admin-table tr:hover td { background: #151625; }
.session-active-row td { background: #1e1b4b22; }

/* ===== Stats ===== */
.stat-card {
  background: #111220;
  border: 1px solid #1f2037;
  border-radius: 6px;
  padding: 14px 18px;
}
.stat-value { font-size: 24px; font-weight: 700; color: #fff; }
.stat-label { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* ===== Usage Limits ===== */
.usage-bar-wrap {
  background: #1a1b2e;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease, background .4s ease;
}
.usage-bar-fill.green  { background: #22c55e; }
.usage-bar-fill.yellow { background: #eab308; }
.usage-bar-fill.red    { background: #ef4444; }
.usage-reset {
  font-size: 10px;
  color: #555;
  margin-top: 3px;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 500;
}
.badge-ready    { background: #065f46; color: #6ee7b7; }
.badge-busy     { background: #78350f; color: #fcd34d; }
.badge-error    { background: #7f1d1d; color: #fca5a5; }
.badge-creating { background: #1e1b4b; color: #a5b4fc; }

/* Source badges */
.badge-source-admin  { background: #1e1b4b; color: #a5b4fc; }
.badge-source-api    { background: #065f46; color: #6ee7b7; }
.badge-source-system { background: #374151; color: #9ca3af; }

/* HTTP Method badges */
.method-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  font-family: monospace;
  letter-spacing: 0.03em;
}
.method-GET    { background: #064e3b; color: #6ee7b7; }
.method-POST   { background: #1e1b4b; color: #a5b4fc; }
.method-PUT    { background: #78350f; color: #fcd34d; }
.method-DELETE { background: #7f1d1d; color: #fca5a5; }

/* ===== Buttons ===== */
.btn {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.12s;
  cursor: pointer;
  border: none;
}
.btn-sm { padding: 3px 8px; font-size: 11px; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-danger  { background: #991b1b; color: #fca5a5; }
.btn-danger:hover  { background: #7f1d1d; }
.btn-ghost   { background: transparent; color: #6b7280; border: 1px solid #1f2037; }
.btn-ghost:hover   { background: #1a1b2e; color: #e5e7eb; border-color: #374151; }

/* ===== Form inputs ===== */
.input {
  padding: 5px 10px;
  background: #151625;
  border: 1px solid #1f2037;
  border-radius: 5px;
  font-size: 12px;
  color: #e5e7eb;
  outline: none;
  font-family: inherit;
}
.input:focus { border-color: #818cf8; }
.input::placeholder { color: #374151; }

.select {
  padding: 5px 10px;
  background: #151625;
  border: 1px solid #1f2037;
  border-radius: 5px;
  font-size: 12px;
  color: #e5e7eb;
  outline: none;
  font-family: inherit;
  cursor: pointer;
}
.select:focus { border-color: #818cf8; }

/* ===== MCP env editor ===== */
.env-textarea {
  resize: vertical;
  min-height: 38px;
  line-height: 1.5;
  font-family: inherit;
}
.env-var-badge {
  display: inline-block;
  background: #1e1b4b;
  border: 1px solid #312e81;
  border-radius: 3px;
  padding: 0 5px;
  font-size: 10px;
  color: #a5b4fc;
}

/* ===== Key reveal ===== */
.key-reveal {
  background: #0d0e18;
  border: 1px solid #065f46;
  border-radius: 5px;
  padding: 10px;
  font-size: 12px;
  word-break: break-all;
  color: #6ee7b7;
}

/* ===== Toasts ===== */
.toast {
  padding: 8px 14px;
  border-radius: 5px;
  font-size: 12px;
  animation: slideIn 0.2s ease-out;
  max-width: 320px;
  word-break: break-word;
}
.toast-success { background: #065f46; border: 1px solid #047857; color: #a7f3d0; }
.toast-error   { background: #7f1d1d; border: 1px solid #991b1b; color: #fca5a5; }
.toast-info    { background: #1e1b4b; border: 1px solid #312e81; color: #c7d2fe; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Docs page ===== */
.docs-body {
  line-height: 1.6;
  font-size: 13px;
}
.docs-h1 { font-size: 20px; font-weight: 700; color: #fff; margin: 20px 0 10px; }
.docs-h2 { font-size: 16px; font-weight: 700; color: #e5e7eb; margin: 18px 0 8px; padding-top: 12px; border-top: 1px solid #1f2037; }
.docs-h3 { font-size: 13px; font-weight: 700; color: #d1d5db; margin: 12px 0 6px; }
.docs-p { color: #9ca3af; margin: 3px 0; }
.docs-spacer { height: 6px; }
.docs-hr { border: none; border-top: 1px solid #1f2037; margin: 12px 0; }
.docs-li { color: #9ca3af; padding-left: 14px; position: relative; margin: 2px 0; }
.docs-li::before { content: "\2022"; position: absolute; left: 2px; color: #4b5563; }
.docs-code {
  background: #0d0e18;
  border: 1px solid #1f2037;
  border-radius: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  font-size: 11px;
  line-height: 1.5;
  color: #d1d5db;
  margin: 6px 0;
  white-space: pre;
}
.docs-inline-code {
  background: #1a1b2e;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: #a5b4fc;
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
.docs-table th {
  text-align: left;
  padding: 4px 8px;
  font-size: 11px;
  color: #d1d5db;
  border-bottom: 1px solid #374151;
  background: #111220;
}
.docs-table td {
  padding: 4px 8px;
  font-size: 11px;
  color: #9ca3af;
  border-bottom: 1px solid #1f2037;
}
