/* ═══════════════════════════════════════════════════════════════════════
   AE Tool Hub — Admin chrome
   ─────────────────────────────────────────────────────────────────────
   Shared layout for every /admin/** page: header, left rail, main
   content area. Page-specific styles live in page-specific CSS; this
   file only defines the shell. Relies on brand.css + hub.css for
   tokens.
   ═══════════════════════════════════════════════════════════════════════ */

body.ae-admin {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--ae-text);
  background: var(--ae-grey-light);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Auth gate states ───────────────────────────────────────────── */
#admin-gate-loading,
#admin-gate-denied {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 80px 32px;
  text-align: center;
  color: var(--ae-text);
}
#admin-gate-loading {
  color: var(--ae-text-muted);
  font-size: 14px;
}
#admin-gate-denied h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
#admin-gate-denied p {
  color: var(--ae-text-muted);
  font-size: 15px;
  line-height: 1.55;
  max-width: 480px;
  margin: 0 0 24px;
}

/* ── App shell ──────────────────────────────────────────────────── */
#admin-app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--ae-ink-950, #0E0B2E);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.admin-header-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.admin-header-logo img {
  height: 20px;
  width: auto;
  display: block;
}
.admin-header-divider {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.22);
}
.admin-header-sub {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.68);
}
.admin-header-breadcrumb {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-header-breadcrumb a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
}
.admin-header-breadcrumb a:hover { text-decoration: underline; }

