/* admin-tool — styled to match the Temple AGI static site. */

:root {
  --brand: #7C051C;
  --brand-strong: #5a0414;
  --brand-bar: #9E1B34;
  --brand-soft: rgba(124, 5, 28, 0.08);
  --text: #1a1a1a;
  --text-muted: #555;
  --text-faint: #888;
  --border: #e5e5e5;
  --surface: #ffffff;
  --surface-alt: #fafafa;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.08);
  --container: 1200px;
  --radius: 8px;
  --radius-sm: 4px;
  --green: #2e7d32;
  --red: #c62828;
  --amber: #b45309;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Roboto", "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-alt);
  font-feature-settings: "ss01", "cv11";
}

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

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
button:hover { background: var(--surface-alt); }
button.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
button.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 3.5rem; }

/* ---------- top navigation (matches www .topnav) ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
}
.topnav-inner {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
}
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}
.topnav-brand:hover { text-decoration: none; }
.topnav-brand img.brand-logo {
  height: 2.4rem;
  width: auto;
  display: block;
}
.topnav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.topnav-right a {
  color: var(--text-muted);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
}
.topnav-right a:hover {
  color: var(--brand);
  background: var(--brand-soft);
  text-decoration: none;
}

/* ---------- container / page sections ---------- */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.titlecard {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 2rem 0 1rem;
  padding: 0 0 0 0.75rem;
  border-left: 4px solid var(--brand);
}

.muted { color: var(--text-muted); font-size: 0.875rem; }
.faint { color: var(--text-faint); font-size: 0.85rem; }
.error { color: var(--red); font-size: 0.875rem; margin-top: 0.5rem; }

/* ---------- card (matches www .card / .cardtitle / .cardcontent) ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 1.25rem;
  transition: box-shadow 0.2s;
}
.cardtitle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.15rem;
  background: var(--brand-bar);
  color: #fff;
}
.cardtitle h1, .cardtitle h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: #fff;
}
.cardcontent {
  padding: 1rem 1.15rem;
  font-size: 0.95rem;
}
.card.flat {
  border-radius: var(--radius);
}
.card.flat .cardcontent { padding: 1.15rem; }

/* ---------- pills / tags ---------- */

.label-pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--brand);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.3rem;
  white-space: nowrap;
  vertical-align: 0.05em;
}
.tag {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: 0.05em;
}
.tag.good { background: rgba(46, 125, 50, 0.1); color: var(--green); border-color: rgba(46, 125, 50, 0.25); }
.tag.bad  { background: rgba(198, 40, 40, 0.1); color: var(--red); border-color: rgba(198, 40, 40, 0.25); }
.tag.warn { background: rgba(180, 83, 9, 0.1); color: var(--amber); border-color: rgba(180, 83, 9, 0.25); }
.tag.brand { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); }

/* ---------- login ---------- */

/* On the login page we want the sign-in card to sit at the vertical centre
   of the space between the hero (top) and the footer (bottom), regardless
   of viewport height. Make body a flex column, let .login-main grow to fill
   the remaining height, and inside it let .login-wrap take the leftover so
   align-items:center actually has space to centre against. */
body.login-page {
  min-height: 100vh;
  height: auto;
  display: flex;
  flex-direction: column;
}
body.login-page .login-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 1.5rem;
}
body.login-page .login-hero {
  margin-bottom: 0;
}
body.login-page .login-wrap {
  flex: 1;
}
body.login-page .site-footer {
  margin-top: 0;
}

.login-main {
  padding: 1.5rem;
}

/* Hero on the login page — mirrors www .hero (faded logo background +
   eyebrow + large title + lead paragraph). */
.login-hero {
  position: relative;
  text-align: center;
  padding: 3rem 1rem 2.5rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/images/logo-2026.png") center 55% / contain no-repeat;
  opacity: 0.08;
  pointer-events: none;
  z-index: 0;
}
.login-hero > * {
  position: relative;
  z-index: 1;
}
.hero-eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 0.75rem;
}
.login-hero h1 {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}
.login-hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 42rem;
  margin: 0 auto;
  line-height: 1.6;
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
}
.login-card {
  width: 22rem;
  margin: 0;
}
.login-card .cardcontent { padding: 1.5rem; }
.login-card .field { margin-bottom: 0.85rem; }
.login-card .field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

/* ---------- chat layout ---------- */

.chat-layout {
  display: grid;
  grid-template-columns: 22rem 1fr;
  gap: 1.25rem;
  max-width: var(--container);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  align-items: start;
}

.chat-side, .chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-side {
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}
.chat-side .card { margin-bottom: 0.85rem; }

