/* Shared design tokens — single source of truth for the color values that
   used to be hardcoded independently in the admin layout, the public
   join/verify layout, and join.html. Each of those pages still owns its
   own page-specific layout rules, but references these variables instead
   of repeating hex codes. */
:root {
  color-scheme: dark;
  --bg: #1e1f22;
  --surface: #2b2d31;
  --surface-hover: #35373c;
  --surface-alt: #3a3c42;
  --border: #1e1f22;
  --text: #f2f3f5;
  --text-muted: #b5bac1;
  --text-faint: #80848e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #23a559;
  --danger: #f23f42;
  --warning: #f5a623;
  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "gg sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ==== Admin portal ==== */

.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.sidebar {
  width: 252px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 14px;
}
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}
.brand-text {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 12px 16px;
  overflow-y: auto;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-bottom {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--surface-alt);
}
.nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 16px 10px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 500;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.nav-link svg {
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.nav-link:hover svg {
  opacity: 1;
}
.nav-link.active {
  background: rgba(88, 101, 242, 0.16);
  color: #fff;
}
.nav-link.active svg {
  opacity: 1;
  color: var(--accent);
}

.sidebar-backdrop {
  display: none;
}

/* ---- Topbar + content ---- */

.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.topbar-spacer {
  flex: 1;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
  font-size: 0.8rem;
}
.account-chip .user {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Hamburger toggle — hidden on wide viewports, shown only in the mobile
   media query below. Pure CSS icon (3 bars), no image asset needed. */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle:hover {
  background: var(--surface-hover);
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
}

main {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 28px 64px;
}
h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
}
h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 34px 0 12px;
}

.flash {
  background: rgba(35, 165, 89, 0.15);
  border: 1px solid rgba(35, 165, 89, 0.4);
  color: var(--success);
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.flash-error {
  background: rgba(242, 63, 66, 0.15);
  border-color: rgba(242, 63, 66, 0.4);
  color: var(--danger);
}
.flash-warning {
  background: rgba(245, 166, 35, 0.15);
  border-color: rgba(245, 166, 35, 0.4);
  color: var(--warning);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.stat {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}
.stat:hover {
  background: var(--surface-hover);
  border-color: var(--surface-alt);
  transform: translateY(-1px);
}
.stat .value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stat .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Wrap a <table> in this so wide tables scroll horizontally on narrow
   viewports instead of clipping the page — a plain `table { display: block }`
   trick breaks column alignment between thead/tbody, so a real wrapper
   element is used instead. */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* ---- Card list (e.g. Game Day Events) ----
   A stacked card per row instead of a wide multi-column table — avoids the
   horizontal scroll a table with many columns forces on narrow viewports,
   and gives each row room for a label above its value. */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
.item-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.item-card-title {
  font-size: 0.98rem;
  font-weight: 700;
}
.item-card-title .hint {
  font-weight: 500;
  margin-left: 6px;
}
.item-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.item-card-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 16px;
  font-size: 0.85rem;
}
.item-card-meta .meta-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 3px;
}
.item-card-meta code {
  word-break: break-all;
}
.item-card details {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.87rem;
}
th,
td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:last-child td {
  border-bottom: none;
}
tbody tr {
  transition: background-color 0.1s ease;
}
tbody tr:hover {
  background: var(--surface-hover);
}
.empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 16px;
  text-align: center;
}
.actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.deny-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.deny-form textarea {
  min-height: 32px;
  max-width: 220px;
  padding: 6px 8px;
  font-size: 0.8rem;
  resize: vertical;
}

