/* ==========================================================
   ACERSMP ADMIN PANEL
   Loads after nav.css / icons.css / light-theme.css.
   ========================================================== */

/*
 * border-box for this page only.
 *
 * Without it a field is width:100% PLUS its padding, because the
 * default is content-box: 100% of the card plus 42px of icon space and
 * 14px of breathing room, so every input hangs 56px out past the card
 * edge. nav.css sets this for .site-header alone, which does not cover
 * anything down here.
 *
 * .admin-page is listed FIRST on purpose: a `.foo *` rule matches
 * descendants, never the element itself, so the wrapper stayed
 * content-box and its padding was added on top of its width.
 */
.admin-page,
.admin-page *,
.admin-page *::before,
.admin-page *::after {
  box-sizing: border-box;
}

:root {
  --panel: rgba(12, 23, 39, .82);
  --line: rgba(138, 207, 255, .13);
  --blue: #59caff;
  --blue-bright: #8be0ff;
  --text: #eff8ff;
  --muted: #91a7bd;
  --green: #50dfa0;
  --amber: #ffc46b;
  --rose: #ff8f99;
  --violet: #a5abf8;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.admin-page {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 24px 70px;
}

/*
 * A rule that sets `display` beats the browser default for [hidden],
 * so every toggle below needs its own line or the staff gate, the
 * members tab and the reply box would never actually hide.
 */
.admin-page [hidden] { display: none !important; }

/* ---------- Gate ---------- */

.gate {
  display: grid;
  place-items: center;
  min-height: 60vh;
}

.gate-card {
  width: min(100%, 420px);
  padding: 40px 36px;
  text-align: center;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;

  box-shadow: 0 28px 70px rgba(0, 0, 0, .45);
}

.gate-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 22px;

  border-radius: 18px;
  background: rgba(255, 143, 153, .12);
  border: 1px solid rgba(255, 143, 153, .32);
  color: var(--rose);
}

.gate-icon .ic { width: 28px; height: 28px; }

.gate-card h1 {
  margin: 0 0 12px;
  font-size: clamp(22px, 4vw, 27px);
  font-weight: 900;
  letter-spacing: -1px;
}

.gate-card p {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.gate-button { text-decoration: none; }

/* ---------- Heading ---------- */

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;

  margin-bottom: 26px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 900;
  letter-spacing: -1.5px;
}

.page-heading h1 span { color: var(--amber); }

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  max-width: 50ch;
}

.subtitle strong { color: var(--blue-bright); }

.heading-stats { display: flex; gap: 10px; }

.mini-stat {
  min-width: 78px;
  padding: 11px 14px;
  text-align: center;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.mini-stat span {
  display: block;
  margin-bottom: 5px;

  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
}

.mini-stat strong {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.5px;
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;

  margin-bottom: 20px;

  padding-bottom: 0;

  border-bottom: 1px solid var(--line);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  min-height: 42px;
  padding: 0 16px;

  border: 0;
  border-bottom: 2px solid transparent;

  background: transparent;
  color: var(--muted);

  font-size: 12.5px;
  font-weight: 700;

  cursor: pointer;

  transition: color .2s ease, border-color .2s ease;
}

.tab .ic { width: 15px; height: 15px; }

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.panel[hidden] { display: none; }

/* ---------- Filters ---------- */

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;

  margin-bottom: 16px;
}

.filter {
  min-height: 34px;
  padding: 0 13px;

  border: 1px solid var(--line);
  border-radius: 999px;

  background: transparent;
  color: var(--muted);

  font-size: 11.5px;
  font-weight: 700;

  cursor: pointer;

  transition: color .2s ease, border-color .2s ease, background .2s ease;
}

.filter:hover { color: var(--text); }

.filter.active {
  color: var(--amber);
  border-color: rgba(255, 196, 107, .4);
  background: rgba(255, 196, 107, .1);
}

.search-input {
  width: min(100%, 320px);
  height: 36px;
  padding: 0 14px;

  color: var(--text);
  background: #081321;

  border: 1px solid var(--line);
  border-radius: 10px;

  font-size: 12.5px;
}

.search-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(89, 202, 255, .12);
}

/* ---------- Layout ---------- */

.columns {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.case[hidden] { display: none; }

.list-empty {
  padding: 30px 18px;
  text-align: center;

  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.7;

  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 14px;
}

/* ---------- Queue ---------- */

.queue { display: grid; gap: 8px; }

.queue-card {
  display: block;
  width: 100%;
  padding: 13px 14px;
  text-align: left;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;

  color: inherit;
  cursor: pointer;

  transition: border-color .2s ease, transform .2s var(--ease);
}

.queue-card:hover {
  border-color: rgba(255, 196, 107, .4);
  transform: translateY(-2px);
}

.queue-card.active {
  border-color: rgba(255, 196, 107, .55);
  background: rgba(255, 196, 107, .07);
}

.queue-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 6px;
}

.queue-ref {
  display: inline-flex;
  align-items: center;
  gap: 7px;

  color: var(--blue);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
}

