/* AgentHouse-inspired dashboard styles (token-based) */

/* ── Design Tokens ─────────────────────────────────── */
:root {
  /* Colors */
  --color-bg:           #ffffff;
  --color-surface:      #f8f9fb;
  --color-surface-2:    #f0f2f7;
  --color-border:       #e2e6ef;
  --color-text:         #111827;
  --color-text-muted:   #6b7280;
  --color-accent:       #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-success:      #059669;
  --color-warn:         #d97706;
  --color-danger:       #dc2626;

  /* Typography */
  --font-sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --text-xs:    .75rem;
  --text-sm:    .875rem;
  --text-base:  1rem;
  --text-lg:    1.125rem;
  --text-xl:    1.25rem;
  --text-2xl:   1.5rem;
  --text-3xl:   1.875rem;
  --text-4xl:   2.25rem;
  --text-5xl:   3rem;

  /* Spacing */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08);

  /* Layout */
  --max-width: 1400px;
}

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

/* ── Nav ──────────────────────────────────────────── */
.nav-wrapper {
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  z-index: 100;
}
.nav {
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
}
.nav-logo {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -.02em;
}
.nav-logo span { color: var(--color-accent); }
.nav-links {
  display: flex;
  gap: var(--space-8);
  list-style: none;
}
.nav-links a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color .15s;
}
.nav-links a:hover,
.nav-links a.active { color: var(--color-text); }
.nav-links a.active { font-weight: 600; }

/* ── Layout wrapper ───────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
section { padding: var(--space-20) 0; }

/* ── Hero ─────────────────────────────────────────── */
.hero {
  padding: var(--space-24) 0 var(--space-20);
  text-align: center;
}
.hero-compact {
  padding: var(--space-16) 0 var(--space-10);
}
.hero-compact .hero-sub { margin-bottom: 0; }
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: #eff6ff;
  color: var(--color-accent);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: var(--space-6);
}
.hero h1 {
  font-size: var(--text-5xl);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.1;
  max-width: 720px;
  margin: 0 auto var(--space-6);
}
.hero h1 em { font-style: normal; color: var(--color-accent); }
.hero-sub {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  max-width: 580px;
  margin: 0 auto var(--space-10);
  line-height: 1.65;
}
.hero-ctas {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: .7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background .15s, color .15s, box-shadow .15s, border-color .15s;
}
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}
.btn-secondary:hover { border-color: #c7d0e0; background: var(--color-surface); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn-danger { background: #c0392b; color: #fff; border-color: #c0392b; }
.btn-danger:hover { background: #a93226; border-color: #a93226; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Stat bar ─────────────────────────────────────── */
.stat-bar {
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: var(--space-6) 0;
}
.stat-bar-inner {
  display: flex;
  justify-content: center;
  gap: var(--space-16);
  flex-wrap: wrap;
}
.stat-item { text-align: center; min-width: 140px; }
.stat-num {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--color-text);
}
.stat-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ── Section header ───────────────────────────────── */
.section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}
.section-title {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.2;
  margin-bottom: var(--space-4);
}
.section-sub {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 640px;
  margin-bottom: var(--space-12);
}

/* ── Cards Grid ───────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-6);
}
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  box-shadow: var(--shadow-card);
  transition: box-shadow .2s, border-color .2s;
}
.card:hover { box-shadow: var(--shadow-md); border-color: #c7d0e0; }
.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: var(--space-4);
}
.card h3 { font-size: var(--text-base); font-weight: 700; margin-bottom: var(--space-2); }
.card p { font-size: var(--text-sm); color: var(--color-text-muted); line-height: 1.65; }

/* ── Steps ────────────────────────────────────────── */
.steps-section { background: var(--color-surface); }
.steps-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-6); }
@media (max-width: 900px) { .steps-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .steps-grid { grid-template-columns: 1fr; } }
.step-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}
.step-num {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: var(--space-3);
}
.step-card h3 { font-size: var(--text-base); font-weight: 700; margin-bottom: var(--space-2); }
.step-card p { font-size: var(--text-sm); color: var(--color-text-muted); }

/* ── Status section ───────────────────────────────── */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
@media (max-width: 700px) { .status-grid { grid-template-columns: 1fr; } }
.status-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}
.status-card h3 {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: var(--space-4);
}
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}
.status-row:last-child { border-bottom: none; }