.session-item {
  position: relative;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.3rem;
  transition: background 0.15s, border-color 0.15s;
}
.session-item:hover { background: var(--surface-alt); }
.session-item.active { border-color: var(--brand); background: var(--brand-soft); }
.session-item .schema { font-weight: 600; font-size: 0.95rem; }
.session-item .meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.session-item .delete-btn {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--text-faint);
  padding: 0.2rem 0.4rem;
  font-size: 0.95rem;
  line-height: 1;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  cursor: pointer;
}
.session-item:hover .delete-btn,
.session-item.active .delete-btn { opacity: 1; }
.session-item .delete-btn:hover {
  background: rgba(198, 40, 40, 0.12);
  color: var(--red);
}

.new-session-row { display: flex; gap: 0.5rem; }
.new-session-row select { flex: 1; }

.chat-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 30rem;
  height: calc(100vh - 6rem);
}
.chat-main-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.15rem;
  background: var(--brand-bar);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
}
.chat-main-head .schema-name {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: rgba(255,255,255,0.15);
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.15rem;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.bubble {
  max-width: 75%;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
  font-size: 0.93rem;
}
.bubble.user {
  align-self: flex-end;
  background: var(--brand-soft);
  border: 1px solid rgba(124, 5, 28, 0.18);
  color: var(--text);
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.bubble.system {
  align-self: center;
  max-width: 90%;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  font-size: 0.85rem;
}
.bubble .bubble-image {
  display: block;
  max-width: 100%;
  max-height: 14rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  background: var(--surface-alt);
}
.bubble .bubble-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  align-items: flex-start;
}
.composer textarea { flex: 1; min-height: 2.5rem; max-height: 12rem; }
.composer .icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.composer .icon-btn:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-soft);
}

.chat-main.dropzone-active {
  outline: 3px dashed var(--brand);
  outline-offset: -3px;
}
.chat-main.dropzone-active .messages::after {
  content: "Drop image to upload";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 5, 28, 0.05);
  color: var(--brand);
  font-weight: 600;
  font-size: 1.1rem;
  pointer-events: none;
}
.chat-main { position: relative; }

/* draft / planner preview blocks (now in the left column) */
.chat-side pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  line-height: 1.55;
}

/* IDE-like syntax colors for JSON draft */
.json .json-key     { color: var(--brand); font-weight: 600; }
.json .json-string  { color: #047857; }   /* emerald */
.json .json-number  { color: #b45309; }   /* amber */
.json .json-boolean { color: #7c3aed; }   /* violet */
.json .json-null    { color: var(--text-faint); font-style: italic; }
.json .json-punct   { color: var(--text-muted); }
.planner-block { font-size: 0.88rem; }
.planner-block .field-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.field-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.14rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.field-pill.done   { background: #047857; border-color: #047857; }
.field-pill.active { background: #6b7280; border-color: #6b7280; }
.field-pill.todo   { background: #c62828; border-color: #c62828; }
.field-pill.optional { opacity: 0.78; }
.field-pill .hammer {
  display: inline-block;
  animation: hammer-wobble 1.4s ease-in-out infinite;
  transform-origin: 60% 80%;
}
@keyframes hammer-wobble {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(18deg); }
}

.empty {
  color: var(--text-faint);
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.9rem;
}

/* ---------- admin ---------- */

.admin-wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1.5rem;
}
.admin-filter {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 1rem;
  flex-wrap: wrap;
}
.admin-filter label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.admin-filter select { width: auto; min-width: 9rem; }
.admin-filter .sep { width: 1px; height: 1.4rem; background: var(--border); margin: 0 0.4rem; }

.admin-row {
  display: grid;
  grid-template-columns: 22rem 1fr;
  gap: 1.25rem;
  align-items: start;
}
.sub-list { display: flex; flex-direction: column; gap: 0.5rem; }
.sub-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.sub-item:hover { box-shadow: var(--shadow); }
.sub-item.active { border-color: var(--brand); box-shadow: var(--shadow-hover); }
.sub-item .sub-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.sub-item .sub-title { font-weight: 600; font-size: 0.95rem; }
.sub-item .sub-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }
.sub-item .sub-preview { font-size: 0.85rem; color: var(--text); margin-top: 0.35rem; line-height: 1.45; }

.sub-detail pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  margin: 0;
}
.sub-detail .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sub-detail .actions { display: flex; gap: 0.5rem; }

/* ---------- footer (mirrors www .site-footer) ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0 3rem;
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: var(--text-faint);
  text-align: center;
  background: var(--surface-alt);
}
.site-footer .container { padding: 0 1.5rem; }
.footer-org {
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.footer-address {
  font-style: normal;
  color: var(--text-muted);
  margin: 0.5rem 0;
  line-height: 1.55;
}
.footer-email { margin-top: 0.5rem; }
.footer-email a { color: var(--brand); }

/* On the chat page, the layout already fills the viewport; the footer
   sits after the fold and is reached by scrolling. */
body.chat-page .chat-layout { padding-bottom: 0.5rem; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .chat-layout { grid-template-columns: 16rem 1fr 18rem; }
}
@media (max-width: 900px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-main { height: auto; min-height: 24rem; }
  .admin-row { grid-template-columns: 1fr; }
}
