/* ============================================================
   Admin > People > Bans.
   Layered on top of panel.css. Only .bn-* classes are introduced, and the
   filter bar and results header reuse the Users tab classes so both tabs look
   and behave the same.
   ============================================================ */

/* The tab sits inside sidebar + panel padding, so it is often only 550-750px
   wide on a desktop. Layout follows the space the tab really has (container
   queries), not the window width, and nothing may scroll sideways. */
.bn {
  display: grid;
  gap: 18px;
  min-width: 0;
  container: bans / inline-size;
}

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

.bn-sub { display: block; margin-top: 2px; color: var(--td); font-size: 11px; line-height: 1.45; }
.bn-muted-strong { color: var(--td); font-weight: 600; }
.bn-hint { margin: 10px 0 0; color: var(--td); font-size: 12px; }
.bn-error { margin: 10px 0 0; color: #ff8c97; font-size: 12.5px; }
.bn-req { color: #f66b79; }

/* ── Header ── */
.bn-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.bn-head h3 { margin: 3px 0 4px; color: #fff; font-size: 20px; letter-spacing: -.3px; }
.bn-head p { margin: 0; max-width: 62ch; color: var(--td); font-size: 12.5px; line-height: 1.6; }
.bn-new { flex: 0 0 auto; }

/* ── Stats ── */
.bn-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.bn-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 14px;
  background: rgba(255, 255, 255, .025);
}

.bn-stat-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(240, 56, 75, .1);
  color: #ff8c97;
  font-size: 15px;
}

.bn-stat > div { min-width: 0; }
.bn-stat > div strong { display: block; color: #fff; font-size: 22px; font-weight: 800; line-height: 1.1; }
.bn-stat > div span { display: block; color: var(--tm); font-size: 12px; font-weight: 600; }
.bn-stat > div small { display: block; color: var(--td); font-size: 10.5px; margin-top: 1px; }

/* ── Filter bar ──
   Grid instead of the shared flex-wrap, so the button never ends up alone on
   a row. Wide: one row. Medium: search on top, then status/source/button. */
.bn .bn-filterbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 0;
}

.bn .bn-filterbar .admin-search-field { grid-column: 1 / -1; }
.bn .bn-filterbar .admin-search-button { align-self: end; }

.bn-seg {
  display: flex;
  height: 46px;
  box-sizing: border-box;
  padding: 3px;
  border: 1px solid rgba(240, 74, 96, .3);
  border-radius: 8px;
  background: var(--g);
}

.bn-seg button {
  flex: 1 1 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--td);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.bn-seg button:hover { color: #fff; }
.bn-seg button.active { background: rgba(240, 56, 75, .22); color: #fff; }
.bn-seg button:focus-visible { outline: 2px solid rgba(240, 56, 75, .7); outline-offset: 1px; }

/* ── Table ── */
.bn-list {
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 14px;
  background: rgba(255, 255, 255, .015);
  overflow: hidden;
}

.bn-table-wrap { overflow: hidden; }

.bn-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.bn-table th {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: var(--td);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .9px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Fixed widths for the short columns; the reason takes whatever is left, so
   the table always fits its container exactly. */
.bn-table th:nth-child(1) { width: 24%; }
.bn-table th:nth-child(3) { width: 100px; }
.bn-table th:nth-child(4) { width: 112px; }
.bn-table th:nth-child(5) { width: 118px; }
.bn-table th.bn-th-actions { width: 58px; }

.bn-table td {
  padding: 13px 12px;
  min-width: 0;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, .04);
  color: var(--tm);
  font-size: 12.5px;
  vertical-align: middle;
}

.bn-table tbody tr:last-child td { border-bottom: 0; }
.bn-table td > span:not(.bn-chip):not(.bn-cat):not(.bn-reason-text) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The end date may take two lines instead of being cut off. */
.bn-table td:nth-child(5) > span:first-child:not(.bn-chip) { white-space: normal; line-height: 1.35; }
.bn-table .bn-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

.bn-row { cursor: pointer; transition: background .15s; }
.bn-row:hover td { background: rgba(255, 255, 255, .025); }
.bn-row:focus-visible { outline: 2px solid rgba(240, 56, 75, .6); outline-offset: -2px; }
.bn-row.is-lifted td { opacity: .55; }

.bn-user { display: flex; align-items: center; gap: 11px; min-width: 0; }
.bn-user > div { min-width: 0; }
.bn-user strong {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bn-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(240, 56, 75, .32), rgba(240, 56, 75, .08));
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.bn-reason { min-width: 0; }

/* Two lines at most; the full text is in the row's title and the detail view. */
.bn-reason-text {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.45;
}

.bn-actions { text-align: right; }

.bn-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 9px;
  background: rgba(255, 255, 255, .03);
  color: var(--tm);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.bn-icon-btn:hover { background: rgba(240, 56, 75, .14); border-color: rgba(240, 56, 75, .35); color: #fff; }
.bn-icon-btn:focus-visible { outline: 2px solid rgba(240, 56, 75, .7); outline-offset: 1px; }

.bn-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, .05);
  color: var(--td);
  font-size: 12px;
}

.bn-pager > div { display: flex; gap: 6px; }

.bn-empty, .bn-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 46px 20px;
  color: var(--td);
  font-size: 13px;
  text-align: center;
}

.bn-empty i { color: rgba(240, 56, 75, .55); font-size: 26px; }
.bn-empty p { margin: 0; }

/* ── Chips ── */
.bn-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: var(--tm);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.bn-chip i { font-size: 10px; }
.bn-src-client, .bn-src-auto { background: rgba(240, 56, 75, .13); color: #ff9aa4; }
.bn-src-manual { background: rgba(99, 102, 241, .14); color: #a5b4fc; }
.bn-src-legacy { background: rgba(255, 255, 255, .05); color: var(--td); }
.bn-perm { background: rgba(240, 56, 75, .1); color: #ffb3ba; }
.bn-banned { background: rgba(240, 56, 75, .18); color: #ff9aa4; }
.bn-ok { background: rgba(96, 220, 130, .12); color: #8be3a5; }
.bn-staff { background: rgba(245, 158, 11, .14); color: #fbbf24; }

.bn-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  color: #ff96a0;
  font-size: 11px;
  font-weight: 700;
}

.bn-cat i { font-size: 10px; opacity: .85; }
.bn-perm-text { color: #ff9aa4; font-weight: 700; }

/* ── Dialog ── */
.mb.bn-modal-box {
  box-sizing: border-box;
  max-width: 720px;
  width: min(720px, calc(100vw - 24px));
  padding: 26px 28px;
  overflow-x: hidden;
}

.bn-modal { display: grid; gap: 20px; min-width: 0; }
.bn-modal > *, #ban-form-area > * { min-width: 0; }
/* The form is injected after the lookup, so it needs its own spacing. */
#ban-form-area { display: grid; gap: 20px; }
#ban-form-area:empty { display: none; }
.bn-modal h3 { margin: 2px 0 0; font-size: 19px; }

.bn-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bn-head-tags { display: flex; align-items: center; gap: 10px; }

.bn-label {
  display: block;
  margin-bottom: 9px;
  color: rgba(255, 255, 255, .6);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .7px;
  text-transform: uppercase;
}

.bn-step { display: block; }
.bn-step .ig { margin: 0; }

.bn-lookup { display: flex; gap: 10px; }
.bn-lookup .ig { flex: 1 1 auto; min-width: 0; }
.bn-lookup .btn { flex: 0 0 auto; }

.bn-target {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 12px;
  background: rgba(255, 255, 255, .025);
}

.bn-target.is-banned { border-color: rgba(240, 56, 75, .32); background: rgba(94, 22, 28, .22); }
.bn-target-main { flex: 1 1 auto; min-width: 0; }
.bn-target-main strong { color: #fff; font-size: 14px; }
.bn-target-main .bn-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-target-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.bn-current {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, .22);
}

.bn-current p { margin: 8px 0 4px; color: var(--tm); font-size: 13px; line-height: 1.5; }

.bn-blocked, .bn-replace-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.5;
}

.bn-blocked { background: rgba(245, 158, 11, .08); color: #fcd34d; }
.bn-blocked p { margin: 0; }
.bn-replace-note { background: rgba(99, 102, 241, .1); color: #c7d2fe; }
.bn-replace-note strong { display: block; color: #fff; }
.bn-blocked i, .bn-replace-note i { margin-top: 3px; }

.bn-options { display: flex; flex-wrap: wrap; gap: 8px; }
.bn-options-cat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.bn-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 10px;
  background: rgba(255, 255, 255, .025);
  color: var(--tm);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.bn-option i { color: var(--td); font-size: 12px; }
.bn-option:hover { border-color: rgba(240, 56, 75, .35); color: #fff; }
.bn-option.active { border-color: rgba(240, 56, 75, .7); background: rgba(240, 56, 75, .16); color: #fff; }
.bn-option.active i { color: #ff9aa4; }
.bn-option:focus-visible { outline: 2px solid rgba(240, 56, 75, .7); outline-offset: 1px; }
.bn-option-sm { min-height: 36px; padding: 0 13px; font-size: 12px; }
.bn-option.is-perm.active { background: rgba(240, 56, 75, .26); }

.bn-custom { margin-top: 10px; max-width: 280px; }

.bn-textarea, .bn-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(240, 74, 96, .3);
  border-radius: 8px;
  background: var(--g);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.bn-textarea { min-height: 84px; padding: 11px 14px; line-height: 1.5; resize: vertical; }
.bn-input { height: 42px; padding: 0 14px; }
.bn-textarea:focus, .bn-input:focus { border-color: var(--p); box-shadow: 0 0 0 3px rgba(240, 56, 75, .2); }
.bn-textarea::placeholder, .bn-input::placeholder { color: #826a74; }

.bn-reason-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-top: 8px; }
.bn-templates { display: flex; flex-wrap: wrap; gap: 6px; }

.bn-template {
  padding: 5px 10px;
  border: 1px dashed rgba(255, 255, 255, .14);
  border-radius: 999px;
  background: transparent;
  color: var(--td);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.bn-template:hover { border-color: rgba(240, 56, 75, .45); color: #fff; }
.bn-counter { flex: 0 0 auto; color: var(--td); font-size: 11px; }

.bn-note-toggle summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--tm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.bn-note-toggle summary::-webkit-details-marker { display: none; }
.bn-note-toggle summary .bn-sub { display: inline; margin: 0 0 0 2px; }
.bn-note-toggle[open] summary { margin-bottom: 10px; }
.bn-note-toggle i { color: #fbbf24; font-size: 11px; }

.bn-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.bn-summary { color: var(--td); font-size: 12.5px; }
.bn-summary strong { color: #fff; }
.bn-footer-actions { display: flex; gap: 10px; margin-left: auto; }
.bn-submit.is-armed { background: #b91c1c; box-shadow: 0 0 0 3px rgba(239, 68, 68, .3); }

/* ── Detail ── */
.bn-detail-current {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(240, 56, 75, .25);
  border-radius: 14px;
  background: rgba(94, 22, 28, .18);
}

.bn-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.bn-detail-grid .bn-label { margin-bottom: 6px; }
.bn-detail-grid > div > span:not(.bn-label) { font-size: 12.5px; color: var(--tm); }
.bn-detail-reason { margin: 0; color: #fff; font-size: 13.5px; line-height: 1.55; }

.bn-note {
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(245, 158, 11, .08);
  color: #fcd34d;
  font-size: 12px;
  line-height: 1.5;
}

.bn-note i { margin-top: 3px; font-size: 10px; }

.bn-lift { padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .07); }
.bn-lift-row { display: flex; gap: 10px; }
.bn-lift-row .bn-input { flex: 1 1 auto; }
.bn-lift-row .btn { flex: 0 0 auto; }

.bn-detail-clear {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(96, 220, 130, .07);
  color: #8be3a5;
  font-size: 13px;
}

.bn-detail-clear .btn { margin-left: auto; }

.bn-timeline { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.bn-timeline li {
  position: relative;
  padding: 12px 14px 12px 18px;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 12px;
  background: rgba(255, 255, 255, .02);
}

.bn-timeline li::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
}

.bn-timeline li.is-active::before { background: #f0384b; }
.bn-timeline p { margin: 6px 0 4px; color: var(--tm); font-size: 13px; line-height: 1.5; }
.bn-tl-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bn-tl-top > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bn-lifted-line { color: #8be3a5; }
.bn-lifted-line i { font-size: 10px; margin-right: 3px; }
.bn-timeline .bn-note { margin-top: 8px; }

.bn-evidence { margin-top: 8px; }
.bn-evidence summary { cursor: pointer; color: var(--td); font-size: 11.5px; }

.bn-evidence dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(0, 0, 0, .28);
  font-size: 11.5px;
}

.bn-evidence dt { color: var(--td); text-transform: capitalize; }
.bn-evidence dd { margin: 0; color: #e4e4e7; word-break: break-all; }

/* ── Responsive ── */
/* Wide enough for one filter row. */
@container bans (min-width: 860px) {
  .bn .bn-filterbar { grid-template-columns: minmax(0, 1fr) 230px 190px auto; }
  .bn .bn-filterbar .admin-search-field { grid-column: auto; }
}

@container bans (max-width: 640px) {
  .bn-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container bans (max-width: 460px) {
  .bn .bn-filterbar { grid-template-columns: minmax(0, 1fr); }
  .bn .bn-filterbar .admin-search-button { width: 100%; }
  .bn-stats { gap: 8px; }
  .bn-stat { padding: 12px; gap: 10px; }
  .bn-stat-icon { width: 34px; height: 34px; }
  .bn-head { align-items: flex-start; }
  .bn-new { width: 100%; }
}

/* Too narrow for six columns: every ban becomes a card. */
@container bans (max-width: 680px) {
  .bn-table { table-layout: auto; }
  .bn-table thead { display: none; }
  .bn-table, .bn-table tbody { display: block; width: 100%; }
  .bn-table tr.bn-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 10px 12px;
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
  }
  .bn-table tbody tr.bn-row:last-child { border-bottom: 0; }
  .bn-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .bn-row:hover td { background: transparent; }
  .bn-table td:nth-child(1) { grid-column: 1 / 4; grid-row: 1; }
  .bn-table td.bn-actions { grid-column: 4; grid-row: 1; align-self: center; }
  .bn-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .bn-table td:nth-child(3) { grid-row: 3; }
  .bn-table td:nth-child(4) { grid-row: 3; }
  .bn-table td:nth-child(5) { grid-column: 3 / -1; grid-row: 3; }
}

/* Dialogs live outside the tab, so they still follow the window width. */
@media (max-width: 720px) {
  .bn-options-cat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bn-detail-grid { grid-template-columns: 1fr 1fr; }
  .bn-lookup, .bn-lift-row { flex-direction: column; }
  .bn-footer-actions { width: 100%; }
  .bn-footer-actions .btn { flex: 1 1 0; }
  .bn-detail-clear { flex-wrap: wrap; }
  .bn-detail-clear .btn { margin-left: 0; width: 100%; }
  .mb.bn-modal-box { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .bn-row, .bn-option, .bn-seg button, .bn-icon-btn { transition: none; }
}
