/* ==========================================================================
   Repo X-Ray — Design System & Stylesheet
   Aesthetic: Apple-level polish + Samsung One UI clarity + Linear + VS Code
   Palette: Rich obsidian charcoal dark mode, restrained cobalt accent
   Typography: SamsungOne, SF Pro, Inter, crisp monospace
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-canvas: #090b0e;
  --bg-sidebar: #0e1117;
  --bg-surface: #141720;
  --bg-surface-elevated: #1a1e2a;
  --bg-surface-active: #222736;
  --bg-surface-hover: #171b26;

  /* Borders */
  --border-subtle: #1c2230;
  --border-medium: #272f42;
  --border-focus: #3b82f6;

  /* Primary Technical Accent */
  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-primary-glow: rgba(59, 130, 246, 0.12);

  /* Semantic Status Colors */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.1);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.1);
  --color-info: #0ea5e9;
  --color-info-bg: rgba(14, 165, 233, 0.1);
  --color-purple: #8b5cf6;

  /* Text & Typography */
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #64748b;
  --text-subtle: #475569;

  /* Font Stacks */
  --font-sans: "SamsungOne", "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, Menlo, monospace;

  /* Dimensions & Spacing */
  --sidebar-width: 250px;
  --header-height: 54px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Shadows (subtle & restrained) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   Application Shell
   ========================================================================== */

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* --- Top Header Bar --- */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 16px;
  user-select: none;
  z-index: 20;
}

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

.brand-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: 0.05em;
  font-size: 13px;
}

.brand-icon {
  width: 22px;
  height: 22px;
  color: var(--accent-primary);
}

.brand-divider {
  width: 1px;
  height: 16px;
  background-color: var(--border-medium);
}

.repo-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.repo-status-pill:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-surface-elevated);
}

.repo-name {
  font-weight: 600;
  color: var(--text-primary);
}

.repo-branch-badge {
  background-color: var(--bg-surface-active);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
}

