/* AdminBot design system — one stylesheet for the whole product.
   Layout shell lives in core/base.html; the workspace strip + app
   navigation live in workspaces/context_bar.html. */

:root {
  --color-bg: #f6f7f9;
  --color-surface: #ffffff;
  --color-surface-alt: #eef1f5;
  --color-text: #17202b;
  --color-text-muted: #5d6b7d;
  --color-border: #dde3ea;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-soft: #e3ecfd;
  --color-success: #0a7d5c;
  --color-success-soft: #e0f4ec;
  --color-warning: #9a6a00;
  --color-warning-soft: #fdf0d3;
  --color-error: #c62828;
  --color-error-soft: #fde8e8;
  --header-bg: #101828;
  --header-text: #f4f7fb;
  --spacing: 1rem;
  --radius: 0.625rem;
  --radius-lg: 0.9rem;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0b1220;
    --color-surface: #131c2e;
    --color-surface-alt: #1a2639;
    --color-text: #edf2f8;
    --color-text-muted: #9fb0c3;
    --color-border: #2a3a52;
    --color-accent: #5b93ff;
    --color-accent-hover: #84adff;
    --color-accent-soft: #1d335c;
    --color-success: #4ade9e;
    --color-success-soft: #0f3527;
    --color-warning: #fbbf24;
    --color-warning-soft: #3d2f05;
    --color-error: #f87171;
    --color-error-soft: #3d1414;
    --header-bg: #0a0f1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

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

body {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: calc(var(--spacing) * 2) var(--spacing) calc(var(--spacing) * 3);
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: var(--spacing);
}

h2 {
  font-size: 1.15rem;
  font-weight: 650;
  margin: calc(var(--spacing) * 1.75) 0 calc(var(--spacing) * 0.6);
}

p { margin-bottom: var(--spacing); color: var(--color-text-muted); }
strong { color: var(--color-text); }
small { color: var(--color-text-muted); }

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

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Header ---------- */

.site-header { background: var(--header-bg); color: var(--header-text); }

.site-header .header-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.8rem var(--spacing);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--header-text);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand:hover { color: var(--header-text); text-decoration: none; }
.brand .brand-mark { display: inline-flex; }
.brand .brand-tag {
  font-weight: 400;
  font-size: 0.8rem;
  color: #aebdd1;
  border-inline-start: 1px solid #33445e;
  padding-inline-start: 0.75rem;
}

.header-spacer { flex: 1; }
.header-user { color: #aebdd1; font-size: 0.92rem; }
.header-logout { margin: 0; }
.header-logout button {
  background: none;
  border: 1px solid #33445e;
  color: var(--header-text);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}
.header-logout button:hover { border-color: #f87171; color: #f87171; background: none; }

/* ---------- Workspace strip + app navigation ---------- */

.workspace-strip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.8rem 1rem;
  margin-bottom: calc(var(--spacing) * 1.5);
}

.workspace-strip .ws-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  font-size: 0.92rem;
  color: var(--color-text-muted);
  margin-bottom: 0.65rem;
}

.app-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }

.app-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  color: var(--color-text);
  font-size: 0.92rem;
  font-weight: 550;
}

.app-nav a:hover { background: var(--color-surface-alt); text-decoration: none; }
.app-nav a.nav-active { background: var(--color-accent-soft); color: var(--color-accent); }
.app-nav svg { flex: none; }

/* ---------- Messages ---------- */

.messages { list-style: none; margin-bottom: var(--spacing); display: grid; gap: 0.5rem; }

.messages li {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-accent-soft);
  color: var(--color-text);
  font-size: 0.95rem;
}

.messages li.success { background: var(--color-success-soft); border-color: var(--color-success); }
.messages li.warning { background: var(--color-warning-soft); border-color: var(--color-warning); }
.messages li.error { background: var(--color-error-soft); border-color: var(--color-error); }

/* ---------- Cards, callouts, grids ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: var(--spacing);
}

.card h2 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

.callout {
  border: 1px solid var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  margin-bottom: calc(var(--spacing) * 1.5);
}

.callout h2 { margin-top: 0; }
.callout p { color: var(--color-text); margin-bottom: 0; font-size: 1.02rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
  gap: var(--spacing);
  margin-bottom: var(--spacing);
}

.card-grid .card { margin-bottom: 0; }

.empty-state {
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.25rem;
  text-align: center;
  color: var(--color-text-muted);
  background: var(--color-surface);
  margin-bottom: var(--spacing);
}

.empty-state p { margin-bottom: 0.4rem; }
.empty-state p:last-child { margin-bottom: 0; }

/* ---------- Hero + endpoint cards (home) ---------- */

