/* /static/css/player-stats.css — Player Stats cheat sheet table */

.ps-container {
  padding: 24px 20px 40px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ── Header + controls ─────────────────────────────────── */
.ps-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.ps-title {
  display: none;
}

.ps-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Button group (Last N / Split) */
.ps-btn-group {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ps-btn {
  background: rgba(255, 255, 255, 0.04);
  border: none;
  color: var(--theme-text-secondary, #8B949E);
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ps-btn:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.ps-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--theme-text-primary, #E6EDF3);
}

.ps-btn--active {
  background: rgba(0, 211, 189, 0.12);
  color: #00D3BD;
  border-color: rgba(0, 211, 189, 0.3);
}

.ps-btn--active:hover {
  background: rgba(0, 211, 189, 0.2);
  color: #00D3BD;
}

/* Position picker */
.ps-pos-picker {
  position: relative;
}

.ps-pos-popup {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  background: #141e30;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 200px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.ps-pos-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.ps-pos-chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--theme-text-secondary, #8B949E);
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 0;
  width: 56px;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, opacity 0.12s;
}

.ps-pos-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--theme-text-primary, #E6EDF3);
}

.ps-pos-chip--active {
  background: rgba(0, 211, 189, 0.12);
  color: #00D3BD;
  border-color: rgba(0, 211, 189, 0.3);
}

.ps-pos-grid:has(.ps-pos-chip:not(.ps-pos-chip--active)) .ps-pos-chip:not(.ps-pos-chip--active) {
  opacity: 0.35;
}

/* Standalone today-only toggle */
.ps-btn-today {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Team picker */
.ps-team-picker {
  position: relative;
}

.ps-team-popup {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  background: #141e30;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 380px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.ps-team-popup-header {
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--theme-text-secondary, #8B949E);
  margin-bottom: 10px;
}

.ps-team-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.ps-team-chip {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--theme-text-secondary, #8B949E);
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 4px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, opacity 0.12s;
}

.ps-team-chip-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.ps-team-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--theme-text-primary, #E6EDF3);
}

.ps-team-chip--active {
  background: rgba(0, 211, 189, 0.12);
  color: #00D3BD;
  border-color: rgba(0, 211, 189, 0.3);
}

/* Dim unselected chips when a subset is active */
.ps-team-grid:has(.ps-team-chip:not(.ps-team-chip--active)) .ps-team-chip:not(.ps-team-chip--active) {
  opacity: 0.35;
}

.ps-team-chip--active .ps-team-chip-logo {
  filter: none;
}

/* Dropdown selects */
.ps-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--theme-text-primary, #E6EDF3);
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
  padding: 10px 12px;
  cursor: pointer;
  appearance: auto;
}

.ps-select:focus {
  outline: none;
  border-color: var(--theme-accent, #00D3BD);
}

/* Inline position grid (always visible, no popup) */
.ps-pos-grid-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Drawer wrapper — preserves flex chain on desktop ──── */
.ps-drawer-handle { display: none; }
.ps-drawer-toggle-btn { display: none; }
.ps-drawer-body {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

/* Bottom row (team picker + reset) — inline on desktop */
.ps-bottom-row {
  display: contents;
}

.ps-btn-reset { display: none; }
.ps-btn-reset.ps-btn--dirty {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ── Table ──────────────────────────────────────────────── */
.ps-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ps-table {
  width: 100%;
  border-collapse: collapse;
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
  white-space: nowrap;
}

/* Sticky header — give th an opaque background so content
   scrolls cleanly underneath */
.ps-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #0d1b2a;
  color: var(--theme-text-secondary, #8B949E);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
}

/* Player header stays left-aligned */
.ps-table th.ps-col-player {
  text-align: left;
}

.ps-table th[data-col] {
  cursor: pointer;
  transition: color 0.15s;
}

.ps-table th[data-col]:hover {
  color: var(--theme-accent, #00D3BD);
}

.ps-table th.ps-sorted {
  color: var(--theme-accent, #00D3BD);
}

.ps-arrow {
  font-size: 10px;
  margin-left: 3px;
  vertical-align: middle;
}

.ps-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--theme-text-primary, #E6EDF3);
}

/* Zebra rows */
.ps-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Hover highlight */
.ps-table tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.ps-table tbody tr:hover {
  background: rgba(0, 211, 189, 0.06);
}

/* ── Column-specific ────────────────────────────────────── */
/* Player name cell (td only) — sticky left for horizontal scroll */
td.ps-col-player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  position: sticky;
  left: 0;
  z-index: 1;
}

/* Opaque backgrounds for the sticky player column so it covers
   horizontal-scrolled content underneath */
.ps-table tbody tr:nth-child(odd) td.ps-col-player {
  background: #0a1628;
}
.ps-table tbody tr:nth-child(even) td.ps-col-player {
  background: #0c1a30;
}
.ps-table tbody tr:hover td.ps-col-player {
  background: #0b1f30;
}

/* Player header cell — also sticky left */
th.ps-col-player {
  position: sticky;
  left: 0;
  z-index: 4; /* above both thead z-3 and td z-1 */
}

.ps-avatar-wrap {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.ps-headshot {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 50%;
}

.ps-team-badge {
  position: absolute;
  bottom: -3px;
  right: -6px;
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 50%;
  background: #060e1e;
  padding: 2px;
}

.ps-team-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.ps-name {
  font-weight: 600;
  color: var(--theme-text-primary, #E6EDF3);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Abbreviated name / rounded MPG hidden on desktop, shown on mobile */
.ps-name-short { display: none; }
.ps-mpg-short { display: none; }

.ps-pos-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.08);
  color: var(--theme-text-secondary, #8B949E);
}

.ps-today-chip,
.ps-inj-chip {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.2;
}

.ps-today-chip {
  background: rgba(0, 211, 189, 0.15);
  color: var(--theme-accent, #00D3BD);
}

.ps-inj-chip {
  background: rgba(255, 170, 51, 0.15);
  color: #ffaa33;
}

.ps-inj--gtd {
  background: rgba(255, 170, 51, 0.15);
  color: #ffaa33;
}

.ps-inj--probable {
  background: rgba(0, 211, 189, 0.12);
  color: #44d9b4;
}

.ps-inj--out {
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
}

.ps-col-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.ps-col-highlight {
  color: var(--theme-accent, #00D3BD);
  font-weight: 700;
}

/* ── Loading / Empty states ─────────────────────────────── */
.ps-loading,
.ps-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--theme-text-secondary, #8B949E);
  font-family: Inter, system-ui, sans-serif;
  font-size: 15px;
}

/* ── Light theme ────────────────────────────────────────── */
[data-theme="light"] .ps-table th {
  background: #f6f8fa;
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .ps-table td {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .ps-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .ps-table tbody tr:hover {
  background: rgba(0, 211, 189, 0.06);
}

[data-theme="light"] .ps-btn {
  background: rgba(0, 0, 0, 0.04);
  color: var(--theme-text-secondary, #656d76);
}

[data-theme="light"] .ps-select {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--theme-text-primary, #1f2328);
}

[data-theme="light"] .ps-team-popup {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .ps-team-chip {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--theme-text-secondary, #656d76);
}

[data-theme="light"] .ps-team-chip:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--theme-text-primary, #1f2328);
}

[data-theme="light"] .ps-team-chip--active {
  background: rgba(0, 180, 160, 0.1);
  color: #00917e;
  border-color: rgba(0, 180, 160, 0.3);
}

[data-theme="light"] .ps-pos-popup {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .ps-pos-chip {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--theme-text-secondary, #656d76);
}

[data-theme="light"] .ps-pos-chip--active {
  background: rgba(0, 180, 160, 0.1);
  color: #00917e;
  border-color: rgba(0, 180, 160, 0.3);
}

[data-theme="light"] .ps-table tbody tr:nth-child(odd) td.ps-col-player {
  background: #fff;
}
[data-theme="light"] .ps-table tbody tr:nth-child(even) td.ps-col-player {
  background: #f6f8fa;
}
[data-theme="light"] .ps-table tbody tr:hover td.ps-col-player {
  background: rgba(0, 211, 189, 0.06);
}
[data-theme="light"] th.ps-col-player {
  background: #f6f8fa;
}
[data-theme="light"] .ps-team-badge {
  background: #fff;
}
[data-theme="light"] .ps-pos-badge {
  background: rgba(0, 0, 0, 0.06);
  color: var(--theme-text-secondary, #656d76);
}
[data-theme="light"] .ps-today-chip {
  background: rgba(0, 180, 160, 0.12);
  color: #008577;
}
[data-theme="light"] .ps-inj-chip,
[data-theme="light"] .ps-inj--gtd {
  background: rgba(200, 130, 0, 0.12);
  color: #b37400;
}
[data-theme="light"] .ps-inj--probable {
  background: rgba(0, 160, 130, 0.1);
  color: #008060;
}
[data-theme="light"] .ps-inj--out {
  background: rgba(220, 60, 60, 0.12);
  color: #cc3333;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1000px) {

  /* Lock page scroll when drawer is open */
  body.ps-body-locked {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .ps-container {
    padding: 140px 0 32px;
  }

  .ps-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 32px;
  }

  .ps-title {
    display: none;
  }

  /* ── Filter drawer — fixed below navbar ─────────────── */
  .ps-filter-drawer {
    position: fixed;
    top: var(--ps-navbar-h, 74px) !important;
    left: 0;
    right: 0;
    z-index: 1100;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0 0 16px 16px;
    background: var(--bg-base, #060e1e);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .ps-drawer-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    height: 120px;
    flex-shrink: 0;
    padding: 0 24px;
    box-sizing: border-box;
    background: var(--bg-base, #060e1e);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    order: 2;
  }

  .ps-drawer-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    min-width: 72px;
    border-radius: 50%;
    border: 2px solid #00D3BD;
    background: rgba(0, 211, 189, 0.12);
    color: #00D3BD;
    font-size: 32px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, transform 0.15s;
  }

  .ps-drawer-toggle-btn:active {
    background: rgba(0, 211, 189, 0.25);
    transform: scale(0.92);
  }

  .ps-drawer-summary {
    font-size: 32px;
    font-weight: 600;
    color: var(--theme-text-primary, #E6EDF3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- Drawer body (scrollable content) --- */
  .ps-drawer-body {
    overflow-y: auto;
    max-height: 0;
    transition: max-height 0.3s ease;
    -webkit-overflow-scrolling: touch;
    order: 1;
    display: block;
    flex-wrap: nowrap;
    gap: 0;
  }

  .ps-filter-drawer.ps-drawer-open .ps-drawer-body {
    max-height: calc(70vh - 108px);
  }

  .ps-controls {
    width: 100%;
    gap: 28px;
    flex-direction: column;
    padding: 48px 32px 20px;
    box-sizing: border-box;
  }

  /* ── Buttons — 30px font, generous padding ──────────── */
  .ps-btn {
    font-size: 30px;
    padding: 18px 28px;
  }

  .ps-btn-group {
    border-radius: 16px;
    width: 100%;
    display: flex;
  }

  .ps-btn-group .ps-btn {
    flex: 1;
    text-align: center;
  }

  .ps-btn-today {
    border-radius: 16px;
    width: 100%;
    text-align: center;
    padding: 20px 28px;
  }

  /* ── Table 2x: 13px→26px ─────────────────────────────── */
  .ps-table {
    font-size: 26px;
  }

  .ps-table th {
    font-size: 24px;
    padding: 20px 20px;
    letter-spacing: 0.05em;
  }

  .ps-table td {
    padding: 16px 8px;
  }

  td.ps-col-player {
    padding-left: 4px;
  }

  /* ── Avatar 2x: 32px→64px ────────────────────────────── */
  .ps-avatar-wrap {
    width: 64px;
    height: 64px;
  }

  .ps-headshot {
    width: 64px;
    height: 64px;
  }

  .ps-team-badge {
    width: 36px;
    height: 36px;
    bottom: -4px;
    right: -8px;
    padding: 3px;
  }

  .ps-team-logo {
    width: 64px;
    height: 64px;
  }

  td.ps-col-player,
  th.ps-col-player {
    position: static;
  }

  td.ps-col-player {
    gap: 16px;
    min-width: auto;
    max-width: 320px;
  }

  .ps-name {
    font-size: 26px;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
  }

  .ps-name-short {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
  }

  /* ── Chips 2x: 9px→18px ──────────────────────────────── */
  .ps-pos-badge,
  .ps-today-chip,
  .ps-inj-chip {
    font-size: 18px;
    padding: 4px 12px;
    border-radius: 8px;
  }

  /* ── Arrow 2x ────────────────────────────────────────── */
  .ps-arrow {
    font-size: 20px;
    margin-left: 6px;
  }

  /* ── Loading/empty 2x ────────────────────────────────── */
  .ps-loading,
  .ps-empty {
    font-size: 30px;
    padding: 96px 32px;
  }

  .ps-table-wrap {
    border: none;
    border-radius: 0;
  }

  /* Abbreviated player names + rounded MPG on mobile */
  .ps-name-full { display: none; }
  .ps-name-short { display: inline; }
  .ps-mpg-full { display: none; }
  .ps-mpg-short { display: inline; }

  /* ── Bottom row: team picker + reset side by side ────── */
  .ps-bottom-row {
    display: flex;
    gap: 12px;
    width: 100%;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .ps-bottom-row .ps-team-picker {
    flex: 1;
    min-width: 0;
  }

  .ps-bottom-row .ps-team-popup {
    width: calc(100vw - 64px);
  }

  .ps-btn-reset {
    display: block;
    flex: 0 0 auto;
    width: auto;
    padding: 18px 24px;
  }

  /* ── Team popup — inline panel inside drawer ─────────── */
  .ps-team-picker {
    position: static;
    width: 100%;
  }

  .ps-team-popup {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    transform: none;
    min-width: 0;
    width: 100%;
    max-width: none;
    max-height: none;
    overflow-y: visible;
    padding: 20px;
    margin-top: 10px;
    border-radius: 16px;
    box-shadow: none;
  }

  .ps-team-popup-header {
    font-size: 26px;
    margin-bottom: 16px;
  }

  .ps-team-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
  }

  .ps-team-chip {
    font-size: 22px;
    padding: 14px 8px;
  }

  .ps-team-chip-logo {
    width: 54px;
    height: 54px;
  }

  /* ── Inline position chips ─────────────────────────────── */
  .ps-pos-grid-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    width: 100%;
  }

  .ps-pos-chip {
    font-size: 28px;
    padding: 16px 0;
    flex: 1;
    min-width: 0;
    border-radius: 14px;
  }

  /* ── Disable hover effects on mobile ─────────────────── */
  .ps-btn:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--theme-text-secondary, #8B949E);
  }

  .ps-btn--active:hover {
    background: rgba(0, 211, 189, 0.12);
    color: #00D3BD;
  }

  .ps-team-chip:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--theme-text-secondary, #8B949E);
  }

  .ps-team-chip--active:hover {
    background: rgba(0, 211, 189, 0.12);
    color: #00D3BD;
  }

  .ps-pos-chip:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--theme-text-secondary, #8B949E);
  }

  .ps-pos-chip--active:hover {
    background: rgba(0, 211, 189, 0.12);
    color: #00D3BD;
  }
}

/* ── Light theme — mobile drawer ───────────────────────── */
@media (max-width: 1000px) {
  [data-theme="light"] .ps-filter-drawer {
    background: #fff;
    border-bottom-color: rgba(0, 0, 0, 0.1);
  }

  [data-theme="light"] .ps-drawer-handle {
    background: #fff;
    border-top-color: rgba(0, 0, 0, 0.06);
  }

  [data-theme="light"] .ps-drawer-toggle-btn {
    border-color: #00b4a0;
    background: rgba(0, 180, 160, 0.1);
    color: #00917e;
  }
}
