@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Roboto:wght@500&display=swap');

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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-elevated: #242736;
  --border: #2e3148;
  --text: #e4e4e7;
  --text-secondary: #9ca3af;
  --accent: #6366f1;
  --accent-hover: #818cf8;

  --status-not-started: #6b7280;
  --status-in-progress: #3b82f6;
  --status-complete: #22c55e;
  --status-failed: #ef4444;
  --status-timed-out: #f59e0b;
  --status-disabled: #374151;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8f9fc;
    --surface: #ffffff;
    --surface-elevated: #f1f3f9;
    --border: #e2e5ed;
    --text: #1a1d27;
    --text-secondary: #6b7280;
    --accent: #4f46e5;
    --accent-hover: #6366f1;
  }
}

html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 24px;
}
.nav-logo {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.nav-links { display: flex; gap: 16px; flex: 1; justify-content: center; }
.nav-links a {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 12px 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-external {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.nav-logout {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
}
.nav-logout:hover { color: var(--text); }

/* Login page */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 12px;
}
.login-title { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.login-subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
/* Google Sign-In button (official branding) */
.google-btn {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 4px;
  height: 40px;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow 0.15s;
  overflow: hidden;
}
.google-btn:hover {
  box-shadow: 0 1px 3px rgba(60,64,67,0.3);
  color: #3c4043;
}
.google-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.google-btn-text {
  font-family: 'Roboto', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #3c4043;
  padding: 0 12px 0 0;
  white-space: nowrap;
  letter-spacing: 0.25px;
}

/* Home page */
.home-container { max-width: 800px; margin: 0 auto; padding: 48px 20px; }
.home-title { font-size: 24px; font-weight: 600; margin-bottom: 32px; letter-spacing: -0.03em; }
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
  display: block;
  color: var(--text);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  color: var(--text);
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.card-desc { font-size: 13px; color: var(--text-secondary); }
.card-external::after { content: ' ↗'; font-size: 11px; opacity: 0.5; }

/* Orchestrator */
.diagram-container {
  padding: 24px;
  overflow: auto;
}
.diagram-container .mermaid svg {
  width: auto;
  max-height: none;
}
/* Override Mermaid subgraph backgrounds */
.mermaid .cluster rect { fill: var(--surface) !important; stroke: var(--border) !important; }
.mermaid .cluster span { color: var(--text) !important; }
.mermaid .nodeLabel { color: var(--text) !important; }
.mermaid .edgeLabel { background: var(--bg) !important; color: var(--text-secondary) !important; }
.mermaid .node rect,
.mermaid .node polygon { fill: var(--surface-elevated) !important; stroke: var(--accent) !important; }
.mermaid .flowchart-link { stroke: var(--accent) !important; }
.mermaid marker path { fill: var(--accent) !important; }

/* Agent Board */
.board-container { padding: 16px; overflow-x: auto; }
.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(300px, 1fr));
  gap: 12px;
  min-width: calc(7 * 300px + 6 * 12px);
}
.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px - 32px);
}
.column-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}
.column-name { font-weight: 600; font-size: 14px; }
.column-role { font-size: 12px; color: var(--text-secondary); }
.column-count {
  margin-left: auto;
  background: var(--surface-elevated);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}
.column-body { padding: 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.column-empty { text-align: center; color: var(--text-secondary); font-size: 13px; padding: 24px 8px; }
.column-error { text-align: center; color: var(--status-failed); font-size: 13px; padding: 24px 8px; }

/* Task card */
.task-card {
  background: var(--surface-elevated);
  border-radius: 6px;
  padding: 12px;
  border-left: 3px solid var(--status-not-started);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.task-card[data-status="not_started"] { border-left-color: var(--status-not-started); }
.task-card[data-status="in_progress"] { border-left-color: var(--status-in-progress); }
.task-card[data-status="complete"] { border-left-color: var(--status-complete); }
.task-card[data-status="failed"] { border-left-color: var(--status-failed); }
.task-card[data-status="timed_out"] { border-left-color: var(--status-timed-out); }
.task-card[data-status="disabled"] { border-left-color: var(--status-disabled); opacity: 0.6; }
.task-card[data-status="routed"] { border-left-color: var(--status-in-progress); }

.task-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.task-status[data-status="not_started"] { background: var(--status-not-started); color: #fff; }
.task-status[data-status="in_progress"] { background: var(--status-in-progress); color: #fff; }
.task-status[data-status="complete"] { background: var(--status-complete); color: #fff; }
.task-status[data-status="failed"] { background: var(--status-failed); color: #fff; }
.task-status[data-status="timed_out"] { background: var(--status-timed-out); color: #000; }
.task-status[data-status="disabled"] { background: var(--status-disabled); color: #9ca3af; }
.task-status[data-status="routed"] { background: var(--status-in-progress); color: #fff; }

.task-desc {
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.task-desc.expanded {
  display: block;
  -webkit-line-clamp: unset;
}
.task-meta { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.task-project {
  font-size: 11px;
  background: var(--surface);
  color: var(--text-secondary);
  padding: 1px 8px;
  border-radius: 4px;
}
.task-recurring {
  font-size: 12px;
  color: var(--text-secondary);
  title: "Recurring";
}

/* Skeleton loading */
.skeleton {
  background: var(--surface-elevated);
  border-radius: 6px;
  height: 80px;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

/* Error banner */
.error-banner {
  background: var(--status-failed);
  color: #fff;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
