/*
  Force Measurement dashboard (Version 3 Phase 1 — Force Plate).

  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. Scoped entirely under .v3-fm-* / [data-force-measurement-*]
  selectors so it can never bleed into the rest of the shell.
*/

.v3-panel--force-measurement {
  max-width: none;
}

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

.v3-fm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--v3-space-3);
}

.v3-fm-validation {
  margin: 0;
  padding: var(--v3-space-2) var(--v3-space-3);
  border-radius: var(--v3-radius-sm);
  background: #fdecea;
  border: 1px solid #e0a3a3;
  color: #7a1f1f;
  font-size: 0.85rem;
  font-weight: 600;
}

.v3-fm-status {
  font-size: 0.82rem;
  color: var(--v3-text-muted);
}

.v3-fm-empty,
.v3-fm-error {
  padding: var(--v3-space-5);
  border-radius: var(--v3-radius-md);
  border: 1px dashed var(--v3-border-strong);
  background: var(--v3-surface-muted);
  color: var(--v3-text-muted);
  text-align: center;
}

.v3-fm-error {
  border-style: solid;
  border-color: #e0a3a3;
  background: #fdecea;
  color: #7a1f1f;
  text-align: left;
}

[data-force-measurement-content] {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-6);
}

.v3-fm-section-heading {
  margin: 0 0 var(--v3-space-3);
  font-size: 1rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------------- */
/* Team summary                                                            */
/* ---------------------------------------------------------------------- */

.v3-fm-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: var(--v3-space-4);
  margin: 0 0 var(--v3-space-4);
}

.v3-fm-summary-item {
  padding: var(--v3-space-3) var(--v3-space-4);
  border-radius: var(--v3-radius-sm);
  border: 1px solid var(--v3-border);
  background: var(--v3-surface-muted);
}

.v3-fm-summary-item dt {
  margin: 0 0 var(--v3-space-1);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--v3-text-muted);
}

.v3-fm-summary-item dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--v3-text);
}

.v3-fm-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--v3-space-3);
}

.v3-fm-metric-card {
  padding: var(--v3-space-3);
  border-radius: var(--v3-radius-sm);
  border: 1px solid var(--v3-border);
  background: var(--v3-surface);
}

.v3-fm-metric-label {
  margin: 0 0 var(--v3-space-1);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--v3-text-muted);
}

.v3-fm-metric-value {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--v3-maroon);
}

.v3-fm-metric-range {
  margin: var(--v3-space-1) 0 0;
  font-size: 0.75rem;
  color: var(--v3-text-muted);
}

/* ---------------------------------------------------------------------- */
/* Tables (position summary, athlete results, leaderboards)                */
/* ---------------------------------------------------------------------- */

.v3-fm-table-wrap {
  overflow-x: auto;
}

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

.v3-fm-table caption {
  text-align: left;
}

.v3-fm-table th,
.v3-fm-table td {
  padding: var(--v3-space-2) var(--v3-space-3);
  border-bottom: 1px solid var(--v3-border);
  text-align: left;
  white-space: nowrap;
}

.v3-fm-table thead th {
  background: var(--v3-surface-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--v3-text-muted);
}

.v3-fm-table tbody tr:hover {
  background: var(--v3-surface-muted);
}

.v3-fm-sort-button {
  display: flex;
  align-items: center;
  gap: var(--v3-space-1);
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}

.v3-fm-table th[aria-sort="ascending"] .v3-fm-sort-button::after {
  content: "▲";
  font-size: 0.65em;
}

.v3-fm-table th[aria-sort="descending"] .v3-fm-sort-button::after {
  content: "▼";
  font-size: 0.65em;
}

.v3-fm-note {
  color: var(--v3-text-muted);
  font-size: 0.88rem;
}

/* ---------------------------------------------------------------------- */
/* Leaderboards                                                            */
/* ---------------------------------------------------------------------- */

[data-force-measurement-leaderboards] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--v3-space-5);
}

/* A grid item defaults to `min-width: auto`, which means its track refuses to
   shrink below its widest content -- so a five-column leaderboard pushed the
   whole page wider than the viewport at narrow widths instead of scrolling
   inside its own wrapper. This is the standard remedy, and the same one
   `.v3-fm-*` cards already use elsewhere. */
.v3-fm-leaderboard {
  min-width: 0;
}

.v3-fm-leaderboard h4 {
  margin: 0 0 var(--v3-space-2);
  font-size: 0.88rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------------- */
/* Focus visibility for sortable header buttons and the reset control      */
/* ---------------------------------------------------------------------- */

.v3-fm-sort-button:focus-visible,
.v3-fm-toolbar .v3-button:focus-visible {
  outline: 3px solid var(--v3-focus-ring);
  outline-offset: 2px;
}

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

@media (max-width: 899px) {
  .v3-fm-summary-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 560px) {
  .v3-fm-summary-grid {
    grid-template-columns: 1fr;
  }

  [data-force-measurement-leaderboards] {
    grid-template-columns: 1fr;
  }

  .v3-fm-table {
    font-size: 0.82rem;
  }
}
