/* SSIT AI Agent — EJS admin console */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3e;
  --text: #e8eaf6;
  --muted: #8892b0;
  --accent: #6c63ff;
  --accent2: #00d2ff;
  --success: #51cf66;
  --danger: #ff6b6b;
  --link-gold: #d4af37;
  --link-gold-hover: #f1d67a;
  --radius: 10px;
  --font: system-ui, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body.admin-body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.admin-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
}
.admin-login-card h1 { margin: 0 0 0.5rem; font-size: 1.35rem; }
.admin-login-card p { color: var(--muted); margin: 0 0 1.25rem; font-size: 0.9rem; }

.admin-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}
.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #13151f;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  position: relative;
  z-index: 1;
}
.admin-brand {
  padding: 0 1rem 1rem;
  font-weight: 700;
  font-size: 1rem;
}
.admin-brand a { color: var(--text); text-decoration: none; }
.admin-brand a:hover { color: var(--accent); }

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}
.nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 12px 8px 4px;
}
.nav-item {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
}
.nav-item:hover { background: var(--border); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,.18); color: var(--accent); }
.nav-sub { padding-left: 16px; font-size: 0.82rem; }

.admin-logout {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.admin-logout .btn { width: 100%; }

/* Main column: stacked top bar (title + flashes) + scrollable content — same shape as portal */
.admin-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-x: visible;
  overflow-y: visible;
  position: relative;
  z-index: 2;
}
.admin-top-bar {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 300;
  background: var(--bg);
  padding: 0 28px 0.25rem;
  border-bottom: 1px solid var(--border);
}
.admin-top-bar .admin-page-header h1 {
  margin: 0.85rem 0 0.65rem;
}
.admin-top-bar .flash:last-child {
  margin-bottom: 0.65rem;
}
.admin-page-header h1 {
  font-size: 1.35rem;
  font-weight: 600;
}
.admin-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  padding: 0.65rem 28px 40px;
}
/* Same content width as portal dashboard when using shared wrapper (admin overview + portal) */
.admin-content .portal-wrap {
  max-width: 960px;
  width: 100%;
  overflow: visible;
}
.dashboard-main-page {
  width: 100%;
}

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash-success { background: rgba(81,207,102,.12); color: var(--success); border: 1px solid rgba(81,207,102,.25); }
.flash-error { background: rgba(255,107,107,.12); color: var(--danger); border: 1px solid rgba(255,107,107,.25); }

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  overflow: visible;
}
/* Raised by JS while a native <select> in this panel is open (focus-within is unreliable) */
.admin-panel.ssit-select-lift {
  position: relative;
  z-index: 50000;
}
a:not(.btn):not(.nav-item) {
  color: var(--link-gold);
}
a:not(.btn):not(.nav-item):hover {
  color: var(--link-gold-hover);
}
.admin-panel h2 { margin: 0 0 1rem; font-size: 1rem; font-weight: 600; color: var(--muted); }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #13151f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.stat-card .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }
.stat-card .sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-up { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-down { background: var(--danger); }
.portal-help-tip {
  display: inline-flex;
  width: 1.1rem;
  height: 1.1rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
  cursor: help;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.admin-table tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: ui-monospace, monospace; font-size: 0.8rem; color: var(--accent2); }

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 560px;
  padding: 10px 12px;
  background: #13151f;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.form-group textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: 0.82rem; }
.form-group textarea.code-lg { min-height: 280px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

.btn {
  display: inline-block;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge-ok { background: rgba(81,207,102,.15); color: var(--success); }
.badge-bad { background: rgba(255,107,107,.15); color: var(--danger); }

.key-reveal {
  background: #13151f;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 1rem;
  word-break: break-all;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--accent2);
  margin: 1rem 0;
}

.chat-log {
  background: #13151f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 1rem;
}
.chat-msg { margin-bottom: 12px; font-size: 0.9rem; }
.chat-msg .role { font-size: 0.7rem; color: var(--muted); margin-bottom: 4px; }
.chat-msg.user .text { color: var(--accent2); }
.chat-msg.assistant .text { white-space: pre-wrap; }

pre.json {
  background: #13151f;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow: auto;
  font-size: 0.78rem;
  max-height: 400px;
}

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.feature-doc {
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 1rem;
}
.feature-doc > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent2);
}
.feature-doc > summary::-webkit-details-marker { display: none; }
.feature-doc[open] { padding-bottom: 0.75rem; }
.feature-doc-body {
  padding-bottom: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
}
.feature-doc-body h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--text);
}
.feature-doc-body ul { margin: 0.25rem 0 0.5rem 1.1rem; padding: 0; }
.feature-doc-body li { margin-bottom: 0.35rem; }
.feature-doc-body code {
  background: #13151f;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
}
.docs-toc { margin: 0; padding-left: 1.25rem; }
.docs-toc li { margin-bottom: 0.5rem; }
