/* ── Superbot Dashboard — Clean Rebuild ── */

:root {
  --bg: #0f0f14;
  --bg-card: #1a1a24;
  --bg-input: #14141c;
  --border: #252535;
  --text: #e4e4ec;
  --text-dim: #6e6e84;
  --accent: #7c6bf0;
  --accent-dim: rgba(124, 107, 240, 0.12);
  --accent-border: rgba(124, 107, 240, 0.3);
  --green: #34d399;
  --green-dim: rgba(52, 211, 153, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'SF Pro', system-ui, sans-serif;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }


/* ════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════ */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  text-align: center;
  width: 100%;
  max-width: 300px;
}

.login-mascot {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: contain;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 24px rgba(124, 107, 240, 0.4));
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 28px;
  letter-spacing: -0.3px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#login-form input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

#login-form input:focus {
  border-color: var(--accent);
}

#login-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

#login-form button:hover { opacity: 0.88; }

.error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
}


/* ════════════════════════════════════════
   HEADER
   ════════════════════════════════════════ */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-mascot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

header h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.conn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.conn-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}

.conn-dot.offline {
  background: var(--red);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.4);
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: color 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-dim);
}


/* ════════════════════════════════════════
   TABS
   ════════════════════════════════════════ */

.tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 53px;
  z-index: 49;
}

.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
  padding: 24px;
  max-width: 960px;
  margin: 0 auto;
}

.tab-content.active { display: block; }


/* ════════════════════════════════════════
   LIVE TAB — Stats Row
   ════════════════════════════════════════ */

.stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stat-chip {
  flex: 1 1 100px;
  min-width: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-chip-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-chip-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
}


/* ════════════════════════════════════════
   LIVE TAB — Activity Feed
   ════════════════════════════════════════ */

.feed-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.feed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.7); }
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 520px;
  overflow-y: auto;
}

.activity-feed::-webkit-scrollbar { width: 4px; }
.activity-feed::-webkit-scrollbar-track { background: transparent; }
.activity-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.feed-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
  overflow: hidden;
}

.activity-item:hover {
  border-color: var(--accent-border);
}

.activity-item.fail {
  border-left: 2px solid var(--orange);
}

.activity-item.new-item {
  animation: slideIn 0.25s ease-out;
}

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

/* Tier badges */
.tier-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-family: var(--mono);
}

.tier-3b     { background: var(--blue-dim);   color: var(--blue); }
.tier-moe    { background: var(--green-dim);  color: var(--green); }
.tier-sonnet { background: var(--accent-dim); color: var(--accent); }
.tier-opus   { background: var(--amber-dim);  color: var(--amber); }

.activity-type {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.activity-query {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.activity-meta {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.activity-elapsed {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.activity-score {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

.score-pass { background: var(--green-dim); color: var(--green); }
.score-fail { background: var(--orange-dim); color: var(--orange); }


/* ════════════════════════════════════════
   AGENTS TAB
   ════════════════════════════════════════ */

.agents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}

.agent-card:hover {
  border-color: var(--accent-border);
}

.agent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.agent-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.agent-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.agent-tool {
  font-size: 10px;
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}

.agent-tool.dim {
  border-style: dashed;
}

.agent-stats {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-dim);
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.agent-stats strong {
  color: var(--text);
  font-weight: 600;
}

.agent-source {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  opacity: 0.6;
}


/* ════════════════════════════════════════
   MEMORY TAB
   ════════════════════════════════════════ */

.memory-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.memory-search-wrap {
  flex: 1;
}

.memory-search {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.memory-search:focus {
  border-color: var(--accent);
}

.fact-count {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.add-fact-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.add-fact-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.add-fact-input:focus { border-color: var(--accent); }

.add-fact-source {
  width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.add-fact-source:focus { border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

.facts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fact-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
}

.fact-card:hover {
  border-color: var(--accent-border);
}

.fact-body {
  flex: 1;
  min-width: 0;
}

.fact-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.fact-meta {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.fact-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.fact-delete {
  flex-shrink: 0;
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}

.fact-delete:hover {
  color: var(--red);
  border-color: var(--red-dim);
}


/* ════════════════════════════════════════
   CHAT TAB
   ════════════════════════════════════════ */

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding: 4px 0;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-welcome {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.bot {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble.bot.streaming {
  border-color: var(--accent-border);
}

.chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.quick-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.quick-btn:hover {
  background: rgba(124, 107, 240, 0.22);
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input-row input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-row input:focus {
  border-color: var(--accent);
}


/* ════════════════════════════════════════
   WANDERING MASCOT
   ════════════════════════════════════════ */

#wandering-mascot {
  position: fixed;
  bottom: 14px;
  width: 36px;
  height: 36px;
  pointer-events: none;
  z-index: 100;
  opacity: 0.8;
  filter: drop-shadow(0 0 10px rgba(124, 107, 240, 0.5));
  animation:
    wander 24s ease-in-out infinite alternate,
    bob 3.5s ease-in-out infinite;
}

#wandering-mascot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

@keyframes wander {
  0%   { left: 4vw; }
  15%  { left: 22vw; }
  35%  { left: 12vw; }
  50%  { left: 48vw; }
  70%  { left: 68vw; }
  85%  { left: 42vw; }
  100% { left: 86vw; }
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-8px) rotate(2deg); }
}


/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */

@media (max-width: 640px) {
  header { padding: 12px 16px; }
  .tabs { padding: 0 16px; }
  .tab { padding: 12px 16px; font-size: 13px; }
  .tab-content { padding: 16px; }

  .stats-row { gap: 8px; }
  .stat-chip { min-width: 80px; padding: 10px 12px; }
  .stat-chip-value { font-size: 15px; }

  .add-fact-form { flex-direction: column; }
  .add-fact-source { width: 100%; }

  .chat-bubble { max-width: 90%; }
}

@media (max-width: 420px) {
  .stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .stat-chip:last-child {
    grid-column: span 2;
  }

  .memory-toolbar { flex-direction: column; align-items: stretch; }
  .fact-count { text-align: right; }
}
