/* ============================================= */
/* NEXUS SHELL — Shared Design System            */
/* ============================================= */

/* ── Design Tokens ─────────────────────────── */
:root {
  --bg-0: #0a0a0c;
  --bg-1: #111114;
  --bg-2: #18181b;
  --bg-3: #1e1e22;
  --bg-elevated: #232328;
  --bg-hover: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.10);
  --border-focus: rgba(129,140,248,0.4);
  --text-0: #f4f4f5;
  --text-1: #a1a1aa;
  --text-2: #8a8a93;
  --text-3: #3f3f46;
  --accent: #818cf8;
  --accent-soft: rgba(129,140,248,0.10);
  --accent-glow: rgba(129,140,248,0.25);
  --emerald: #34d399;
  --emerald-soft: rgba(52,211,153,0.10);
  --amber: #fbbf24;
  --amber-soft: rgba(251,191,36,0.08);
  --rose: #fb7185;
  --rose-soft: rgba(251,113,133,0.08);
  --sky: #38bdf8;
  --sky-soft: rgba(56,189,248,0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --sidebar-w: 240px;
  --sidebar-collapsed-w: 60px;
  --topbar-h: 56px;
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);

  /* Provider colors */
  --claude: #cc785c;
  --claude-soft: rgba(204,120,92,0.10);
  --codex: #34d399;
  --codex-soft: rgba(52,211,153,0.10);
  --gemini: #818cf8;
  --gemini-soft: rgba(129,140,248,0.10);
  --system: #38bdf8;
  --system-soft: rgba(56,189,248,0.10);
  --danger: #fb7185;
  --danger-soft: rgba(251,113,133,0.08);
  --warning: #fbbf24;
  --warning-soft: rgba(251,191,36,0.08);
  --success: #34d399;
  --success-soft: rgba(52,211,153,0.10);
}

/* ── Accessibility — Focus Visible ─────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Shell Layout ──────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────── */
.shell-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), min-width var(--transition-base);
  z-index: 60;
  overflow: hidden;
}
.shell-sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
  min-width: var(--sidebar-collapsed-w);
}

.shell-sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}
.shell-brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shell-brand-icon svg { width: 16px; height: 16px; }
.shell-brand-text {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-0);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
}
.shell-sidebar.collapsed .shell-brand-text { opacity: 0; width: 0; }

.shell-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.shell-nav-section {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-3);
  padding: 16px 8px 6px;
  white-space: nowrap;
  overflow: hidden;
}
.shell-sidebar.collapsed .shell-nav-section { opacity: 0; height: 0; padding: 0; overflow: hidden; }

.shell-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  border: 1px solid transparent;
  text-decoration: none;
}
.shell-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-1);
  text-decoration: none;
}
.shell-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(129,140,248,0.08);
}
.shell-nav-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shell-nav-item-icon svg { width: 18px; height: 18px; stroke-width: 1.5; }
.shell-nav-item-label { overflow: hidden; text-overflow: ellipsis; }
.shell-sidebar.collapsed .shell-nav-item-label { opacity: 0; width: 0; }

.shell-nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--accent-soft);
  color: var(--accent);
  min-width: 18px;
  text-align: center;
}
.shell-nav-badge.warn { background: var(--amber-soft); color: var(--amber); }
.shell-nav-badge.danger { background: var(--rose-soft); color: var(--rose); }
.shell-sidebar.collapsed .shell-nav-badge { display: none; }

.shell-sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.shell-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.shell-collapse-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.shell-collapse-btn svg { width: 18px; height: 18px; transition: transform var(--transition-base); }
.shell-sidebar.collapsed .shell-collapse-btn svg { transform: rotate(180deg); }

/* ── Main Content ──────────────────────────── */
.shell-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shell-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Full-bleed variant for pages that need full width (workflows, livestream, etc.) */
body[data-shell-full] .shell-content {
  max-width: none;
  padding: 0;
}

/* ── Mobile Responsive ─────────────────────── */
.shell-mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 70;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--text-1);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.shell-mobile-toggle svg { width: 20px; height: 20px; }

.shell-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 55;
}

@media (max-width: 768px) {
  .shell-mobile-toggle { display: flex; }

  .shell-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    z-index: 60;
    box-shadow: var(--shadow-lg);
  }
  .shell-sidebar.mobile-open {
    transform: translateX(0);
  }
  .shell-sidebar.collapsed {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
  }
  .shell-overlay.active { display: block; }

  .shell-content {
    padding: 20px 16px; padding-top: 60px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  /* Ensure tap targets are at least 44px on mobile */
  .shell-nav-item { min-height: 44px; }
  button, .btn, .btn-sm { min-height: 44px; min-width: 44px; }
}

/* ── Notification Bell ─────────────────────── */
.shell-notif-bell {
  position: relative;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.shell-notif-bell:hover { background: var(--bg-hover); }
.shell-notif-bell svg { width: 18px; height: 18px; color: var(--text-2); }
.shell-notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rose);
  border: 2px solid var(--bg-1);
  display: none;
}
.shell-notif-dot.active { display: block; }

/* ── Common Components ─────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: var(--bg-3); color: var(--text-1); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-0); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(251,113,133,0.15); }
.btn-danger:hover { background: rgba(251,113,133,0.15); }
.btn-success { background: var(--success-soft); color: var(--success); border-color: rgba(52,211,153,0.15); }
.btn-success:hover { background: rgba(52,211,153,0.15); }

/* ── Animations ────────────────────────────── */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes skeleton-pulse { 0%,100%{opacity:.4} 50%{opacity:.8} }
