/* ============================================================
   Agentic Board — Design System
   Aesthetic: Industrial precision meets collaborative warmth
   Font: DM Mono (monospace utility) + DM Sans (readable body)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Tokens ── */
:root {
  --font-mono: 'DM Mono', 'Fira Code', monospace;
  --font-sans: 'DM Sans', 'Segoe UI', sans-serif;

  --bg:        #0f1117;
  --bg2:       #181c27;
  --bg3:       #1e2233;
  --surface:   #242840;
  --surface2:  #2d3250;
  --border:    #353a5a;
  --border2:   #434870;

  --text:      #e8eaf2;
  --text2:     #9ba3c4;
  --text3:     #636b8f;

  --accent:    #6c7fff;
  --accent2:   #4e5fd4;
  --accent-bg: rgba(108,127,255,0.10);

  --green:     #3ecf8e;
  --green-bg:  rgba(62,207,142,0.10);
  --amber:     #f5a623;
  --amber-bg:  rgba(245,166,35,0.10);
  --red:       #f06565;
  --red-bg:    rgba(240,101,101,0.10);
  --blue:      #5cadfe;
  --blue-bg:   rgba(92,173,254,0.10);

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow:    0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);

  --transition: 150ms ease;
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Layout ── */
.app-shell {
  display: grid;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  padding: 0 20px;
  position: relative;
  z-index: 10;
}

.nav-logo {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 32px;
}

.nav-logo-mark {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 4px;
  display: grid;
  place-items: center;
}

.nav-logo-mark svg { width: 13px; height: 13px; }

.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
}

.nav-link {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
}

.nav-link .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

.badge-blocked {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); }

.btn-secondary {
  background: var(--surface);
  color: var(--text2);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface2); color: var(--text); }

.btn-ghost {
  background: none;
  color: var(--text2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.btn-sm {
  font-size: 12px;
  padding: 5px 10px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Forms ── */
input, textarea, select {
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

input::placeholder, textarea::placeholder {
  color: var(--text3);
}

/* ── Status chips ── */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-not-started  { background: var(--surface); color: var(--text3); }
.status-in-progress  { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(92,173,254,0.2); }
.status-blocked      { background: var(--red-bg); color: var(--red); border: 1px solid rgba(240,101,101,0.2); }
.status-complete     { background: var(--green-bg); color: var(--green); border: 1px solid rgba(62,207,142,0.2); }

.status-chip::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  font-size: 13px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: slideIn 200ms ease;
  max-width: 320px;
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red); color: var(--red); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Loading spinner ── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Utility ── */
.mono  { font-family: var(--font-mono); }
.muted { color: var(--text3); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Ideation Page ── */
.ideation-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  height: 100%;
  overflow: hidden;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chat-header h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text3);
  text-align: center;
  padding: 40px;
}

.chat-empty .icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.chat-empty h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
}

.chat-empty p {
  font-size: 13px;
  line-height: 1.7;
  max-width: 280px;
}

.message {
  display: flex;
  gap: 10px;
  max-width: 640px;
  animation: msgIn 200ms ease;
}

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

.message.user { align-self: flex-end; flex-direction: row-reverse; }

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.message.user .message-avatar {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(108,127,255,0.2);
}

.message.agent .message-avatar {
  background: var(--surface);
  color: var(--text3);
  border: 1px solid var(--border);
}

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

.message-content {
  font-size: 14px;
  line-height: 1.7;
  padding: 10px 14px;
  border-radius: var(--radius);
  word-break: break-word;
}

.message.user .message-content {
  background: var(--accent-bg);
  border: 1px solid rgba(108,127,255,0.15);
  color: var(--text);
  border-radius: var(--radius) 2px var(--radius) var(--radius);
}

.message.agent .message-content {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 2px var(--radius) var(--radius) var(--radius);
}

.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 8px 0 8px 20px; }
.message-content li { margin-bottom: 4px; }
.message-content strong { color: var(--text); font-weight: 600; }
.message-content code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
}

.message-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time { text-align: right; }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px var(--radius) var(--radius) var(--radius);
  width: fit-content;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  animation: typingBounce 1.2s ease infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 14px;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
  color: #fff;
}

.send-btn:hover { background: var(--accent2); }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Initiative Sidebar ── */
.initiative-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg2);
}

.initiative-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.initiative-header h2 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
}

.initiative-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.initiative-empty {
  color: var(--text3);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
  line-height: 1.7;
}

.initiative-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.initiative-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.initiative-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}

.initiative-card-desc {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

.task-list { border-top: 1px solid var(--border); }

.task-list-header {
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  background: var(--bg3);
}

.task-item {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.task-item:first-child { border-top: none; }

.task-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border2);
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
  display: grid;
  place-items: center;
}

.task-title {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.4;
  flex: 1;
}

.initiative-actions {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Tracker Page ── */
.tracker-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.tracker-toolbar {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg2);
}

.tracker-toolbar h1 {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-right: 4px;
}

.filter-group {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.filter-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-btn.active, .filter-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border2);
}

/* ── Kanban ── */
.kanban-outer {
  flex: 1;
  overflow: hidden;
  padding: 20px;
}

.kanban-board {
  display: grid;
  grid-template-columns: 260px 1fr 1fr 1fr 1fr;
  gap: 12px;
  height: 100%;
  min-width: 960px;
  overflow-x: auto;
}

.kanban-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg2);
  border: 1px solid var(--border);
}

.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.kanban-col-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  flex: 1;
}

.kanban-col-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
}

.col-accent {
  height: 2px;
  border-radius: 0;
  margin-bottom: -1px;
  flex-shrink: 0;
}

.col-accent-initiative { background: var(--accent); }
.col-accent-not-started { background: var(--border2); }
.col-accent-in-progress { background: var(--blue); }
.col-accent-blocked     { background: var(--red); }
.col-accent-complete    { background: var(--green); }

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-drop-zone {
  min-height: 60px;
  border-radius: var(--radius);
  transition: background var(--transition), border var(--transition);
}

.kanban-drop-zone.drag-over {
  background: var(--accent-bg);
  border: 1px dashed var(--accent);
}

/* ── Initiative Kanban Card ── */
.initiative-kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.initiative-kanban-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border2);
}

.initiative-kanban-title {
  padding: 12px 14px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.initiative-kanban-meta {
  padding: 0 14px 12px;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
}

.initiative-progress {
  padding: 0 14px 12px;
}

.progress-bar-bg {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 400ms ease;
}

/* ── Task Kanban Card ── */
.task-kanban-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: grab;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  user-select: none;
}

.task-kanban-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow);
}

.task-kanban-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: rotate(1.5deg);
}

.task-kanban-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
}

.task-kanban-initiative {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-kanban-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-agent-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── Blocked card detail ── */
.blocked-reason {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--red-bg);
  border: 1px solid rgba(240,101,101,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--red);
  line-height: 1.5;
}

/* ── Task Detail Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: grid;
  place-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 150ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-xl);
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 200ms ease;
}

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

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.modal-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text3);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 16px;
  transition: all var(--transition);
}

.modal-close:hover { color: var(--text); border-color: var(--border2); }

.modal-body { padding: 20px 24px; }

.modal-section { margin-bottom: 20px; }

.modal-section:last-child { margin-bottom: 0; }

.modal-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 6px;
}

.modal-text {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.resolve-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Skeleton loaders ── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 37%, var(--surface) 63%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

/* ── Session list ── */
.session-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text3);
}

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

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

/* ── Responsive ── */
@media (max-width: 900px) {
  .ideation-layout { grid-template-columns: 1fr; }
  .initiative-pane { display: none; }
}
