/* Spelarstatistiktabeller för match-, historik- och säsongsvyer. */

/* Per-spelare-tabeller */
.player-stat-sections {
  display: grid;
  gap: 18px;
  padding: 2px 14px 16px;
}

.player-stat-group {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.player-stat-group--goalkeepers {
  border-color: #d7c49f;
}

.player-stat-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 8px;
  border-bottom: 1px solid var(--brand-edf1ee, #edf1ee);
}

.player-stat-group-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.player-stat-group--goalkeepers .player-stat-group-heading {
  background: #fffbf3;
}

.player-stat-group-heading h3,
.player-stat-group-heading p {
  margin-bottom: 0;
}

.player-stat-group-heading p {
  margin-top: 3px;
  font-size: 0.72rem;
}

.player-stat-group .table-scroll {
  padding: 0;
}

.stats-table--players {
  min-width: 1020px;
}

.player-stats-card {
  overflow: hidden;
}

.stats-table--goalkeepers {
  min-width: 1240px;
}

.stats-table--players thead tr:first-child th {
  border-bottom: 1px solid var(--brand-dce5df, #dce5df);
}

.stats-group-heading {
  background: var(--brand-eff7f2, #eff7f2);
  color: var(--green-800) !important;
  text-align: center !important;
}

.stats-group-heading--goalkeeper {
  background: #fff7e8;
  color: #805116 !important;
}

.stats-group-heading--technical,
.technical-stat-cell {
  background: #fff8ec;
}

.stats-table tbody tr:hover .technical-stat-cell {
  background: #fcf0da;
}

.technical-stat-cell--total {
  border-left: 2px solid #dfc397;
  color: #77470b;
  font-weight: 900;
}

.stats-group-heading--technical {
  border-left: 2px solid #dfc397;
  color: #77470b !important;
}

.history-metric--technical strong {
  color: #8a5510;
}

.card-subsection--players .player-stat-sections {
  padding-top: 8px;
}

.season-player-summary {
  gap: 18px;
}

/* Version 2.15.2: konsekventa tabellbredder och trunkerade namn */
.stats-table--aligned-players { table-layout: fixed; }
.stats-table--aligned-players.stats-table--outfield { width: 2148px; min-width: 100%; }
.stats-table--aligned-players.stats-table--goalkeepers { width: 1938px; min-width: 100%; }
.stats-table--aligned-players.stats-table--with-appearances.stats-table--outfield { width: 2234px; }
.stats-table--aligned-players.stats-table--with-appearances.stats-table--goalkeepers { width: 2024px; }
.player-stat-column--player { width: 224px; }
.player-stat-column--mep { width: 76px; }
.player-stat-column--compact { width: 68px; }
.player-stat-column--medium { width: 78px; }
.player-stat-column--goalkeeper-wide { width: 90px; }
.player-stat-column--wide { width: 112px; }
.player-stat-column--appearances { width: 86px; }
.player-stat-column--playing-time { width: 86px; }
.player-stat-column--status { width: 96px; }
.player-stat-column--technical { width: 76px; }

/* Version 2.15.3: säsongstabellerna använder matchvyns kompletta kolumnprofil */
.stats-table--season-outfield .mep-stat-cell {
  min-width: 76px;
  width: 76px;
  max-width: 76px;
  overflow: hidden;
}
.stats-table--season-outfield .season-appearances-stat-cell {
  min-width: 86px;
  width: 86px;
  max-width: 86px;
}
.stats-table--season-outfield .mep-stat-cell .season-sort-button,
.stats-table--season-outfield .season-appearances-stat-cell .season-sort-button {
  min-width: 0;
  overflow: hidden;
}
.stats-table--season-outfield .season-penalty-stat-cell { min-width: 112px; width: 112px; max-width: 112px; }
.stats-table--season-outfield .season-penalty-stat-cell .season-sort-button {
  justify-content: flex-end;
  white-space: normal;
  line-height: 1.12;
  text-align: right;
}

.season-sort-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 3px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 950;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.season-sort-button--left,
.stats-table--season-outfield th:first-child .season-sort-button {
  justify-content: flex-start;
}

.season-sort-button:hover,
.season-sort-button:focus-visible {
  outline: none;
  background: rgba(7, 95, 60, 0.08);
  color: var(--green-900);
}

.season-sort-active {
  color: var(--green-900) !important;
  background: var(--brand-eaf4ee, #eaf4ee);
}

.season-summary-toggle {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.season-summary-toggle-button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  cursor: pointer;
}
.season-summary-toggle-button:last-child { border-right: 0; }
.season-summary-toggle-button--active { background: var(--green-800); color: white; }

.season-player-summary .stats-table thead th:first-child,
.season-player-summary .stats-table tbody th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 224px;
  min-width: 224px;
  background: var(--surface);
  box-shadow: 2px 0 0 var(--line);
}

.season-player-summary .stats-table thead th:first-child { z-index: 5; }
.season-player-summary .stats-table tbody tr:hover th:first-child { background: var(--brand-f4faf6, #f4faf6); }
.season-player-summary .table-player {
  width: 100%;
  min-width: 0;
  grid-template-columns: 34px minmax(0, 1fr) max-content;
}
.season-player-summary .table-player strong { overflow: hidden; text-overflow: ellipsis; }
.season-player-summary .table-player small { justify-self: end; white-space: nowrap; }

.stats-table--season-goalkeepers { width: 958px; min-width: 958px; max-width: 958px; table-layout: fixed; }
.stats-table--season-goalkeepers th,
.stats-table--season-goalkeepers td { padding-left: 7px; padding-right: 7px; }
.stats-table--season-goalkeepers th:first-child,
.stats-table--season-goalkeepers td:first-child { min-width: 224px; width: 224px; }

.playing-time-stat-cell {
  color: var(--green-900);
  font-variant-numeric: tabular-nums;
}
.playing-time-stat-cell strong { font-weight: 950; }

/* Version 2.16.3: sortering i matchtabellen */
.stats-table--match-players .season-penalty-stat-cell .season-sort-button {
  justify-content: flex-end;
  white-space: normal;
  line-height: 1.12;
  text-align: right;
}

.season-position-filter {
  min-width: 112px;
}

.season-position-filter > span {
  font-size: 0.64rem;
}

.season-position-filter select {
  min-height: 34px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.history-player-stats .stats-table--outfield thead th:first-child,
.history-player-stats .stats-table--outfield tbody th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 224px;
  min-width: 224px;
  background: var(--surface);
  box-shadow: 2px 0 0 var(--line);
}

.history-player-stats .stats-table--outfield thead th:first-child { z-index: 5; }
.history-player-stats .stats-table--outfield tbody tr:hover th:first-child { background: var(--brand-f4faf6, #f4faf6); }

.player-stat-column--penalty-save-pct { width: 82px; }
.stats-table--season-goalkeepers {
  width: 1040px;
  min-width: 1040px;
  max-width: 1040px;
}

.season-column-toggle { display: flex; gap: 6px; margin: 10px 0; overflow-x: auto; }
.history-column-toggle { margin: 10px 16px; }
.stats-table--aligned-players.stats-table--outfield.stats-table--history-outfield {
  width: var(--history-outfield-table-width);
  min-width: var(--history-outfield-table-width);
}
.stats-table--aligned-players.stats-table--goalkeepers.stats-table--history-goalkeepers {
  width: 1050px;
  min-width: 1050px;
}
.history-focused-player-summary .stats-table thead th:first-child,
.history-focused-player-summary .stats-table tbody th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 224px;
  min-width: 224px;
  background: var(--surface);
  box-shadow: 2px 0 0 var(--line);
}
.history-focused-player-summary .stats-table thead th:first-child { z-index: 5; }
.history-focused-player-summary .stats-table tbody tr:hover th:first-child { background: var(--brand-f4faf6, #f4faf6); }
.history-focused-player-summary .table-player {
  width: 100%;
  min-width: 0;
  grid-template-columns: 34px minmax(0, 1fr) max-content;
}
.history-focused-player-summary .table-player strong { overflow: hidden; text-overflow: ellipsis; }
.history-focused-player-summary .table-player small { justify-self: end; white-space: nowrap; }
.stats-table--season-outfield th:first-child,
.stats-table--season-outfield tbody th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
}
.stats-table--season-outfield thead th:first-child { z-index: 5; background: var(--surface-soft, var(--brand-f4f7f5, #f4f7f5)); }

/* Version 2.29.1: share the goalkeeper table's player-column geometry. */
.stats-table--aligned-players.stats-table--with-appearances.stats-table--outfield.stats-table--season-outfield {
  width: var(--season-outfield-table-width);
  min-width: var(--season-outfield-table-width);
}

@media (max-width: 720px) {
  .history-column-toggle { margin-inline: 12px; }
}

@media (max-width: 700px) {
  .player-stat-group-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .player-stat-group-heading-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
}

/* Keep labels inside their columns, with alternating height for dense headers. */
.stats-table--players thead tr:not(.stats-group-row) > th {
  height: 64px;
  padding: 4px 5px 12px;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
.stats-table--players thead tr:not(.stats-group-row) > th:nth-child(even) {
  padding-top: 12px;
  padding-bottom: 4px;
  vertical-align: bottom;
}
.stats-table--players thead > tr:only-child > th:first-child {
  vertical-align: middle;
  padding-block: 4px;
}
.stats-table--players .season-sort-button {
  position: relative;
  display: block;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 4px 2px 14px;
  white-space: normal;
  text-align: right;
  line-height: 1.2;
}
.stats-table--players .season-sort-button--left { text-align: left; }
.stats-table--players .season-sort-button > span:first-child {
  display: block;
  overflow-wrap: anywhere;
}
.stats-table--players .season-sort-button > span + span {
  position: absolute;
  right: 2px;
  bottom: 0;
}