button,
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: filter 0.1s ease, transform 0.05s ease;
}
.btn-approve {
  background: var(--success);
  color: #fff;
}
.btn-deny {
  background: var(--danger);
  color: #fff;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
}
button:hover,
.btn:hover {
  filter: brightness(1.1);
}
button:active,
.btn:active {
  transform: translateY(1px);
}
button:disabled,
.btn:disabled {
  cursor: default;
  filter: none;
  opacity: 0.7;
  transform: none;
}
form.inline {
  display: inline;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 14px 0 6px;
}
label:first-child {
  margin-top: 0;
}
input[type="text"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  max-width: 400px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b5bac1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
}
textarea {
  width: 100%;
  max-width: 500px;
  min-height: 90px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.checkbox-row label {
  margin: 0;
  text-transform: none;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
}
.hint {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 4px;
}
code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ---- Search bar (e.g. Members page) ----
   A single-line icon + input + button group instead of a stacked
   label/input/button form — the button stretches to match the input's
   height for free via flex's default `align-items: stretch`. */
.search-bar {
  display: flex;
  gap: 10px;
  max-width: 560px;
  margin-bottom: 20px;
}
.search-input-wrap {
  position: relative;
  flex: 1;
}
.search-input-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
/* Scoped to .search-input-wrap so this reliably outranks the generic
   `input[type="search"]` rule above (attribute+type beats a single class). */
.search-input-wrap input[type="search"] {
  width: 100%;
  max-width: none;
  padding-left: 38px;
}
.search-bar .btn-primary {
  flex-shrink: 0;
  padding-left: 20px;
  padding-right: 20px;
}

/* ---- Channel picker (see admin.js buildChannelPicker) ----
   A searchable, categorized dropdown built on top of a hidden native
   <select data-channel-picker> — the select stays the real form field and
   the no-JS fallback; this is a pure progressive-enhancement layer. */
.channel-picker {
  position: relative;
  width: 100%;
  max-width: 400px;
}
.channel-picker-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.channel-picker-trigger:hover {
  border-color: var(--surface-alt);
}
.channel-picker-trigger[aria-expanded="true"] {
  border-color: var(--accent);
}
.channel-picker-icon {
  flex-shrink: 0;
  color: var(--text-faint);
}
.channel-picker-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-picker-value.placeholder {
  color: var(--text-faint);
}
.channel-picker-chevron {
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}
.channel-picker-trigger[aria-expanded="true"] .channel-picker-chevron {
  transform: rotate(180deg);
}

.channel-picker-menu {
  /* `display: none` by default so the `hidden` attribute admin.js toggles
     actually hides this — an unconditional `display: flex` here would
     override the UA [hidden] rule (author styles win over UA styles at
     equal specificity), leaving the menu stuck visibly open. */
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 8;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--surface-alt);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.channel-picker-menu:not([hidden]) {
  display: flex;
}
.channel-picker-search-wrap {
  position: relative;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.channel-picker-search-wrap svg {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
/* Scoped to .channel-picker-search-wrap (rather than just .channel-picker-search)
   so this reliably outranks the generic `input[type="search"]` rule above —
   an attribute+type selector is more specific than a single class, and would
   otherwise win and reset padding-left, pushing the text under the icon. */
.channel-picker-search-wrap .channel-picker-search {
  width: 100%;
  max-width: none;
  padding: 7px 10px 7px 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
.channel-picker-list {
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
}
.channel-picker-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 10px 8px 4px;
}
.channel-picker-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-size: 0.87rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
/* Same fix as .channel-picker-menu above: an unconditional `display: flex`
   outranks the UA [hidden] rule, so filtered-out options stayed visible. */
.channel-picker-option[hidden] {
  display: none;
}
.channel-picker-option svg {
  flex-shrink: 0;
  color: var(--text-faint);
}
.channel-picker-option:hover,
.channel-picker-option.highlighted {
  background: var(--surface-hover);
}
.channel-picker-option.active {
  background: rgba(88, 101, 242, 0.16);
  color: #fff;
}
.channel-picker-option.active svg {
  color: var(--accent);
}
.channel-picker-empty {
  padding: 14px 10px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-faint);
}

/* ---- Textarea #/@ mention autocomplete (see admin.js buildMentionAutocomplete) ---- */
.mention-autocomplete {
  position: relative;
}
.mention-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 8;
  min-width: 220px;
  max-width: 320px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--surface-alt);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
}
.mention-option {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.mention-option .trigger {
  color: var(--text-faint);
  flex-shrink: 0;
}
.mention-option:hover,
.mention-option.highlighted {
  background: var(--surface-hover);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-verified {
  background: rgba(35, 165, 89, 0.15);
  color: var(--success);
}
.badge-pending_review {
  background: rgba(245, 166, 35, 0.15);
  color: var(--warning);
}
.badge-rejected {
  background: rgba(242, 63, 66, 0.15);
  color: var(--danger);
}
.badge-unverified {
  background: rgba(128, 132, 142, 0.15);
  color: var(--text-faint);
}

/* Spacing utilities — replace ad hoc inline style="margin-top:Npx" */
.mt-xs {
  margin-top: 4px;
}
.mt-sm {
  margin-top: 8px;
}
.mt-md {
  margin-top: 16px;
}
.mt-lg {
  margin-top: 24px;
}

/* Keyboard-focus visibility (previously only plain inputs had any focus style) */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
.stat:focus-visible,
.nav-link:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
  }
  .sidebar-backdrop.open {
    display: block;
  }

  .nav-toggle {
    display: flex;
  }
  .topbar {
    padding: 12px 16px;
  }
  main {
    padding: 20px 16px 48px;
  }
  .account-chip .user {
    display: none;
  }
}

@media (max-width: 420px) {
  .brand-text {
    display: none;
  }
}