.hero { text-align: center; padding: 2.2rem 0 1.4rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 0.6rem; }
.hero .hero-sub { font-size: 1.12rem; max-width: 36rem; margin: 0 auto 1.4rem; }
.hero .hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.endpoint-list { list-style: none; display: grid; gap: 0.6rem; }
.endpoint-list li {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  box-shadow: var(--shadow);
}
.endpoint-list a { font-weight: 600; }

/* ---------- Buttons ---------- */

.btn, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover, button[type="submit"]:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

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

.btn-small { padding: 0.32rem 0.8rem; font-size: 0.88rem; }

.page-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0 0 var(--spacing); }
.back-link { margin-top: calc(var(--spacing) * 1.5); font-size: 0.95rem; }

/* ---------- Forms ---------- */

form { margin-bottom: var(--spacing); }
form p { margin-bottom: 0.9rem; color: var(--color-text); }
form > div { margin-bottom: 0.9rem; }

label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.3rem; color: var(--color-text); }

input[type="text"], input[type="url"], input[type="email"],
input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  max-width: 34rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.97rem;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-accent);
  outline: 2px solid var(--color-accent-soft);
  outline-offset: 0;
}

textarea { min-height: 6.5rem; resize: vertical; }
.helptext, form small { display: block; margin-top: 0.3rem; font-size: 0.85rem; }

.errorlist { list-style: none; margin: 0.3rem 0; }
.errorlist li { color: var(--color-error); font-size: 0.88rem; }

.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  max-width: 40rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.1rem;
  margin-bottom: var(--spacing);
}

.filter-bar label { margin-bottom: 0.2rem; }
.filter-bar select { width: auto; }
.filter-bar form, .filter-bar { margin-bottom: var(--spacing); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin-bottom: var(--spacing); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.94rem;
  margin-bottom: var(--spacing);
}

th, td { text-align: start; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--color-border); }
thead th { background: var(--color-surface-alt); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-alt); }
td form { margin: 0; }

/* ---------- Definition lists ---------- */

dl {
  display: grid;
  grid-template-columns: minmax(8rem, auto) 1fr;
  gap: 0.6rem 1.75rem;
  margin: 0 0 var(--spacing);
  padding: 1.1rem 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

dt { font-weight: 600; color: var(--color-text); }
dd { color: var(--color-text-muted); overflow-wrap: anywhere; }
dd.status-ok { color: var(--color-success); font-weight: 600; }
dd.status-error { color: var(--color-error); font-weight: 600; }

ul.plain-list { list-style: none; display: grid; gap: 0.5rem; margin-bottom: var(--spacing); }
ul.plain-list li {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  box-shadow: var(--shadow);
}

/* ---------- Draft cards ---------- */

.draft-list { list-style: none; display: grid; gap: 0.6rem; margin-bottom: var(--spacing); }

.draft-list li {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.85rem 1.1rem;
}

.draft-list .draft-title { font-weight: 650; font-size: 1.02rem; }
.draft-meta { color: var(--color-text-muted); font-size: 0.88rem; }

.badge {
  display: inline-block;
  padding: 0.08rem 0.55rem;
  border-radius: 999px;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  vertical-align: middle;
}

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

.caption-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin-bottom: var(--spacing);
  color: var(--color-text);
  white-space: normal;
}

/* ---------- Auth pages ---------- */

.auth-wrap { display: flex; justify-content: center; padding-top: 2.2rem; }

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.8rem;
  width: 100%;
  max-width: 26rem;
}

.auth-card h1 { font-size: 1.5rem; text-align: center; }
.auth-card .auth-sub { text-align: center; }
.auth-card input { max-width: none; }
.auth-card button[type="submit"] { width: 100%; justify-content: center; }
.auth-card form { margin-bottom: 0.5rem; }

.notice {
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: var(--spacing);
  font-size: 0.95rem;
  border: 1px solid var(--color-warning);
  background: var(--color-warning-soft);
  color: var(--color-text);
}

.notice-error { border-color: var(--color-error); background: var(--color-error-soft); }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.site-footer .footer-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.1rem var(--spacing);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  justify-content: space-between;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  main { padding-top: 1.25rem; }
  h1 { font-size: 1.5rem; }
  .hero h1 { font-size: 2rem; }
  dl { grid-template-columns: 1fr; gap: 0.15rem 0; padding: 1rem; }
  dd { margin-bottom: 0.6rem; }
  .brand .brand-tag { display: none; }
  .auth-card { padding: 1.3rem; }
  input[type="text"], input[type="url"], input[type="email"],
  input[type="password"], input[type="number"], select, textarea { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
