/* ============ ADMIN ============ */

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.admin-nav-link {
  border: 1px solid var(--color-border-strong);
  background: #fff;
  color: var(--near-black-30);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 7px;
}

.admin-nav-link:hover {
  color: var(--near-black-30);
}

.admin-nav-link.is-current {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
}

.admin-nav-link.is-current:hover {
  color: #fff;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  font-weight: 700;
  color: var(--gray-50);
  background: var(--color-alt-bg);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table-actions {
  display: flex;
  gap: 14px;
}

.admin-link-danger {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-50);
  cursor: pointer;
}

.admin-link-danger:hover {
  color: var(--color-accent);
}

.admin-link-positive {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-50);
  cursor: pointer;
}

.admin-link-positive:hover {
  color: oklch(0.45 0.12 145);
}

.admin-status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
}

.admin-status-badge.is-pending {
  background: oklch(0.93 0.06 85);
  color: oklch(0.45 0.1 85);
}

.admin-status-badge.is-positive {
  background: oklch(0.93 0.08 145);
  color: oklch(0.4 0.1 145);
}

.admin-status-badge.is-negative {
  background: var(--color-alt-bg);
  color: var(--gray-50);
}

.admin-field-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.admin-license-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.admin-license-preview-image {
  max-width: 100%;
  max-height: 480px;
  width: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.admin-license-preview-frame {
  width: 100%;
  height: 600px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.admin-image-preview {
  max-width: 320px;
  width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

/* One tournament/bar gallery photo + its "削除 / Remove" link, stacked —
   shared/_tournament_result_fields' gallery_photos grid and admin/bars/edit's
   own bar-gallery display both wrap each thumbnail in this. */
.admin-gallery-photo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 168px;
}

.admin-gallery-photo .admin-image-preview {
  width: 168px;
  height: 120px;
  max-width: none;
  object-fit: cover;
}

.admin-empty {
  padding: 40px;
  text-align: center;
  color: var(--gray-50);
  font-size: 14px;
}

.admin-form {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 28px;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.admin-form-wide {
  max-width: 760px;
}

/* One attached badge in the admin bar edit page's badges panel. */
.admin-badge-row {
  border-top: 1px solid var(--color-border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-badge-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.admin-badge-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 640px) {
  .admin-field-row {
    grid-template-columns: 1fr;
  }
}

/* Tournament payout rows (shared/_tournament_payout_fields) — a repeatable
   place_from/place_to/amount/remove row, admin + owner tournament forms.
   Also shared by shared/_tournament_result_row_fields (tournament_results
   rows on the same forms) — same class, same shape.

   :not([hidden]) rather than a bare selector — this class's own
   display: grid would otherwise outrank the browser's
   [hidden] { display: none } default at equal specificity, since this
   stylesheet loads after the UA one. Without it, nested-fields#remove
   setting a row's `hidden` attribute had no visible effect — the row was
   correctly marked _destroy: "1" and would vanish on save, but stayed
   rendered on screen until then, reading as "delete doesn't work". */
.admin-payout-row:not([hidden]) {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr auto;
  gap: 12px;
  align-items: end;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.admin-payout-row:last-child {
  border-bottom: none;
}

.admin-payout-remove {
  height: 38px;
}

/* places_paid, admin + owner tournament forms — de-emphasized (not hidden,
   still directly editable) once a payout breakdown exists above it, since
   #effective_places_paid ignores it in that case. */
.admin-field--deemphasized {
  opacity: 0.55;
}

@media (max-width: 640px) {
  .admin-payout-row {
    grid-template-columns: 1fr 1fr;
  }
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-help-text {
  font-size: 12px;
  color: var(--gray-50);
  margin: 0;
}

.admin-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
}

/* Toggle-pill checkboxes — game_types and payment_methods only (the design's
   "ゲームタグ"/"支払い方法" chips), not every other checkbox in this app,
   which stays a plain native box + .admin-checkbox-label. Pure CSS, no JS:
   the real checkbox is visually hidden (kept in the tab order and still a
   flex item for :checked ~ nothing needed — the label is its very next
   sibling), and the following <label for> is styled as the pill, switching
   look via the adjacent-sibling :checked selector. The "✓ " prefix on a
   checked pill is a ::before pseudo-element, not duplicated server-rendered
   text, so it can't drift out of sync with the checkbox's actual state. */
.admin-pill-checkbox {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.admin-pill-label {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border-strong);
  background: #fff;
  color: var(--gray-50);
  font-weight: 700;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 20px;
  cursor: pointer;
  user-select: none;
}

.admin-pill-checkbox:checked + .admin-pill-label {
  background: oklch(0.95 0.03 30);
  border-color: oklch(0.82 0.09 30);
  color: oklch(0.42 0.14 27);
}

.admin-pill-checkbox:checked + .admin-pill-label::before {
  content: "✓ ";
}

.admin-pill-checkbox:focus-visible + .admin-pill-label {
  outline: 2px solid oklch(0.55 0.19 27);
  outline-offset: 2px;
}

.admin-label {
  font-size: 13px;
  font-weight: 700;
}

.admin-input,
.admin-select,
.admin-textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border-strong);
  background: #fff;
  color: var(--near-black-30);
  width: 100%;
}

.admin-textarea {
  resize: vertical;
  min-height: 90px;
}

.admin-form-actions {
  display: flex;
  gap: 12px;
}

/* Structured opening-hours editor (shared/_opening_hours_fields) */
.opening-hours-hint {
  margin: 4px 0 10px;
  line-height: 1.5;
}

.opening-hours-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opening-hours-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.opening-hours-day {
  font-size: 13px;
  font-weight: 700;
  width: 72px;
  flex-shrink: 0;
}

.opening-hours-closed {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 400;
  width: 130px;
  flex-shrink: 0;
}

.opening-hours-times {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opening-hours-time {
  width: 84px;
  text-align: center;
}

.opening-hours-dash {
  color: var(--gray-50);
}

.admin-review-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

/* Left at the default `stretch` above (not `align-items: flex-start`) so
   .admin-field/.admin-textarea inside still fill the form's width the
   same way they do in .admin-form elsewhere — see the admin license
   preview's own align-items gotcha for why that default matters here.
   The submit button is the one direct child that should size to its own
   content instead of stretching full-width, so it opts out individually. */
.admin-review-form > .btn {
  align-self: flex-start;
}

.admin-errors {
  background: oklch(0.95 0.05 27);
  border: 1px solid oklch(0.75 0.12 27);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: oklch(0.4 0.15 27);
}

.admin-errors p {
  margin: 0 0 6px;
  font-weight: 700;
}

.admin-errors ul {
  margin: 0;
  padding-left: 18px;
}

/* A light-themed content block on an admin page below the main form/table —
   currently just the event edit page's tournament-schedule section. */
.admin-card {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

.admin-card-head {
  margin-bottom: 12px;
}

.admin-card-title {
  font-weight: 700;
  font-size: 14px;
}

/* admin/shared/_csv_import — template download + upload form, with an
   inline error list on failure (bars index, events index, and the
   per-event tournament-schedule import on events#edit). */
.admin-csv-import {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.admin-csv-import-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--gray-45);
}

.admin-csv-import-hint {
  margin: 6px 0 14px;
  font-size: 13px;
  color: var(--gray-50);
}

.admin-csv-import-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.admin-csv-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.admin-stat-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--color-accent);
  line-height: 1;
}

.admin-stat-label {
  font-size: 12px;
  color: var(--gray-50);
}

.admin-dashboard-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.admin-dashboard-col {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 20px;
}

.admin-dashboard-col-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-dashboard-col-header h2 {
  font-size: 15px;
  margin: 0;
}

.admin-mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-mini-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.admin-mini-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.admin-mini-list-meta {
  color: var(--gray-50);
  font-size: 12px;
  white-space: nowrap;
}

/* Admin analytics — reuses the dashboard stat/column/mini-list components;
   only needs a caption style and vertical rhythm between stacked rows. */
.admin-analytics-note {
  font-size: 12px;
  color: var(--gray-50);
  margin: 0 0 20px;
}

.admin-analytics-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