/* ── Pills ────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.4;
}
.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .8;
}
.pill-green { background: #d1fae5; color: #065f46; }
.pill-amber { background: #fef3c7; color: #92400e; }
.pill-blue  { background: #dbeafe; color: #1e40af; }
.pill-muted { background: var(--color-surface-2); color: var(--color-text-muted); }

/* ── Utilities ─────────────────────────────────────── */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace; }
.muted { color: var(--color-text-muted); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.fw-700 { font-weight: 700; }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-md > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mt-6 { margin-top: var(--space-6); }

/* ── Playbook (Demo) ───────────────────────────────── */
/* only top/bottom — left/right kommt von .container */
.playbook-main { padding-top: var(--space-16); padding-bottom: var(--space-20); }
.playbook-compact { padding-top: var(--space-10); padding-bottom: var(--space-16); }
.pb-section { margin-bottom: var(--space-6); }
.pb-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.pb-row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.pb-input {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .55rem .8rem;
  color: var(--color-text);
  font-size: var(--text-sm);
  width: 260px;
}
.pb-input:focus { outline: none; border-color: #c7d0e0; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.pb-actions { display: flex; gap: var(--space-3); margin-top: var(--space-6); flex-wrap: wrap; }


.pb-gate {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  padding: var(--space-6);
  border: 1px solid #fde68a;
  background: #fffbeb;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
}
.pb-gate[hidden] { display: none; }
.pb-gate-icon { font-size: 1.2rem; }
.pb-gate-content p { margin-top: var(--space-1); color: var(--color-text-muted); font-size: var(--text-sm); }

.pb-stories {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: var(--color-bg);
}
.pb-empty { padding: var(--space-6); color: var(--color-text-muted); font-size: var(--text-sm); }
.pb-story {
  display: grid;
  grid-template-columns: 26px 92px 1fr auto 26px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.pb-story:last-child { border-bottom: none; }
.pb-story-icon { width: 26px; text-align: center; }
.pb-story-key { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace; font-size: var(--text-sm); font-weight: 700; }
.pb-story-title { font-size: var(--text-sm); color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-story-status { justify-self: end; }
.pb-story-conf { width: 26px; text-align: center; opacity: .8; }

.pb-badge {
  --badge: #64748b;
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 800;
  border: 1px solid color-mix(in srgb, var(--badge) 30%, transparent);
  background: color-mix(in srgb, var(--badge) 10%, transparent);
  color: var(--badge);
}
.pb-badge[data-status="Backlog"],
.pb-badge[data-status="Todo"] { --badge: #64748b; }
.pb-badge[data-status="InAnalysis"] { --badge: #2563eb; }
.pb-badge[data-status="InDesign"] { --badge: #7c3aed; }
.pb-badge[data-status="ReadyForBuild"],
.pb-badge[data-status="Done"] { --badge: #059669; }
.pb-badge[data-status="InDevelopment"] { --badge: #ea580c; }
.pb-badge[data-status="InReview"] { --badge: #d97706; }
.pb-badge[data-status="InTest"] { --badge: #0891b2; }
.pb-badge[data-status="Blocked"] { --badge: #dc2626; }

.pb-log-wrap { margin-top: var(--space-6); }
.pb-log-title {
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.pb-log {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  height: 210px;
  overflow: auto;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.pb-log-entry + .pb-log-entry { margin-top: var(--space-2); }
.pb-log-entry--webhook { color: var(--color-accent); font-weight: 500; }

/* ── Verlauf / History ──────────────────────────────── */
.pb-history-wrap {
  margin-top: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.pb-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  cursor: pointer;
  user-select: none;
}
.pb-history-header:hover { background: var(--color-surface); }
.pb-history-toggle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}
.pb-history-filters {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.pb-history-select {
  font-size: var(--text-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
}
.pb-history-log {
  height: 260px;
  border: none;
  border-radius: 0;
}
.pb-history-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  line-height: 1.5;
}
.pb-history-ts {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 10ch;
}
.pb-history-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 9999px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  font-size: .65rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.pb-history-entry--brain .pb-history-badge {
  background: #ede9fe;
  border-color: #c4b5fd;
  color: #6d28d9;
}
.pb-history-entry--warn  { color: var(--color-warn); }
.pb-history-entry--error { color: var(--color-danger); font-weight: 500; }
.pb-history-evt {
  font-weight: 500;
  color: var(--color-text);
  flex-shrink: 0;
}
.pb-history-detail {
  color: var(--color-text-muted);
  font-size: .7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60ch;
}
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

/* ── Webhook status dot ─────────────────────────────── */
.webhook-dot {
  font-size: .65rem;
  cursor: default;
  user-select: none;
  transition: color .3s;
}
.webhook-dot--ok      { color: var(--color-success); }
.webhook-dot--stale   { color: var(--color-warn); }
.webhook-dot--unknown { color: var(--color-text-muted); }

.pb-sse-live    { font-size: .65rem; color: var(--color-success); cursor: default; user-select: none; transition: color .3s; }
.pb-sse-offline { font-size: .65rem; color: var(--color-text-muted); cursor: default; user-select: none; }

.pb-status-bar { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-2); }
.pb-run-chips { margin-top: var(--space-3); display: flex; flex-wrap: wrap; gap: var(--space-2); }
.pb-run-chip {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: .35rem .75rem;
  font-size: var(--text-xs);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.pb-run-chip:hover { border-color: #c7d0e0; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.pb-run-chip-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.pb-run-chip-open0 { opacity: .75; }
.pb-run-chip-count { margin-left: .35rem; color: var(--color-text-muted); font-weight: 700; }

/* ── Footer ───────────────────────────────────────── */
footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) 0;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ── Legacy embeds ─────────────────────────────────── */
.legacy-frame {
  width: 100%;
  height: 920px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  background: var(--color-bg);
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  .container { padding: 0 var(--space-6); }
}
@media (max-width: 640px) {
  .nav-links { display: none; }
  .hero h1 { font-size: var(--text-4xl); }
  .hero-sub { font-size: var(--text-lg); }
  .stat-bar-inner { gap: var(--space-8); }
  .container { padding: 0 var(--space-5); }
  .pb-story { grid-template-columns: 26px 76px 1fr auto 26px; padding: var(--space-4); }
  .legacy-frame { height: 720px; }
}
