/* TomBot dashboard (feat-028 P1) — mobile-first, dark-mode aware. */

:root {
  --bg: #ffffff;
  --bg-alt: #f7f7f9;
  --bg-card: #ffffff;
  --border: #e5e5e7;
  --border-strong: #d1d1d6;
  --text: #1c1c1e;
  --text-muted: #6e6e73;
  --text-soft: #8e8e93;
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.1);
  --warn: #ff9500;
  --warn-soft: #fffbe6;
  --success: #34c759;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --bg-alt: #2c2c2e;
    --bg-card: #2c2c2e;
    --border: #38383a;
    --border-strong: #48484a;
    --text: #ffffff;
    --text-muted: #aeaeb2;
    --text-soft: #8e8e93;
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --warn: #ff9f0a;
    --warn-soft: rgba(255, 159, 10, 0.12);
    --success: #30d158;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.topbar .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-soft);
}

.refresh-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
}

.refresh-btn:active { transform: scale(0.95); }

/* tabs */
.tabs {
  display: flex;
  gap: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 49px;
  z-index: 9;
}

.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; padding: 12px 12px 80px; }
.tab-panel.active { display: block; }

/* filter chips */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* cards */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.card.urgent { border-color: var(--warn); }
.card.done { opacity: 0.6; }

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.card-id {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* Secondary id (imp-YYYYMMDD-NN when a feat-NNN is the primary).
   Smaller, lighter, sits inline with the primary so both are visible
   at a glance without competing visually. */
.card-id-secondary {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--text-soft);
  letter-spacing: 0.02em;
  margin-left: 8px;
  opacity: 0.75;
}

.card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-soft);
}

.badge {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.high { color: var(--warn); border-color: var(--warn); }
.badge.urgent { background: var(--warn); color: #fff; border-color: var(--warn); }
.badge.done { color: var(--success); border-color: var(--success); }

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 4px 0 4px 0;
  color: var(--text);
}

.card-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.card-summary p { margin: 0 0 4px 0; }

/* expanded view */
.card-body {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}

.card.expanded .card-body { display: block; }

.card-body h1, .card-body h2, .card-body h3, .card-body h4 {
  margin: 8px 0 4px 0;
  line-height: 1.25;
}

.card-body h1 { font-size: 16px; }
.card-body h2 { font-size: 15px; }
.card-body h3 { font-size: 14px; }
.card-body h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

.card-body code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--bg-alt);
  padding: 1px 4px;
  border-radius: 3px;
}

.card-body pre {
  background: var(--bg-alt);
  padding: 8px 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 12px;
}

.card-body pre code {
  background: transparent;
  padding: 0;
}

.card-body ul, .card-body ol {
  padding-left: 18px;
  margin: 4px 0;
}

.card-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  margin: 6px 0;
}

.card-body th, .card-body td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  text-align: left;
}

.card-body th { background: var(--bg-alt); }

.card-body blockquote {
  border-left: 3px solid var(--border-strong);
  margin: 6px 0;
  padding: 2px 0 2px 10px;
  color: var(--text-muted);
}

.card-body a { color: var(--accent); text-decoration: none; }
.card-body strong { font-weight: 700; color: var(--text); }
.card-body em { font-style: italic; }

/* asks list — flatter than imp cards */
.ask-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ask-row.done { opacity: 0.5; }
.ask-row.done .ask-title { text-decoration: line-through; }

.ask-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.ask-title {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}

.ask-age {
  font-size: 11px;
  color: var(--text-soft);
  white-space: nowrap;
}

.ask-age.old { color: var(--warn); font-weight: 600; }

.ask-detail {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* placeholder for tabs not yet built */
.placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
  font-size: 14px;
}

.placeholder.placeholder-soft {
  padding: 16px 12px;
  font-size: 12px;
}

.placeholder code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: var(--bg-alt);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}

/* search + sort row (P2) */
.search-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  align-items: center;
}

.search-input {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sort-select {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
}

.sort-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* goals tab (P2) */
.goal-card {
  cursor: pointer;
}

.goal-body {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.goal-card.expanded .goal-body { display: block; }

.goal-section { margin-top: 10px; }
.goal-section:first-child { margin-top: 0; }

.goal-section h4 {
  margin: 0 0 6px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.goal-section p,
.goal-section ul,
.goal-section ol {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}

.goal-empty-callout {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  color: var(--warn);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-style: italic;
}

.initiative {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-alt);
}

.initiative-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.initiative-name {
  font-weight: 600;
  font-size: 13px;
}

.initiative-status {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  white-space: nowrap;
}

.initiative-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.initiative-body ul,
.initiative-body ol { padding-left: 16px; margin: 4px 0; }

.initiative-body p { margin: 4px 0; }

/* schedule tab (P2) */
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.schedule-section { display: block; }

.schedule-heading {
  margin: 0 0 6px 2px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.schedule-card { margin-bottom: 6px; }

.schedule-card .cron-string {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.next-runs {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-soft);
}

.tz-hint {
  color: var(--text-soft);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
}

.bg-card.running { border-color: var(--accent); }
.bg-card.queued { opacity: 0.85; }
.bg-card.failed { border-color: var(--warn); }

/* P3 — write-back action buttons + toast */

.card-actions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.action-btn {
  flex: 1;
  min-width: 70px;
  background: var(--bg-alt);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}

.action-btn:active { transform: scale(0.97); }

.action-btn.approve {
  background: rgba(52, 199, 89, 0.12);
  border-color: var(--success);
  color: var(--success);
}

.action-btn.reject {
  background: rgba(255, 59, 48, 0.10);
  border-color: #ff3b30;
  color: #ff3b30;
}

.action-btn.discuss {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.action-btn[disabled],
.action-btn.in-flight {
  opacity: 0.5;
  cursor: progress;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 88%;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 100;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

/* footer */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-soft);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.footer-mark {
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

.context-badge {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.context-badge.tg {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* error banner */
.error {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  color: var(--warn);
  padding: 10px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

/* feat-033 — Feature card stage strip
   Four pills + connectors L→R: Concept → Spec → Build → Done.
   Variants: .done (solid fill), .current (outlined fill),
   .upcoming (ghost). Blocked statuses (rejected, blocked-needs-*) get
   .stage-strip.blocked which strikes through and adds a chip below.
   All theming via existing CSS variables — dark mode works for free. */
.stage-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 6px 0 10px;
  flex-wrap: wrap;
  cursor: pointer;
}

.stage {
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-soft);
  line-height: 1.4;
}

.stage.done {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.stage.current {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.stage.upcoming {
  background: transparent;
  color: var(--text-soft);
  border: 1px dashed var(--border);
}

.stage-conn {
  flex: 1 1 auto;
  height: 2px;
  min-width: 6px;
  max-width: 24px;
  background: var(--border);
  border-radius: 1px;
}

.stage-conn.done {
  background: var(--accent);
}

.stage-strip.blocked .stage,
.stage-strip.blocked .stage-conn {
  text-decoration: line-through;
  opacity: 0.55;
  filter: grayscale(60%);
}

.stage-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  color: var(--warn);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.stage-chip.stage-chip-warn {
  /* Same chrome as the warn variant; semantic alias for "unknown status". */
}

@media (max-width: 280px) {
  .stage-strip {
    flex-direction: column;
    align-items: stretch;
  }
  .stage-conn {
    width: 2px;
    height: 8px;
    max-width: none;
    margin: 0 auto;
  }
}

/* feat-034 — spec/plan PDF chips on Feature cards */
.card-spec-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.spec-link {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
}

.spec-link:hover,
.spec-link:focus {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