.queue-subject {
  margin: 0 0 7px;
  min-width: 0;
  overflow-wrap: anywhere;

  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.45;

  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.queue-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  flex-wrap: wrap;

  min-width: 0;

  color: #64748b;
  font-size: 10.5px;
}

/*
 * The queue column is a fixed 320px, so a member's display name has to
 * be allowed to wrap or it pushes the card outside its own panel.
 */
.queue-foot > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.priority-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.priority-dot.high {
  background: var(--rose);
  box-shadow: 0 0 8px rgba(255, 143, 153, .5);
}

.priority-dot.normal { background: var(--blue); }
.priority-dot.low { background: #475569; }

/* ---------- Status pills ---------- */

.status-pill {
  flex: 0 0 auto;
  padding: 3px 9px;

  border-radius: 999px;

  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;

  white-space: nowrap;
}

.status-pill.open {
  background: rgba(80, 223, 160, .13);
  border: 1px solid rgba(80, 223, 160, .32);
  color: var(--green);
}

.status-pill.wait {
  background: rgba(255, 196, 107, .13);
  border: 1px solid rgba(255, 196, 107, .32);
  color: var(--amber);
}

.status-pill.closed {
  background: rgba(148, 163, 184, .12);
  border: 1px solid rgba(148, 163, 184, .28);
  color: #94a3b8;
}

/* ---------- Case ---------- */

.case {
  min-width: 0;
  padding: 22px;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.case-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;

  padding-bottom: 16px;
  margin-bottom: 16px;

  border-bottom: 1px solid var(--line);
}

.case-titles { flex: 1 1 240px; min-width: 0; }

.case-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;

  margin: 0 0 7px;

  color: var(--muted);
  font-size: 11px;
}

.case-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #475569;
}

.case-titles h2 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;

  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.4px;
}

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

.mini-select {
  /* Never wider than the row it sits in, however long the label. */
  max-width: 100%;
  min-width: 0;

  height: 34px;
  padding: 0 28px 0 11px;

  color: var(--text);
  background: #081321;

  border: 1px solid var(--line);
  border-radius: 9px;

  font-size: 11.5px;
  font-weight: 700;

  appearance: none;
  cursor: pointer;

  background-image:
    linear-gradient(45deg, transparent 50%, #6f8299 50%),
    linear-gradient(135deg, #6f8299 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.mini-select:focus {
  outline: none;
  border-color: var(--blue);
}

/* ---------- Messages ---------- */

.case-messages {
  display: grid;
  gap: 11px;

  max-height: 46vh;
  overflow-y: auto;

  padding-right: 4px;
  margin-bottom: 18px;

  scrollbar-width: thin;
  scrollbar-color: rgba(255, 196, 107, .3) transparent;
}

.case-messages::-webkit-scrollbar { width: 7px; }
.case-messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 196, 107, .25);
}

.message {
  max-width: 86%;
  padding: 12px 15px;

  border: 1px solid var(--line);
  border-radius: 13px;

  background: rgba(4, 9, 20, .35);
}

.message-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;

  margin-bottom: 6px;

  /*
   * The author is a member's own display name, up to 32 characters.
   * Without the shrink guard the flex row cannot narrow below it and
   * pushes the bubble, then the panel, past the edge.
   */
  min-width: 0;
}

.message-author {
  min-width: 0;
  overflow-wrap: anywhere;

  font-size: 11.5px;
  font-weight: 800;
}

.message-time {
  flex: 0 0 auto;

  color: #64748b;
  font-size: 10.5px;
}

.badge {
  padding: 2px 7px;
  border-radius: 999px;

  font-size: 9px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;

  white-space: nowrap;
}

.badge.staff {
  background: rgba(88, 101, 242, .16);
  border: 1px solid rgba(124, 133, 255, .4);
  color: var(--violet);
}

.badge.owner {
  background: rgba(255, 196, 107, .14);
  border: 1px solid rgba(255, 196, 107, .38);
  color: var(--amber);
}

.badge.member {
  background: rgba(89, 202, 255, .12);
  border: 1px solid rgba(89, 202, 255, .3);
  color: var(--blue-bright);
}

.message-body {
  margin: 0;
  min-width: 0;

  color: #cfe0f2;
  font-size: 13px;
  line-height: 1.72;

  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message.staff {
  margin-left: auto;
  border-color: rgba(124, 133, 255, .28);
  background: rgba(88, 101, 242, .08);
}

/* ---------- Reply ---------- */

.reply-as {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;

  margin-bottom: 10px;

  color: var(--muted);
  font-size: 11px;
}

.reply-box textarea {
  width: 100%;
  min-height: 88px;

  padding: 12px 14px;

  color: var(--text);
  background: #081321;

  border: 1px solid var(--line);
  border-radius: 10px;

  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;

  resize: vertical;
}

.reply-box textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(89, 202, 255, .12);
}

