/*
  Roster Management page -- Version 3.

  Loaded alongside styles/v3-app-shell.css in v3.html (after it, so the
  --v3-* custom properties it defines are already in scope) -- this file
  never redefines them and never touches css/styles.css, the legacy Phase
  9.7 stylesheet. Every rule is scoped under [data-roster-management-root]
  or a .v3-roster-* class that the roster *import* modal's own
  .v3-roster-import-* namespace never uses, so the two roster surfaces are
  styled independently and neither can bleed into the other, the app shell,
  or the Force Measurement dashboard's .v3-fm-* styles.

  Responsive strategy: the filter bar and summary cards are auto-fitting
  grids that collapse to a single column on narrow viewports, and the table
  itself scrolls horizontally inside its own wrapper rather than forcing the
  page body to scroll sideways.
*/

[data-roster-management-root] {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-5);
}

/* ------------------------------------------------------------------ */
/* Summary cards                                                       */
/* ------------------------------------------------------------------ */

.v3-roster-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--v3-space-3);
  margin: 0;
}

.v3-roster-summary-card {
  padding: var(--v3-space-4);
  background: var(--v3-surface-muted);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-md);
  border-left: 4px solid var(--v3-maroon);
}

.v3-roster-summary-card--activeAthletes {
  border-left-color: #1e5631;
}

.v3-roster-summary-card--inactiveAthletes {
  border-left-color: var(--v3-border-strong);
}

.v3-roster-summary-card--positions {
  border-left-color: var(--v3-maroon-light);
}

.v3-roster-summary-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--v3-text-muted);
}

.v3-roster-summary-value {
  margin: var(--v3-space-1) 0 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--v3-text);
}

/* ------------------------------------------------------------------ */
/* Filter bar                                                          */
/* ------------------------------------------------------------------ */

.v3-roster-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: end;
  gap: var(--v3-space-3);
  padding: var(--v3-space-4);
  background: var(--v3-surface);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-md);
}

.v3-roster-filter-field {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-2);
  min-width: 0;
}

.v3-roster-filter-field label {
  font-size: 0.85rem;
  font-weight: 600;
}

.v3-roster-filter-field input,
.v3-roster-filter-field select {
  font: inherit;
  padding: var(--v3-space-2) var(--v3-space-3);
  border: 1px solid var(--v3-border-strong);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface);
  color: var(--v3-text);
  min-width: 0;
}

.v3-roster-filter-actions {
  display: flex;
  align-items: flex-end;
}

[data-roster-management-root] :focus-visible {
  outline: 2px solid var(--v3-focus-ring);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Status region                                                       */
/* ------------------------------------------------------------------ */

.v3-roster-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--v3-text-muted);
}

/* ------------------------------------------------------------------ */
/* Table                                                               */
/* ------------------------------------------------------------------ */

.v3-roster-table-wrap {
  overflow-x: auto;
  /* Without this the wrapper is sized by its own content, so `overflow-x`
     never engages and a wide table pushes the whole page sideways instead of
     scrolling inside its box. The Sprint 1080, Readiness, Reports, and System
     Health wrappers already declare it; these two did not. */
  max-width: 100%;
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-md);
  background: var(--v3-surface);
  /* P11. `overflow-x: auto` makes this box scroll its own content, and it does
     -- the wrapper measures ~338px at a 420px viewport while its table is over
     1000px wide. What it did *not* do is stop that scrollable overflow being
     counted into the root scroller, so the page itself still scrolled sideways
     by ~620px with nothing visibly outside the viewport.

     Measured, not guessed: at 420px every other candidate left
     `document.scrollWidth` at 1043 -- `min-width: 0` on the wrapper and on its
     flex parent, `width: 100%`, `flex: 1 1 0%`, `display: block` on the parent,
     `overflow: hidden` on the parent, `overflow-x: clip` on the parent and on
     the panel, and `contain: inline-size`. Only paint containment brought it to
     420. It makes this box a paint boundary, so its overflow can no longer
     contribute to an ancestor's scrollable area.

     Safe here specifically: nothing inside is absolutely positioned, and the
     sticky table header stays sticky because it positions against this
     wrapper, which is the scroll container either way. */
  contain: paint;
}

.v3-roster-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.v3-roster-th {
  position: sticky;
  top: 0;
  padding: var(--v3-space-3);
  text-align: left;
  white-space: nowrap;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--v3-text-muted);
  background: var(--v3-surface-muted);
  border-bottom: 1px solid var(--v3-border-strong);
}

.v3-roster-td {
  padding: var(--v3-space-3);
  border-bottom: 1px solid var(--v3-border);
  vertical-align: middle;
}

.v3-roster-row:last-child .v3-roster-td {
  border-bottom: 0;
}

.v3-roster-row:hover .v3-roster-td {
  background: var(--v3-surface-muted);
}

.v3-roster-td--athleteId {
  font-variant-numeric: tabular-nums;
  color: var(--v3-text-muted);
}

.v3-roster-td--jersey,
.v3-roster-td--height,
.v3-roster-td--weight {
  font-variant-numeric: tabular-nums;
}

.v3-roster-td--fullName {
  font-weight: 600;
  white-space: nowrap;
}

.v3-roster-status-badge {
  display: inline-block;
  padding: 2px var(--v3-space-2);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--v3-surface-muted);
  border: 1px solid var(--v3-border-strong);
  color: var(--v3-text-muted);
}

.v3-roster-status-badge--active {
  background: #e6f4ea;
  border-color: #a8d5b5;
  color: #1e5631;
}

.v3-roster-status-badge--inactive {
  background: #f3f4f6;
  border-color: var(--v3-border-strong);
  color: var(--v3-text-muted);
}

/* ------------------------------------------------------------------ */
/* Row actions (disabled placeholders until an editing milestone)      */
/* ------------------------------------------------------------------ */

.v3-roster-td--actions {
  white-space: nowrap;
}

.v3-roster-action {
  font: inherit;
  font-size: 0.8rem;
  padding: var(--v3-space-1) var(--v3-space-3);
  margin-right: var(--v3-space-2);
  border: 1px solid var(--v3-border-strong);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface);
  color: var(--v3-text);
  cursor: pointer;
}

.v3-roster-action[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
  background: var(--v3-surface-muted);
  color: var(--v3-text-muted);
}

/* ------------------------------------------------------------------ */
/* Empty states                                                        */
/* ------------------------------------------------------------------ */

.v3-roster-empty {
  padding: var(--v3-space-6) var(--v3-space-5);
  text-align: center;
  background: var(--v3-surface);
  border: 1px dashed var(--v3-border-strong);
  border-radius: var(--v3-radius-md);
}

.v3-roster-empty-title {
  margin: 0;
  font-weight: 600;
}

.v3-roster-empty-body {
  margin: var(--v3-space-2) 0 0;
  color: var(--v3-text-muted);
  font-size: 0.88rem;
}

/* ------------------------------------------------------------------ */
/* Pagination                                                          */
/* ------------------------------------------------------------------ */

.v3-roster-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--v3-space-3);
}

.v3-roster-page-label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--v3-text-muted);
}

.v3-roster-page-label:focus-visible {
  outline: 2px solid var(--v3-focus-ring);
  outline-offset: 2px;
}

.v3-roster-pagination .v3-button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (max-width: 720px) {
  .v3-roster-pagination {
    justify-content: space-between;
  }

  .v3-roster-summary-value {
    font-size: 1.4rem;
  }
}
