/* Admin console styling. Deliberately shares the dashboard's palette and radius
   so moving between the two does not feel like two products. */
:root {
  --primary: #67A2D7;
  --primary-dark: #4d8bbf;
  --primary-light: #e8f3fb;
  --accent: #ff9e22;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --bg: #f0f7ff;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 12px rgba(103,162,215,0.10);
  --radius: 16px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px; width: 100%; max-width: 380px; text-align: center;
}
.login-logo {
  width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.login-card h1 { font-size: 20px; font-weight: 700; }
.login-card h1 span { color: var(--primary); }
.login-card .subtitle { font-size: 12px; color: var(--text-muted); margin: 4px 0 20px; }
.login-card label {
  display: block; text-align: left; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin: 12px 0 5px;
}
.login-card input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.btn-primary {
  width: 100%; margin-top: 18px; padding: 11px; background: var(--primary);
  color: #fff; border: none; border-radius: 10px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background .18s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.form-error {
  background: #fef2f2; color: var(--red); border: 1px solid #fecaca;
  border-radius: 10px; padding: 9px 12px; font-size: 12.5px; text-align: left; margin-top: 6px;
}
.form-hint { font-size: 11.5px; color: var(--text-muted); text-align: left; margin-top: 8px; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border); padding: 20px 12px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.logo-dot {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.sidebar-brand h1 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar-brand h1 span { color: var(--primary); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; border: none; background: none; font-family: inherit;
  text-align: left; width: 100%; transition: all .15s;
}
.nav-item:hover { background: var(--primary-light); color: var(--primary-dark); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-subitems {
  display: none; flex-direction: column; gap: 2px;
  margin: 2px 0 4px 16px; border-left: 2px solid var(--border); padding-left: 8px;
}
/* Direct child only — a nested .nav-group (e.g. Chatbot under Sites) needs its
 * OWN .expanded class for its sub-items to show, not just its ancestor's. */
.nav-group.expanded > .nav-subitems { display: flex; }
.nav-subitems .nav-subitems { margin-left: 10px; }
.nav-item-sub { font-size: 12.5px; padding: 7px 12px; }
.nav-spacer { flex: 1; }
.nav-user {
  border-top: 1px solid var(--border); padding: 12px 10px 0; margin-top: 8px;
  font-size: 12px; color: var(--text-muted);
}
.nav-user strong { display: block; color: var(--text); font-size: 13px; }
.link-btn {
  background: none; border: none; color: var(--primary); cursor: pointer;
  font-size: 12px; font-family: inherit; padding: 6px 0 0; text-decoration: underline;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--border);
}
.topbar .grow { flex: 1; }
.selector { position: relative; display: inline-flex; align-items: center; }
.selector select {
  padding: 7px 32px 7px 12px; background: #fff; color: var(--primary);
  border: 1.5px solid var(--primary); border-radius: 10px; font-size: 12.5px;
  font-weight: 600; cursor: pointer; outline: none; appearance: none;
  -webkit-appearance: none; font-family: inherit; height: 34px;
}
.selector select:disabled { color: var(--text-muted); border-color: var(--border); cursor: default; }
.selector svg { position: absolute; right: 9px; pointer-events: none; color: currentColor; }
.selector-label { font-size: 10.5px; color: var(--text-muted); margin-right: -4px; }
.content { padding: 22px; flex: 1; }

/* ── Generic building blocks ───────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 18px;
}
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.card .card-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.grid td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: none; }
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
}
.pill-green { background: #dcfce7; color: #15803d; }
.pill-grey  { background: #f1f5f9; color: var(--text-muted); }
.pill-amber { background: #fef3c7; color: #b45309; }
.pill-blue  { background: var(--primary-light); color: var(--primary-dark); }
.btn-sm {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: inherit; color: var(--text);
}
.btn-sm:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-sm.danger:hover { border-color: var(--red); color: var(--red); }
.btn-sm.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-sm.primary:hover { background: var(--primary-dark); color: #fff; }
/* Segmented tab toggle (e.g. Sites' Event page/Chat and language tabs) — the
 * INACTIVE state gets its own muted look rather than plain .btn-sm, so it
 * reads as "an unselected tab" and not as just another clickable action
 * button sitting next to the real one. */
.tab-toggle {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-muted); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.tab-toggle:hover { border-color: var(--primary); color: var(--primary-dark); }
.tab-toggle.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab-toggle.active:hover { background: var(--primary-dark); color: #fff; }
.input {
  padding: 8px 11px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: 13px; font-family: inherit; outline: none;
}
.input:focus { border-color: var(--primary); }
.empty { text-align: center; padding: 38px 10px; color: var(--text-muted); font-size: 13px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13px; z-index: 90; box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.toast.error { background: var(--red); }

/* Dashboard is embedded rather than ported — see views/dashboard.js. */
.dash-frame { width: 100%; height: calc(100vh - 128px); border: none; border-radius: var(--radius); background: var(--bg); }

/* ── History ───────────────────────────────────────────────────────────── */
.hist-entry { padding: 12px 0; border-bottom: 1px solid var(--border); }
.hist-entry:last-child { border-bottom: none; }
.hist-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.hist-actor { font-weight: 600; }
.hist-when { color: var(--text-muted); font-size: 11.5px; margin-left: auto; }
.hist-target { color: var(--text-muted); font-size: 12px; }
.diff { margin-top: 7px; font-size: 12px; }
.diff-row { display: flex; gap: 8px; padding: 3px 0; flex-wrap: wrap; align-items: baseline; }
.diff-field { font-weight: 600; min-width: 108px; }
.diff-old { color: var(--red); text-decoration: line-through; word-break: break-word; }
.diff-new { color: #15803d; word-break: break-word; }
.diff-arrow { color: var(--text-muted); }

/* ── Rankings ──────────────────────────────────────────────────────────── */
.rank-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 7px;
  background: #fff; cursor: grab;
}
.rank-row:active { cursor: grabbing; }
.rank-grip { color: var(--text-muted); font-size: 15px; letter-spacing: -2px; }
.rank-num {
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary-dark); font-size: 11.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rank-img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; background: #f8fafc; flex-shrink: 0; }