.admin-user {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}
.admin-user img {
  width: 28px; height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.2);
}
.admin-user a {
  color: rgba(255,255,255,0.78);
  text-decoration: none;
  font-weight: 500;
}
.admin-user a:hover { color: #fff; }

/* ── Body + left rail + main ───────────────────────────────────── */
.admin-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  min-height: 0;
}
.admin-rail {
  background: #fff;
  border-right: 1px solid var(--ae-grey-border);
  padding: 24px 0;
  overflow-y: auto;
}
.admin-rail-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ae-text-muted);
  padding: 14px 22px 6px;
}
.admin-rail a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ae-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.admin-rail a:hover {
  background: var(--ae-grey-light);
  color: var(--ae-purple);
}
.admin-rail a.admin-rail-active {
  background: color-mix(in srgb, var(--ae-purple) 8%, transparent);
  color: var(--ae-purple);
  border-left-color: var(--ae-purple);
}
.admin-rail a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 2;
}
.admin-rail-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--ae-grey-light);
  color: var(--ae-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.admin-rail-tag-soon { background: #FFF4E5; color: #92400E; }

.admin-main {
  overflow-y: auto;
  padding: 32px 40px 60px;
  max-width: 100%;
  min-width: 0;
}

/* ── Page header (inside main) ─────────────────────────────────── */
.admin-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 22px;
  flex-wrap: wrap;
}
.admin-page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.admin-page-sub {
  color: var(--ae-text-muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 6px 0 0;
  max-width: 640px;
}
.admin-page-actions {
  display: inline-flex;
  gap: 8px;
}

/* ── Section cards (landing page grid) ─────────────────────────── */
.admin-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.admin-section-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 24px 24px;
  background: #fff;
  border: 1px solid var(--ae-grey-border);
  border-radius: var(--ae-radius-lg, 16px);
  text-decoration: none;
  color: var(--ae-text);
  transition: all 160ms ease;
  position: relative;
  overflow: hidden;
}
.admin-section-card:hover {
  border-color: var(--ae-purple);
  box-shadow: 0 8px 24px -10px rgba(95, 81, 213, 0.35);
  transform: translateY(-1px);
}
.admin-section-card-icon {
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ae-purple) 8%, transparent);
  color: var(--ae-purple);
  margin-bottom: 6px;
}
.admin-section-card-icon svg { width: 20px; height: 20px; }
.admin-section-card-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.admin-section-card-desc {
  font-size: 13.5px;
  color: var(--ae-text-muted);
  line-height: 1.5;
  flex: 1;
}
.admin-section-card-meta {
  font-size: 11px;
  color: var(--ae-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-top: 8px;
}

/* Section card "coming soon" variant */
.admin-section-card-soon {
  opacity: 0.65;
  pointer-events: none;
  background: var(--ae-grey-light);
}
.admin-section-card-soon .admin-section-card-icon {
  background: var(--ae-grey-border);
  color: var(--ae-text-muted);
}

/* ── Generic surface helpers for admin pages ───────────────────── */
.admin-card {
  background: #fff;
  border: 1px solid var(--ae-grey-border);
  border-radius: var(--ae-radius-md);
  padding: 20px 22px;
}
.admin-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.admin-card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.admin-hr {
  border: 0;
  border-top: 1px solid var(--ae-grey-border);
  margin: 20px 0;
}

.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--ae-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 120ms ease;
  text-decoration: none;
  line-height: 1;
}
.admin-btn-primary {
  background: var(--ae-purple);
  color: #fff;
  border-color: var(--ae-purple);
}
.admin-btn-primary:hover:not(:disabled) { background: #5045C0; border-color: #5045C0; }
.admin-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-btn-secondary {
  background: #fff;
  color: var(--ae-text);
  border-color: var(--ae-grey-border);
}
.admin-btn-secondary:hover { border-color: var(--ae-purple); color: var(--ae-purple); }
.admin-btn-danger {
  background: #fff;
  color: #991B1B;
  border-color: #FCA5A5;
}
.admin-btn-danger:hover { background: #FEE2E2; border-color: #EF4444; }
.admin-btn-ghost {
  background: transparent;
  color: var(--ae-text-secondary);
  border-color: transparent;
}
.admin-btn-ghost:hover { background: var(--ae-grey-light); color: var(--ae-text); }

.admin-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--ae-purple) 12%, transparent);
  color: var(--ae-purple);
}
.admin-pill-success { background: #DCFCE7; color: #15803D; }
.admin-pill-warn    { background: #FEF3C7; color: #B45309; }
.admin-pill-danger  { background: #FEE2E2; color: #991B1B; }
.admin-pill-ghost   { background: var(--ae-grey-light); color: var(--ae-text-muted); }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-body { grid-template-columns: 1fr; }
  .admin-rail {
    border-right: 0;
    border-bottom: 1px solid var(--ae-grey-border);
    padding: 12px 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 2px;
  }
  .admin-rail-section { display: none; }
  .admin-rail a { border-left: 0; border-bottom: 3px solid transparent; justify-content: center; padding: 10px 14px; }
  .admin-rail a.admin-rail-active {
    border-left: 0; border-bottom-color: var(--ae-purple);
  }
  .admin-main { padding: 24px 20px 48px; }
  .admin-header { padding: 12px 20px; flex-wrap: wrap; }
}

/* ═════════════════════════════════════════════════════════════════
   User management (/admin/users)
   ═════════════════════════════════════════════════════════════════ */

/* Small button variant — used inline in table action cells. */
.admin-btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

/* Notification banner (reused by admin-users + any future admin page
   that needs to surface a non-fatal warning). Mirrors the three admin
   pill colors at banner scale. */
.admin-banner {
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 20px;
  border: 1px solid transparent;
}
.admin-banner-warn {
  background: #FEF3C7;
  border-color: #FDE68A;
  color: #78350F;
}
.admin-banner-warn strong { color: #713F12; }
.admin-banner-info {
  background: #DBEAFE;
  border-color: #BFDBFE;
  color: #1E3A8A;
}
.admin-banner-info strong { color: #1E40AF; }
.admin-muted { color: var(--ae-text-muted); }

/* Stats tiles (4-up, wraps at medium widths). */
.users-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.users-stat {
  background: #fff;
  border: 1px solid var(--ae-grey-border);
  border-radius: 12px;
  padding: 18px 20px;
}
.users-stat-label {
  font-size: 0.7rem;
  color: var(--ae-text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.users-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ae-text);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 900px) {
  .users-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Filter row: chip group on the left, search on the right. */
.users-filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.users-filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.users-chip {
  background: #fff;
  border: 1px solid var(--ae-grey-border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ae-text-muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.users-chip:hover { border-color: var(--ae-purple); color: var(--ae-purple); }
.users-chip-active {
  background: var(--ae-purple);
  border-color: var(--ae-purple);
  color: #fff;
}
.users-chip-active:hover { background: #5045C0; color: #fff; }

.users-search {
  width: 280px;
  max-width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--ae-grey-border);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.users-search:focus {
  outline: none;
  border-color: var(--ae-purple);
  box-shadow: 0 0 0 3px rgba(95, 81, 213, 0.12);
}

/* Table. */
.users-card { padding: 0; overflow: hidden; }
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.users-table thead {
  background: var(--ae-grey-light);
  border-bottom: 1px solid var(--ae-grey-border);
}
.users-table th {
  text-align: left;
  padding: 12px 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ae-text-muted);
}
.users-th-user { min-width: 240px; }
.users-th-actions { text-align: right; }
.users-table td {
  padding: 14px 20px;
  border-top: 1px solid var(--ae-grey-border);
  vertical-align: middle;
}
.users-row:first-child td { border-top: 0; }
.users-row-pending { background: #FAFAFA; }
.users-row-pending:hover { background: #F5F5F5; }
.users-row:hover { background: var(--ae-grey-light); }

.users-cell-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.users-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ae-grey-light);
}
.users-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.users-avatar-fallback {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ae-text-muted);
  letter-spacing: 0.02em;
}
.users-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.users-identity-name {
  font-weight: 600;
  color: var(--ae-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.users-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  width: fit-content;
}
.users-badge-pending {
  background: #FEF3C7;
  color: #92400E;
}

.users-cell-email {
  color: var(--ae-text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
}
.users-cell-last {
  color: var(--ae-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.users-cell-actions {
  text-align: right;
  white-space: nowrap;
}
.users-actions {
  display: inline-flex;
  gap: 8px;
}

.users-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--ae-text-muted);
  font-size: 0.875rem;
}

/* Responsive — collapse email column on narrow screens. */
@media (max-width: 800px) {
  .users-table thead th:nth-child(2),
  .users-table tbody td:nth-child(2) { display: none; }
  .users-search { width: 100%; }
  .users-filters { flex-direction: column; align-items: stretch; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Modal — generic overlay + dialog
   ─────────────────────────────────────────────────────────────────────
   Used by admin-users.html (role-modal, configure-modal) and any other
   admin-* page that needs a centered confirm/edit dialog. Open state is
   driven by toggling .open via JS — element is fully invisible (and
   pointer-events disabled) when .open is absent.
   ═══════════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 6, 15, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  padding: 24px;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(7, 6, 15, 0.25), 0 4px 12px rgba(7, 6, 15, 0.08);
  max-width: 480px;
  width: 100%;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  transform: translateY(8px);
  transition: transform 0.18s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-wide { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--ae-grey-light);
}
.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.modal-header p {
  font-size: 13px;
  color: var(--ae-text-muted);
  margin: 0;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--ae-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--ae-grey-light); color: var(--ae-text); }

.modal-body {
  padding: 16px 24px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.55;
  flex: 1 1 auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--ae-grey-light);
}

/* ── Configure modal — section blocks ──────────────────────────────── */

.configure-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--ae-grey-light);
}
.configure-section:first-child { padding-top: 0; }
.configure-section:last-child { border-bottom: none; padding-bottom: 0; }

.configure-section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}
.configure-section-help {
  font-size: 12px;
  color: var(--ae-text-muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.configure-section-help code {
  background: var(--ae-grey-light);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.configure-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.configure-row > input,
.configure-row > select { flex: 1 1 auto; }
.configure-row-end { justify-content: flex-end; }

.configure-items-textarea {
  width: 100%;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--ae-grey-light);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafafa;
  color: var(--ae-text);
  resize: vertical;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.configure-items-textarea:focus {
  outline: 2px solid rgba(95, 81, 213, 0.35);
  outline-offset: 1px;
  border-color: rgba(95, 81, 213, 0.5);
  background: #fff;
}

.configure-feedback {
  margin-top: 10px;
  font-size: 12px;
  min-height: 1em;
}
.configure-feedback.is-error  { color: #b22a3d; }
.configure-feedback.is-ok     { color: #1d7a4f; }

/* ── User-row badges for manager + launchpad ───────────────────────── */

.users-badge-manager,
.users-badge-launchpad {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  margin-right: 4px;
}
.users-badge-manager {
  background: rgba(95, 81, 213, 0.10);
  color: #3D2F9E;
}
.users-badge-launchpad {
  background: rgba(255, 82, 51, 0.10);
  color: #C7361F;
}