.demo-indicator {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  background-color: rgba(255, 255, 255, 0.03);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-status-pill:hover {
  border-color: var(--border-medium);
  background-color: var(--bg-surface-elevated);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: var(--color-success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.offline {
  background-color: var(--text-subtle);
}

.status-dot.connecting {
  background-color: var(--color-warning);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

/* ==========================================================================
   App Body (Sidebar + Content + Inspector)
   ========================================================================== */

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* --- Left Sidebar --- */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
  z-index: 10;
}

.sidebar-nav {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  border: 1px solid transparent;
}

.nav-item:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  font-weight: 600;
}

.nav-item .nav-icon {
  width: 17px;
  height: 17px;
  opacity: 0.8;
  color: inherit;
}

.nav-item.active .nav-icon {
  color: var(--accent-primary);
  opacity: 1;
}

.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.connection-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.connection-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.connection-card-body {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-actions {
  display: flex;
  gap: 6px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-focus);
}

.btn-subtle {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.btn-subtle:hover {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   Main Content Pane & View Switching
   ========================================================================== */

.main-content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  position: relative;
  background-color: var(--bg-canvas);
}

.view-panel {
  display: none;
  height: 100%;
  width: 100%;
}

.view-panel.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   View 1: Overview Dashboard
   ========================================================================== */

.dashboard-container {
  padding: 32px 36px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.repo-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.hero-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 650px;
}

.hero-actions {
  display: flex;
  gap: 8px;
}

/* Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-medium);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  font-feature-settings: "tnum";
}

.stat-subtext {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Two-column layout */
.overview-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 20px;
}

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* Project Health Bars */
.health-bars-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.health-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.health-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.health-bar-label {
  color: var(--text-secondary);
}

.health-bar-score {
  font-weight: 600;
  font-family: var(--font-mono);
}

.progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  background-color: var(--accent-primary);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.progress-fill.high {
  background-color: var(--color-success);
}
.progress-fill.medium {
  background-color: var(--color-warning);
}
.progress-fill.low {
  background-color: var(--color-danger);
}

/* Architecture Flow Banner */
.architecture-flow {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-surface-elevated);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.flow-node {
  background-color: var(--bg-surface-active);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  font-weight: 500;
}

.flow-arrow {
  color: var(--text-muted);
}

/* AI Insight Box */
.ai-insight-box {
  background-color: rgba(59, 130, 246, 0.05);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
}

.ai-insight-icon {
  color: var(--accent-primary);
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.ai-insight-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Activity Stream */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  font-size: 12px;
}

.activity-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.activity-target {
  font-weight: 500;
  color: var(--text-primary);
}

.activity-time {
  color: var(--text-muted);
  font-size: 11px;
}

/* ==========================================================================
   View 2: Architecture Graph (Cytoscape)
   ========================================================================== */

.graph-view-wrapper {
  display: flex;
  flex: 1;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

.graph-main-canvas {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: #0b0d12;
}

/* Graph Toolbar */
.graph-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(14, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper input {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 5px 10px 5px 28px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-primary);
  width: 180px;
  transition: width var(--transition-fast), border-color var(--transition-fast);
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--border-focus);
  width: 220px;
}

.search-icon {
  position: absolute;
  left: 8px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.select-custom {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  outline: none;
}

.select-custom:focus {
  border-color: var(--border-focus);
}

#cy {
  width: 100%;
  height: 100%;
  flex: 1;
}

/* Graph Legend Overlay */
.graph-legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background-color: rgba(14, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: 5;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Node Inspector Panel (Slide-over drawer) */
.node-inspector {
  width: 360px;
  height: 100%;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 15;
  transition: transform var(--transition-normal);
}

.node-inspector.hidden {
  display: none;
}

.inspector-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.inspector-file-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

.inspector-file-path {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 2px;
}

.inspector-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.inspector-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chip:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.inspector-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

/* ==========================================================================
   View 3: Project Explorer
   ========================================================================== */

.explorer-view-wrapper {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.explorer-tree-pane {
  width: 280px;
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  user-select: none;
}

.tree-pane-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tree-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px;
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.tree-node:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
}

.tree-node.active {
  background-color: var(--bg-surface-active);
  color: var(--text-primary);
  font-weight: 500;
}

.tree-node-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}

.tree-node.active .tree-node-icon {
  opacity: 1;
}

.explorer-code-pane {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: #0d1117;
  overflow: hidden;
}

.code-pane-header {
  height: 42px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.code-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-editor-area {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

pre[class*="language-"] {
  background: transparent !important;
  margin: 0 !important;
  padding: 0 !important;
}

code[class*="language-"] {
  font-family: var(--font-mono) !important;
  font-size: 12px !important;
}

/* AI Explanation Sub-Pane in Explorer */
.code-ai-drawer {
  height: 200px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
}

.code-ai-drawer.collapsed {
  height: 38px;
}

.code-ai-header {
  height: 38px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.code-ai-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ==========================================================================
   View 4: AI Codebase Chat ("Ask your codebase")
   ========================================================================== */

.chat-view-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 24px 20px 20px;
  box-sizing: border-box;
}

.chat-header-area {
  margin-bottom: 18px;
}

.chat-header-area h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.chat-header-area p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Suggested chips */
.suggested-questions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 20px;
}

.question-chip {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.question-chip:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.chat-messages-stream {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 6px;
  margin-bottom: 16px;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  line-height: 1.6;
}

.chat-bubble.user-msg {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-medium);
  align-self: flex-end;
  max-width: 80%;
  font-weight: 500;
}

.chat-bubble.ai-msg {
  background-color: var(--bg-surface);
  border-color: var(--border-subtle);
  align-self: flex-start;
  width: 100%;
}

.chat-msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.chat-msg-body {
  font-size: 13px;
  color: var(--text-primary);
}

.chat-msg-body p {
  margin-bottom: 10px;
}

.chat-msg-body p:last-child {
  margin-bottom: 0;
}

.chat-msg-body code {
  background-color: var(--bg-surface-active);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
}

.chat-references-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  align-items: center;
}

.chat-input-bar:focus-within {
  border-color: var(--border-focus);
}

.chat-input-field {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

/* ==========================================================================
   View 5: Impact Analysis
   ========================================================================== */

.impact-view-container {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.impact-target-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
}

.impact-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.impact-badge-display {
  display: flex;
  align-items: center;
  gap: 14px;
}

.impact-level-pill {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 6px 16px;
  border-radius: var(--radius-md);
  text-transform: uppercase;
}

.impact-level-pill.high {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.impact-level-pill.medium {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.impact-level-pill.low {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

#impact-subgraph {
  width: 100%;
  height: 320px;
  background-color: #0b0d12;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

/* ==========================================================================
   View 6: Code Health Scan
   ========================================================================== */

.health-view-container {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.health-summary-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.health-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.health-category-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.signal-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.signal-row.pass {
  color: #34d399;
}

.signal-row.warning {
  color: #fbbf24;
}

/* ==========================================================================
   View 7: Documentation & README Generator
   ========================================================================== */

.docs-view-container {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.docs-tab-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 8px;
}

.docs-markdown-preview {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px 30px;
  font-family: var(--font-sans);
  line-height: 1.7;
  color: var(--text-primary);
  overflow-y: auto;
  max-height: 600px;
}

.docs-markdown-preview h1,
.docs-markdown-preview h2,
.docs-markdown-preview h3 {
  margin-top: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.docs-markdown-preview code {
  background-color: var(--bg-surface-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
}

.docs-markdown-preview pre {
  background-color: #0b0d12;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin: 12px 0;
  overflow-x: auto;
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus {
  border-color: var(--border-focus);
}

.modal-footer {
  padding: 14px 22px;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Scanning Overlay */
.scan-progress-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(9, 11, 14, 0.9);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 150;
  backdrop-filter: blur(8px);
}

.scan-progress-overlay.active {
  display: flex;
}

.scan-card {
  width: 440px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  box-shadow: var(--shadow-lg);
}

.scan-steps-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  text-align: left;
  margin-top: 10px;
}

.scan-step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.scan-step-item.active {
  color: var(--accent-primary);
  font-weight: 500;
}

.scan-step-item.completed {
  color: var(--color-success);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* First-Run Welcome Screen */
.welcome-hero-backdrop {
  position: fixed;
  inset: 0;
  background-color: #080a0e;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
}

.welcome-hero-backdrop.active {
  display: flex;
}

.welcome-card {
  width: 580px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 2;
}

.welcome-canvas-bg {
  position: absolute;
  inset: 0;
  opacity: 0.15;
  pointer-events: none;
  z-index: 1;
}

/* ==========================================================================
   Responsive Design & Breakpoints
   ========================================================================== */

@media (max-width: 900px) {
  :root {
    --sidebar-width: 68px;
  }

  .nav-item span,
  .nav-section-title,
  .sidebar-bottom .connection-card-body,
  .sidebar-bottom .connection-card-header,
  .sidebar-bottom div:last-child {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 10px;
  }

  .sidebar-bottom {
    padding: 8px;
  }

  .btn-sidebar-connect {
    padding: 6px;
    font-size: 10px;
  }

  .overview-grid,
  .impact-result-grid,
  .health-cards-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .privacy-badge {
    display: none;
  }

  .explorer-view-wrapper {
    flex-direction: column;
  }

  .explorer-tree-pane {
    width: 100%;
    height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .node-inspector {
    position: absolute;
    right: 0;
    top: 0;
    width: 300px;
    box-shadow: var(--shadow-lg);
  }
}

@media (max-width: 600px) {
  .dashboard-container,
  .impact-view-container,
  .health-view-container,
  .docs-view-container {
    padding: 16px;
  }

  .top-header {
    padding: 0 10px;
  }

  .repo-status-pill .repo-branch-badge {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .welcome-card {
    width: 92%;
    padding: 24px;
  }

  .modal-dialog {
    width: 94%;
    margin: 10px;
  }

  .graph-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search-input-wrapper input {
    width: 100%;
  }
}

