/* ═══════════════════════════════════════════════════════════
   AntiGravity Command Dashboard — Design System
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Tokens ─── */
:root {
  --bg-deep: #07090f;
  --bg-surface: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2333;
  --bg-elevated: #21262d;

  --border: rgba(139, 148, 158, 0.12);
  --border-hover: rgba(139, 148, 158, 0.25);

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;

  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 58, 237, 0.25);

  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --blue: #58a6ff;
  --gray: #484f58;

  --green-bg: rgba(63, 185, 80, 0.08);
  --amber-bg: rgba(210, 153, 34, 0.08);
  --red-bg: rgba(248, 81, 73, 0.08);
  --blue-bg: rgba(88, 166, 255, 0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Background Effect ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124, 58, 237, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(59, 130, 246, 0.06), transparent),
    radial-gradient(ellipse 50% 30% at 20% 80%, rgba(236, 72, 153, 0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ─── App Shell ─── */
.app {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

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

.logo {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-glow);
}

.header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header h1 span {
  font-weight: 400;
  opacity: 0.6;
  -webkit-text-fill-color: var(--text-secondary);
}

.header-date {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

/* ─── Breadcrumb Nav ─── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  font-size: 14px;
}

.breadcrumb a {
  color: var(--accent-light);
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition);
}

.breadcrumb a:hover {
  color: #c4b5fd;
}

.breadcrumb .sep {
  color: var(--text-muted);
}

.breadcrumb .current {
  color: var(--text-secondary);
}

/* ─── Stats Bar ─── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.purple {
  background: rgba(124, 58, 237, 0.15);
}

.stat-icon.green {
  background: var(--green-bg);
}

.stat-icon.amber {
  background: var(--amber-bg);
}

.stat-icon.red {
  background: var(--red-bg);
}

.stat-icon.blue {
  background: var(--blue-bg);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Section Header ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* ─── Search & Filter ─── */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.search-box {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.search-box input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px 10px 40px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box::before {
  content: '🔍';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

.filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent-light);
  background: rgba(124, 58, 237, 0.06);
}

/* ─── Workspace Cards ─── */
.workspace-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}

.workspace-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.workspace-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--card-accent, var(--accent)), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.workspace-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.workspace-card:hover::before {
  opacity: 1;
}

.workspace-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.workspace-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--bg-elevated);
}

.workspace-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1;
}

.badge-complete {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.2);
}

.badge-partial {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid rgba(210, 153, 34, 0.2);
}

.badge-stalled {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.2);
}

.badge-unknown {
  background: rgba(72, 79, 88, 0.15);
  color: var(--gray);
  border: 1px solid rgba(72, 79, 88, 0.2);
}

.workspace-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.workspace-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.workspace-progress {
  margin-bottom: 16px;
}

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

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.workspace-threads {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.thread-chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.thread-chip.complete {
  border-color: rgba(63, 185, 80, 0.2);
  color: var(--green);
}

.thread-chip.partial {
  border-color: rgba(210, 153, 34, 0.2);
  color: var(--amber);
}

.thread-chip.stalled {
  border-color: rgba(248, 81, 73, 0.2);
  color: var(--red);
}

/* ─── Thread List (workspace detail) ─── */
.thread-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.thread-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: flex-start;
  gap: 20px;
}

.thread-card:hover {
  border-color: var(--border-hover);
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.thread-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.thread-status-dot.complete {
  background: var(--green);
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.4);
}

.thread-status-dot.partial {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(210, 153, 34, 0.4);
}

.thread-status-dot.stalled {
  background: var(--red);
  box-shadow: 0 0 8px rgba(248, 81, 73, 0.4);
}

.thread-status-dot.unknown {
  background: var(--gray);
}

.thread-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.thread-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.thread-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.thread-arrow {
  color: var(--text-muted);
  font-size: 20px;
  margin-top: 4px;
  transition: transform var(--transition);
}

.thread-card:hover .thread-arrow {
  transform: translateX(4px);
  color: var(--accent-light);
}

/* ─── Thread Detail ─── */
.thread-detail {
  max-width: 900px;
}

