/* ============ ADMIN LAYOUT ============ */
.admin-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }

.admin-side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px;
}
.admin-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: 1.5px; margin: -2px 0 18px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px;
  color: var(--muted); font-weight: 500;
}
.admin-nav a:hover { background: var(--surface-2); color: var(--text); }
.admin-nav a.active { background: rgba(225, 6, 0, .15); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-count { margin-left: auto; font-size: .75rem; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.nav-count:empty { display: none; }
.nav-count.alert { background: var(--accent); color: #fff; }
.admin-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: .85rem; color: var(--muted); }
.admin-side-foot a:hover { color: var(--text); }
.admin-side-foot .link-btn { text-align: left; color: var(--muted); font-weight: 500; }

.admin-main { padding: 24px clamp(16px, 3vw, 36px) 48px; min-width: 0; }
.admin-notice {
  margin: 0 0 20px; padding: 8px 12px; border-radius: 8px; font-size: .85rem;
  background: rgba(255, 180, 0, .1); border: 1px solid rgba(255, 180, 0, .3); color: #ffd679;
}
.admin-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-head h1 { font-family: var(--font-head); text-transform: uppercase; margin: 0 0 4px; font-size: 2rem; }
.admin-head .sub { max-width: 640px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; }
.stat strong { font-family: var(--font-head); font-size: 1.8rem; font-weight: 500; }
.stat.gold strong { color: var(--accent-2); }
.stat.alert { border-color: var(--accent); }
.stat.alert strong { color: var(--accent); }

.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
  padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--accent);
}
.bulk-bar span { font-weight: 600; margin-right: 6px; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 760px; }
.admin-table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: rgba(255, 255, 255, .02); }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .actions-col { text-align: right; white-space: nowrap; }
.admin-table .check-col { width: 36px; }
.admin-table a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.admin-table small { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.admin-table .empty { padding: 40px; }
.row-sponsored { box-shadow: inset 3px 0 0 var(--accent-2); }

.cell-video { display: flex; gap: 12px; align-items: center; }
.mini-thumb {
  flex: 0 0 96px; aspect-ratio: 16 / 9; border-radius: 6px; position: relative;
  background: var(--thumb-bg, #222);
}
.mini-thumb span { position: absolute; right: 4px; bottom: 3px; font-size: .65rem; background: rgba(0,0,0,.75); padding: 0 4px; border-radius: 3px; }
.cell-academy { max-width: 340px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.submitted { color: var(--accent-2) !important; }
.muted { color: var(--muted); }

.status-pill { font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status-pill.pending  { background: rgba(255, 180, 0, .15); color: #ffd679; }
.status-pill.approved { background: rgba(34, 197, 94, .15); color: #6ee7a0; }
.status-pill.rejected { background: rgba(255, 255, 255, .08); color: var(--muted); }

.rel-badge {
  display: inline-block; margin-top: 4px; font-size: .68rem; font-weight: 600; font-family: ui-monospace, monospace;
  padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted);
}
.rel-badge.follow { background: rgba(34, 197, 94, .15); color: #6ee7a0; }

.row-actions { display: inline-flex; gap: 6px; }

/* ============ BUTTONS & SWITCH ============ */
.btn-sm { padding: 6px 10px; font-size: .8rem; border-radius: 6px; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-danger { background: transparent; color: #ff6b66; border: 1px solid rgba(255, 107, 102, .4); }
.btn-danger:hover { background: rgba(255, 107, 102, .12); }
.btn-approve { background: #16a34a; color: #fff; }
.btn-approve:hover { filter: brightness(1.1); }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: background .2s; }
.slider::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: var(--muted); border-radius: 50%; transition: transform .2s, background .2s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .slider { opacity: .35; }

.help { color: var(--muted); font-size: .82rem; margin-top: 12px; }

/* ============ DIALOG ============ */
.admin-dialog {
  width: min(560px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text);
}
.admin-dialog::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(2px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-family: var(--font-head); text-transform: uppercase; font-size: 1.4rem; }
.dialog-close { background: none; border: 0; color: var(--muted); font-size: 1.1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--muted); font-weight: 500; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid input:not([type=checkbox]), .form-grid select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font: inherit; font-size: .92rem;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--accent); }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form-grid input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.form-error { color: #ff6b66; font-size: .85rem; margin: 0 20px; min-height: 1.2em; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 20px; }

/* ============ TOAST ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100;
  display: flex; gap: 16px; align-items: center; max-width: calc(100% - 32px);
  background: #26262f; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: .9rem;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-side {
    position: sticky; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: 10px 16px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border); z-index: 10;
  }
  .admin-label { margin: 0; }
  .admin-nav { flex-direction: row; }
  .admin-side-foot { margin: 0 0 0 auto; flex-direction: row; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .admin-side-foot { margin-left: 0; width: 100%; }
}

/* Listing table: keep it compact so actions stay visible */
.cell-academy { max-width: 280px; min-width: 220px; }
.admin-table small.clamp { display: -webkit-box; }
.admin-table small.submitted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-table td:has(.rel-badge) a { display: inline-block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.rel-badge { display: block; width: fit-content; }
#listing-rows .actions-col { white-space: normal; }
#listing-rows .row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 180px; margin-left: auto; }
.admin-table th, .admin-table td { padding-inline: 12px; }

/* Phones: each table row becomes a card with labelled fields */
@media (max-width: 720px) {
  .admin-table { min-width: 0; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; }
  .admin-table tr { position: relative; padding: 14px; border-bottom: 1px solid var(--border); }
  .admin-table tr:last-child { border-bottom: 0; }
  .admin-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
  .admin-table td[data-label]::before {
    content: attr(data-label); flex: 0 0 auto; text-align: left;
    color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
  }
  .admin-table td:first-child:not(.check-col), .admin-table .cell-academy { display: block; text-align: left; padding-bottom: 10px; }
  .admin-table .cell-academy { max-width: none; min-width: 0; padding-right: 32px; }
  .admin-table .check-col { position: absolute; top: 14px; right: 14px; width: auto; padding: 0; }
  .admin-table .actions-col { justify-content: flex-end; padding-top: 10px; }
  #listing-rows .row-actions { max-width: none; }
  .admin-table td:has(.rel-badge) a { max-width: 200px; }
  .rel-badge { margin-left: auto; }
  .admin-table .empty { display: block; text-align: center; }
  .admin-toolbar .search { width: 100%; }
}

/* User-submitted content: review status, payment state, real thumbnails */
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.cell-video .status-pill { display: inline-block; margin-top: 6px; }
.pay-line.paid { color: #6ee7a0 !important; }
.pay-line.unpaid { color: #ff8a85 !important; }
#video-rows .row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

/* Narrow phones: keep the nav to one swipeable row so the page never scrolls sideways */
@media (max-width: 520px) {
  .admin-nav { width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .admin-nav a { flex: none; white-space: nowrap; padding: 8px 10px; }
}

/* ============ ORGANIZATIONS + FIGHTERS ============ */
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.head-actions .btn { display: inline-flex; align-items: center; }
.short-badge {
  display: inline-block; vertical-align: 1px; margin-left: 4px; font-size: .68rem; font-weight: 700;
  padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); text-transform: uppercase;
}
.status-pill.champ { background: rgba(255, 180, 0, .15); color: #ffd679; }
.admin-filters label { flex: 0 1 auto; }
.admin-filters select { min-width: 190px; }
#org-rows .row-actions, #fighter-rows .row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
#org-rows .row-actions .btn { text-decoration: none; }

.form-section {
  margin: 6px 0 -4px; padding-top: 8px; border-top: 1px solid var(--border);
  font-family: var(--font-head); text-transform: uppercase; letter-spacing: .5px; font-size: .95rem; color: var(--text);
}
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section small { font-family: var(--font-body); text-transform: none; color: var(--muted); letter-spacing: 0; font-size: .78rem; }
.field-help { color: var(--muted); font-size: .74rem; font-weight: 400; }
#fighter-dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 32px); }
.form-grid select:disabled { opacity: .5; }

@media (max-width: 720px) {
  .admin-filters { width: 100%; }
  .admin-filters label { flex: 1 1 140px; }
  .admin-filters select { min-width: 0; width: 100%; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; justify-content: center; }
}

/* ============ ARTICLES ============ */
#article-dialog { width: min(640px, calc(100% - 32px)); max-height: calc(100vh - 32px); }
.form-grid textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font: inherit; font-size: .92rem; resize: vertical; line-height: 1.5;
}
.form-grid textarea:focus { outline: none; border-color: var(--accent); }
.image-field { display: grid; grid-template-columns: 220px 1fr; gap: 14px; align-items: start; }
.image-preview { border-radius: 8px; border: 1px solid var(--border); }
.image-preview .thumb-label { font-size: .8rem; }
.image-controls { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.image-controls label:not(.file-btn) { width: 100%; }
.file-btn { position: relative; cursor: pointer; flex-direction: row !important; color: var(--text) !important; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.image-controls .link-btn { color: #ff6b66; font-size: .82rem; }
.help code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .8rem; }
#article-rows .row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
#article-rows .row-actions .btn { text-decoration: none; }

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

/* ============ LISTING DIALOG ============ */
#listing-dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100vh - 32px); }
.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.char-count { align-self: flex-end; }
.form-grid label.check:has(input:disabled) { opacity: .45; }
.disc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.disc-chip { position: relative; cursor: pointer; }
.disc-chip input { position: absolute; opacity: 0; pointer-events: none; }
.disc-chip span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-size: .85rem; }
.disc-chip input:checked + span { background: rgba(225, 6, 0, .18); border-color: var(--accent); color: #fff; }
.disc-chip input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* Payments: code, reject reason box */
.pay-code { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; letter-spacing: .02em; }
.reject-box { display: grid; gap: 8px; min-width: 240px; }
.reject-box input { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; }

/* Events: fight card dialog */
.admin-dialog-wide { width: min(860px, calc(100vw - 32px)); }
.card-body { padding: 0 20px 20px; }
.card-bouts { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.card-bout { display: grid; grid-template-columns: 52px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.card-bout.editing { border-color: var(--accent-2); }
.card-pos { font-size: .75rem; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.card-fight small, .card-result small { display: block; color: var(--muted); font-size: .78rem; }
.bout-form { border-top: 1px solid var(--border); padding-top: 12px; }
@media (max-width: 700px) { .card-bout { grid-template-columns: 1fr; } }
