/* Shared admin styling — brand-aligned with the public landing page. */

:root {
  --navy-950: #081120;
  --navy-900: #0b1a33;
  --ink: #16233b;
  --muted: #5a6b85;
  --muted-dark: #9fb0ca;   /* muted text on navy */
  --line: #dde5f0;
  --line-soft: #e9eff8;
  --bg: #f6f9fd;
  --card: #ffffff;
  --primary: #2e6ee6;
  --primary-dark: #1f57c4;
  --grad: linear-gradient(120deg, #2e6ee6, #38a4f8);
  --error-bg: #fdecec;
  --error-ink: #b3261e;
  --success-bg: #e2f5ea;
  --success-ink: #157a42;
  --info-bg: #e8f0fd;
  --info-ink: #1f57c4;
  --warn-bg: #fdf3d7;
  --warn-ink: #8a6100;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(11, 26, 51, 0.04), 0 4px 14px rgba(11, 26, 51, 0.06);
  --shadow-md: 0 12px 32px rgba(11, 26, 51, 0.14);
  --focus-ring: 0 0 0 3px rgba(46, 110, 230, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 1.25rem; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; margin: 2.25rem 0 0.8rem; }

/* --- Top navigation ------------------------------------------------------ */

.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 1.5rem;
  background: var(--navy-900);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topnav .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-right: 1.25rem;
}

.topnav .brand::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 4px;
  background: var(--grad);
}

.topnav a,
.topnav .btn-link {
  color: var(--muted-dark);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
}

.topnav a:hover,
.topnav .btn-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.topnav a.active { color: #fff; background: rgba(255, 255, 255, 0.14); }
.topnav .spacer { flex: 1; }
.topnav .agent-name { color: var(--muted-dark); font-size: 0.875rem; margin-right: 0.5rem; }
.topnav form { margin: 0; }

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

.btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 9px;
  padding: 0.55rem 1.15rem;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 110, 230, 0.35);
}

.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { filter: brightness(0.97); }

.btn-link { background: none; padding: 0; color: var(--primary); }
.btn-link:hover { text-decoration: underline; }

.btn:focus-visible,
.btn-sm:focus-visible,
.btn-copy:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Small ghost buttons used in table rows */