.thread-detail-header {
  margin-bottom: 32px;
}

.thread-detail-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.thread-detail-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.thread-detail-status.complete {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.2);
}

.thread-detail-status.partial {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid rgba(210, 153, 34, 0.2);
}

.thread-detail-status.stalled {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.2);
}

.thread-detail-status.unknown {
  background: rgba(72, 79, 88, 0.15);
  color: var(--gray);
  border: 1px solid rgba(72, 79, 88, 0.2);
}

.thread-detail-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Detail Sections ─── */
.detail-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-section h3 .icon {
  opacity: 0.7;
}

/* Task checklist */
.checklist {
  list-style: none;
}

.checklist li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(139, 148, 158, 0.06);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.checklist li:last-child {
  border-bottom: none;
}

.check-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 1px;
}

.check-icon.done {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.check-icon.progress {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid rgba(210, 153, 34, 0.3);
}

.check-icon.todo {
  background: rgba(72, 79, 88, 0.1);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* File list */
.file-list {
  list-style: none;
}

.file-list li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition);
}

.file-list li:hover {
  background: var(--bg-elevated);
}

.file-list .file-icon {
  opacity: 0.6;
}

.file-list .file-name {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-light);
}

.file-list .file-desc {
  color: var(--text-secondary);
  margin-left: auto;
}

/* Next steps / insights */
.next-steps-list,
.insights-list {
  list-style: none;
}

.next-steps-list li,
.insights-list li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(139, 148, 158, 0.06);
  font-size: 14px;
  line-height: 1.5;
}

.next-steps-list li:last-child,
.insights-list li:last-child {
  border-bottom: none;
}

.next-steps-list li::before {
  content: '→ ';
  color: var(--accent-light);
  font-weight: 600;
}

.insights-list .worked::before {
  content: '✅ ';
}

.insights-list .issue::before {
  content: '⚠️ ';
}

/* ─── Screenshot Gallery ─── */
.screenshot-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.screenshot-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.screenshot-item:hover {
  border-color: var(--accent);
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.screenshot-item img,
.screenshot-item video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.screenshot-caption {
  padding: 8px 12px;
  background: var(--bg-elevated);
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── Preview Links ─── */
.preview-links {
  margin-top: 16px;
}

.preview-links h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.preview-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin: 4px 6px 4px 0;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(124, 58, 237, 0.25);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
}

.preview-link:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(59, 130, 246, 0.15));
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
}

.preview-link .link-icon {
  font-size: 14px;
}

.preview-link .link-arrow {
  font-size: 11px;
  opacity: 0.5;
  transition: transform var(--transition);
}

.preview-link:hover .link-arrow {
  transform: translateX(3px);
  opacity: 1;
}

/* Workspace card preview link row */
.workspace-previews {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ws-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 999px;
  color: var(--accent-light);
  font-size: 11px;
  text-decoration: none;
  transition: all var(--transition);
}

.ws-preview-chip:hover {
  background: rgba(124, 58, 237, 0.16);
  border-color: var(--accent);
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 15px;
}

/* ─── Back Button ─── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 20px;
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ─── Animations ─── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.animate-in {
  animation: fadeInUp 0.5s var(--transition) forwards;
  opacity: 0;
}

.animate-in:nth-child(1) {
  animation-delay: 0.05s;
}

.animate-in:nth-child(2) {
  animation-delay: 0.1s;
}

.animate-in:nth-child(3) {
  animation-delay: 0.15s;
}

.animate-in:nth-child(4) {
  animation-delay: 0.2s;
}

.animate-in:nth-child(5) {
  animation-delay: 0.25s;
}

.animate-in:nth-child(6) {
  animation-delay: 0.3s;
}

.animate-in:nth-child(7) {
  animation-delay: 0.35s;
}

.animate-in:nth-child(8) {
  animation-delay: 0.4s;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .app {
    padding: 20px 16px 60px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

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

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

  .thread-card {
    grid-template-columns: auto 1fr;
  }

  .thread-arrow {
    display: none;
  }

  .controls {
    flex-wrap: wrap;
  }
}