.form-message {
  margin: 10px 0 0;
  color: var(--rose);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.form-message:empty { display: none; }
.form-message.success { color: var(--green); }

.reply-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;

  min-height: 42px;
  padding: 0 18px;

  border: 0;
  border-radius: 10px;

  background: linear-gradient(120deg, #91e4ff, #49b9ff);
  color: #04111d;

  font-size: 12px;
  font-weight: 800;

  cursor: pointer;

  transition: transform .2s var(--ease), filter .2s ease;
}

.submit-button .ic { width: 15px; height: 15px; }
.submit-button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.05); }
.submit-button:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 42px;
  padding: 0 18px;

  border: 1px solid var(--line);
  border-radius: 10px;

  background: transparent;
  color: var(--muted);

  font-size: 12px;
  font-weight: 700;

  cursor: pointer;

  transition: color .2s ease, border-color .2s ease;
}

.ghost-button:hover { color: var(--blue); border-color: rgba(89, 202, 255, .4); }

/* ---------- Discord confirmation ---------- */

.verify-card {
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 28px;

  text-align: center;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;

  box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}

.verify-card[hidden] { display: none; }

.verify-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 20px;

  border-radius: 17px;
  background: rgba(88, 101, 242, .16);
  border: 1px solid rgba(124, 133, 255, .38);
  color: var(--violet);
}

.verify-icon .ic { width: 26px; height: 26px; }

.verify-card h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.5px;
}

.verify-card > p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.75;
}

.verify-sent {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.verify-sent[hidden] { display: none; }

.verify-sent-label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.verify-sent input {
  width: 100%;
  height: 54px;

  color: var(--blue-bright);
  background: #081321;

  border: 1px solid var(--line);
  border-radius: 12px;

  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
}

.verify-sent input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(89, 202, 255, .12);
}

.verify-note {
  margin: 0;
  color: #64748b;
  font-size: 11px;
}

.verify-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Permissions picker ---------- */

.member-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}

.member-block.has-permissions .member-row {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.perm-box {
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(4, 9, 20, .25);
}

.perm-head {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.perm-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;

  min-width: 0;
  padding: 9px 11px;

  border: 1px solid var(--line);
  border-radius: 10px;

  background: rgba(4, 9, 20, .3);

  cursor: pointer;

  transition: border-color .2s ease, background .2s ease;
}

.perm-row:hover {
  border-color: rgba(89, 202, 255, .35);
}

.perm-row input {
  flex: 0 0 auto;
  margin: 1px 0 0;

  width: 15px;
  height: 15px;

  accent-color: #59caff;
  cursor: pointer;
}

.perm-row span {
  min-width: 0;
  color: #cfe0f2;
  font-size: 12px;
  line-height: 1.5;
}

.perm-note {
  margin: 0 0 12px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.6;
}

.perm-save { width: auto; }

/* ---------- Members ---------- */

.owner-note {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;

  margin: 0 0 16px;
  padding: 12px 15px;

  border: 1px solid rgba(255, 196, 107, .28);
  border-radius: 12px;
  background: rgba(255, 196, 107, .07);

  color: var(--amber);
  font-size: 12px;
}

.owner-note .ic { width: 15px; height: 15px; }

.member-table { display: grid; gap: 8px; }

.member-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;

  padding: 13px 15px;

  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
}

.member-avatar {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;

  object-fit: cover;

  border-radius: 11px;
  border: 1px solid var(--line);

  background: #081321;
}

.member-info {
  flex: 1 1 200px;
  min-width: 0;
}

.member-info strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;

  font-size: 13px;
  font-weight: 800;
}

.member-info span {
  display: block;
  min-width: 0;

  color: var(--muted);
  font-size: 11px;

  overflow-wrap: anywhere;
}

.role-pill {
  flex: 0 0 auto;
  padding: 4px 11px;

  border-radius: 999px;

  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;

  white-space: nowrap;
}

.role-pill.user {
  background: rgba(148, 163, 184, .12);
  border: 1px solid rgba(148, 163, 184, .28);
  color: #94a3b8;
}

.role-pill.admin {
  background: rgba(88, 101, 242, .16);
  border: 1px solid rgba(124, 133, 255, .4);
  color: var(--violet);
}

.role-pill.owner {
  background: rgba(255, 196, 107, .14);
  border: 1px solid rgba(255, 196, 107, .38);
  color: var(--amber);
}

.role-pill[hidden] { display: none; }

/* ---------- Light theme ---------- */

body.light-theme {
  --panel: rgba(255, 255, 255, .9);
  --line: rgba(15, 40, 70, .12);
  --text: #0b1b2c;
  --muted: #4a5f75;
}

body.light-theme .search-input,
body.light-theme .mini-select,
body.light-theme .reply-box textarea { background: #fff; }

body.light-theme .message { background: rgba(15, 40, 70, .035); }
body.light-theme .message-body { color: #1d3346; }

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

@media (max-width: 960px) {
  .columns { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .admin-page { padding: 26px 15px 50px; }

  .heading-stats { width: 100%; }

  .mini-stat { flex: 1 1 0; }

  .case { padding: 17px 14px; }
  .case-actions { width: 100%; }
  .mini-select { flex: 1 1 0; }

  .tab { flex: 1 1 0; justify-content: center; padding: 0 10px; }

  .message { max-width: 95%; }

  .reply-actions { flex-direction: column; }
  .submit-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}