.btn-sm {
  display: inline-block;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.34rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn-sm:hover {
  border-color: #b9cdf3;
  background: var(--info-bg);
  color: var(--primary-dark);
  text-decoration: none;
}

.btn-sm.primary { background: var(--info-bg); border-color: transparent; color: var(--primary-dark); }
.btn-sm.primary:hover { background: #d8e6fb; }
.btn-sm.danger { color: var(--error-ink); }
.btn-sm.danger:hover { border-color: #f0b6b3; background: var(--error-bg); color: var(--error-ink); }

/* --- Flash messages ------------------------------------------------------ */

.flashes { max-width: 1240px; margin: 1.25rem auto 0; padding: 0 1.5rem; }

.flash {
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border-left: 3px solid currentColor;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.flash-error   { background: var(--error-bg);   color: var(--error-ink); }
.flash-success { background: var(--success-bg); color: var(--success-ink); }
.flash-info    { background: var(--info-bg);    color: var(--info-ink); }

/* --- Page content -------------------------------------------------------- */

.content { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.5rem 3.5rem; }

/* --- Login page ---------------------------------------------------------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background:
    radial-gradient(70rem 40rem at 75% -15%, #1b3462 0%, rgba(27, 52, 98, 0) 60%),
    radial-gradient(50rem 30rem at 10% 110%, #132649 0%, rgba(19, 38, 73, 0) 55%),
    var(--navy-950);
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2.25rem 2.25rem;
  width: 100%;
  max-width: 400px;
}

.login-card h1 { margin: 0 0 1.5rem; font-size: 1.3rem; text-align: center; }

.login-card h1::before {
  content: "";
  display: block;
  width: 2.25rem;
  height: 0.35rem;
  border-radius: 999px;
  background: var(--grad);
  margin: 0 auto 1rem;
}

.login-back { margin: 1.5rem 0 0; text-align: center; font-size: 0.875rem; }
.login-back a { color: var(--muted); text-decoration: none; }
.login-back a:hover { color: var(--primary); text-decoration: underline; }

.login-card label {
  display: block;
  margin: 1rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.login-card input {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.login-card .btn { width: 100%; margin-top: 1.5rem; }

.login-card .activate-intro {
  margin: 0 0 1.25rem;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
}

/* --- Page head ----------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-head h1 { margin: 0; }
.page-head .btn { text-decoration: none; }

.page-actions { display: flex; align-items: center; gap: 0.6rem; }

.page-actions .btn-link {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 9px;
  padding: 0.5rem 1rem;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

.page-actions .btn-link:hover {
  border-color: #b9cdf3;
  color: var(--primary-dark);
  background: var(--info-bg);
  text-decoration: none;
}

/* --- Data tables ---------------------------------------------------------- */

.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

.data-table th {
  text-align: left;
  padding: 0.7rem 0.8rem;
  background: #f9fbfe;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td { padding: 0.8rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #f7faff; }

.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.data-table a.btn-sm { color: var(--ink); }
.data-table a.btn-sm:hover { color: var(--primary-dark); text-decoration: none; }

.cell-strong { font-weight: 600; white-space: nowrap; }
.cell-clip { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.actions-col { text-align: right; white-space: nowrap; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.4rem; }
.inline-form { display: inline-flex; align-items: center; gap: 0.55rem; margin: 0; }

/* --- Client link + copy button ------------------------------------------- */

.link-cell { white-space: nowrap; }

.link-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  max-width: 170px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 0.2rem 0.3rem 0.2rem 0.6rem;
}

.link-cell .link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-copy {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  border: 0;
  background: none;
  color: var(--primary);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
}

.btn-copy:hover { background: var(--info-bg); }

.btn-danger-link { color: var(--error-ink); }

.muted { color: var(--muted); }

/* --- Status badges ------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.7rem 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

.badge-draft     { background: #eceff5; color: #4a5a74; }
.badge-published { background: var(--success-bg); color: var(--success-ink); }
.badge-stale     { background: var(--warn-bg); color: var(--warn-ink); }

.badge-role-agent  { background: #eceff5; color: #4a5a74; }
.badge-role-master { background: var(--info-bg); color: var(--info-ink); }

.badge-beta-pending  { background: var(--warn-bg); color: var(--warn-ink); }
.badge-beta-approved { background: var(--success-bg); color: var(--success-ink); }
.badge-beta-denied   { background: #eceff5; color: #4a5a74; }

.badge-fb-new  { background: var(--info-bg); color: var(--info-ink); }
.badge-fb-read { background: #eceff5; color: #4a5a74; }

/* --- Detail list (beta request page) -------------------------------------- */

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6rem 1.75rem;
  margin: 0;
}

.detail-list dt { font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }

.detail-divider { border: none; border-top: 1px solid var(--line); margin: 1.4rem 0 1.2rem; }

/* --- Empty state --------------------------------------------------------- */

.empty-state {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--muted);
}

.empty-state p { margin: 0.3rem 0; }
.empty-state a { color: var(--primary); font-weight: 600; text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* --- Form cards ----------------------------------------------------------- */

.form-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 2rem 2rem;
  max-width: 640px;
}

.form-card label { display: block; margin: 1.2rem 0 0.35rem; font-weight: 600; font-size: 0.9rem; }
.form-card label:first-child { margin-top: 0; }
.form-card h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }

.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"],
.form-card textarea {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-card input:focus,
.form-card textarea:focus,
.form-card select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

.form-card input[type="file"] {
  width: 100%;
  font: inherit;
  font-size: 0.875rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 9px;
  padding: 0.6rem;
  background: var(--bg);
}

.form-card input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 7px;
  padding: 0.35rem 0.85rem;
  margin-right: 0.75rem;
  cursor: pointer;
}

.form-card input[type="file"]::file-selector-button:hover { border-color: #b9cdf3; color: var(--primary-dark); }

.form-card .hint { margin: 0.15rem 0 0.45rem; color: var(--muted); font-size: 0.84rem; }

.form-card .hint.warn {
  margin-top: 1.1rem;
  color: var(--warn-ink);
  background: var(--warn-bg);
  padding: 0.6rem 0.85rem;
  border-radius: 9px;
  border-left: 3px solid var(--warn-ink);
}

.form-actions { margin-top: 1.75rem; display: flex; align-items: center; gap: 1rem; }

/* --- Master dashboard ----------------------------------------------------- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.15rem 1.3rem;
}

.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.02em; }

.stat-card .stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}

/* --- Agent filter on the system client list ------------------------------- */

.filter-bar { display: flex; align-items: center; gap: 0.6rem; margin: 0; }
.filter-bar label { color: var(--muted); font-size: 0.875rem; font-weight: 600; }

.filter-bar select,
.form-card select {
  font: inherit;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.filter-bar select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

.form-card .check-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }

/* --- "Email link" checkbox next to the Publish button -------------------- */

.email-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.email-opt.muted { cursor: not-allowed; }

/* --- Feedback modal (admin header) ---------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6rem 1.5rem 2rem;
  background: rgba(8, 17, 32, 0.55);
  overflow-y: auto;
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  width: 100%;
  max-width: 520px;
  border: 0;
  box-shadow: var(--shadow-md);
}

.modal-card .form-actions { margin-top: 1.4rem; }

/* --- Feedback message body (master detail page) ---------------------------- */

.feedback-message {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
}

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

@media (max-width: 720px) {
  .topnav { flex-wrap: wrap; padding: 0.6rem 1rem; }
  .content { padding: 1.25rem 1rem 2.5rem; }
  .flashes { padding: 0 1rem; }
  .form-card { padding: 1.25rem 1.25rem 1.5rem; }
}
