/* =====================================================================
   COURTIQ - TEAMS PAGE
   Load this AFTER style.css (teams.html already does).
   Everything is scoped to .teams-page, so no other page is affected.
   ===================================================================== */

/* ===== TEAMS PAGE (Team Statistics Tab) ===== */
.teams-page {
  --stat-blue:   var(--accent);
  --stat-teal:   #00cba4;
  --stat-purple: #943cff;
  --stat-orange: #ff981f;
  --stat-green:  #2ecc8f;
  --stat-red:    #ff6b6b;
  --stat-cyan:   var(--accent-cyan);
  --stat-border: var(--border-soft);
  --stat-card:   linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 100%);
}

/* ---------------------------------------------------------------------
   Top Season Summary (next to the team banner): colour-coded KPIs
   --------------------------------------------------------------------- */
.teams-page .summary .summary-grid > .kpi {
  border-left: 3px solid var(--kpi, var(--stat-cyan));
  background:
    linear-gradient(90deg, var(--kpi-bg, rgba(53, 199, 239, .12)), transparent 70%),
    var(--surface);
}
.teams-page .summary .summary-grid > .kpi strong {
  color: var(--kpi, var(--stat-cyan));
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.teams-page .summary .summary-grid > .kpi-games  { --kpi: var(--stat-cyan);  --kpi-bg: rgba(53, 199, 239, .12); }
.teams-page .summary .summary-grid > .kpi-wins   { --kpi: var(--stat-green); --kpi-bg: rgba(46, 204, 143, .12); }
.teams-page .summary .summary-grid > .kpi-losses { --kpi: var(--stat-red);   --kpi-bg: rgba(255, 107, 107, .12); }

/* ---------------------------------------------------------------------
   Team Statistics tab: layout
   Row 1: Team Statistics (wide) + slim Top Scorer
   Row 2: Heatmap + Home vs. Away, side by side, same gap as row 1
   --------------------------------------------------------------------- */
.teams-page #panel-statistics .stats-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.teams-page #panel-statistics .stats-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: stretch;
}
.teams-page #panel-statistics .stats-chart-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

/* ---------------------------------------------------------------------
   Team Statistics tab: card look
   --------------------------------------------------------------------- */
.teams-page #panel-statistics .team-panel {
  position: relative;
  margin: 0;
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--stat-border);
  background: var(--stat-card);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
  overflow: hidden;
}
/* thin hardwood-orange accent along the top edge of each card */
.teams-page #panel-statistics .team-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), var(--accent-cyan), transparent);
  opacity: .8;
  pointer-events: none;
}
.teams-page #panel-statistics .team-panel h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #eaf2ff;
}

/* ---------------------------------------------------------------------
   Team Statistics tab: the four KPI tiles on ONE line
   --------------------------------------------------------------------- */
.teams-page #panel-statistics .stats-top-row > .team-panel:first-child {
  padding-top: 16px;
  padding-bottom: 16px;
}
.teams-page #panel-statistics .stats-top-row > .team-panel:first-child h3 {
  margin-bottom: 10px;
}
.teams-page #panel-statistics .stats-top-row .summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.teams-page #panel-statistics .stats-top-row .summary-grid > div {
  --k: var(--stat-blue);
  --k-bg: rgba(22, 140, 255, .14);
  padding: 11px 12px 11px 14px;
  border: 1px solid var(--stat-border);
  border-left: 3px solid var(--k);
  border-radius: 10px;
  background:
    linear-gradient(90deg, var(--k-bg), transparent 75%),
    var(--surface);
  color: #9fb6cf;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: transform .2s ease, border-color .2s ease;
}
.teams-page #panel-statistics .stats-top-row .summary-grid > div:hover {
  transform: translateY(-2px);
  border-color: var(--k);
}
.teams-page #panel-statistics .stats-top-row .summary-grid > div:nth-child(1) { --k: var(--stat-blue);   --k-bg: rgba(22, 140, 255, .14); }
.teams-page #panel-statistics .stats-top-row .summary-grid > div:nth-child(2) { --k: var(--stat-teal);   --k-bg: rgba(0, 203, 164, .14); }
.teams-page #panel-statistics .stats-top-row .summary-grid > div:nth-child(3) { --k: var(--stat-purple); --k-bg: rgba(148, 60, 255, .16); }
.teams-page #panel-statistics .stats-top-row .summary-grid > div:nth-child(4) { --k: var(--stat-orange); --k-bg: rgba(255, 152, 31, .14); }
.teams-page #panel-statistics .stats-top-row .summary-grid strong {
  margin-top: 6px;
  color: var(--k);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------
   Slim Top Scorer card: picture, name, small "Top Scorer" label
   --------------------------------------------------------------------- */
.teams-page #panel-statistics .scorer-slim {
  display: flex;
  align-items: center;
  padding: 14px 20px;
}
.teams-page #panel-statistics .scorer-slim .scorer {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 0;
}
.teams-page #panel-statistics .scorer-slim .scorer-avatar {
  flex: none;
  width: 60px;
  height: 60px;
  border: 2px solid transparent;
  border-radius: 50%;
  background:
    linear-gradient(var(--row-hover), var(--row-hover)) padding-box,
    linear-gradient(135deg, var(--brand), var(--accent-cyan)) border-box;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 12%, transparent);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;          /* clips the headshot to the circle */
  padding: 0;
}
.teams-page #panel-statistics .scorer-slim .scorer-avatar img.player-headshot {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;                    /* keeps faces in frame */
  transform: scale(var(--headshot-zoom, 1.4));    /* same zoom as the other pages */
  transform-origin: center center;
}
.teams-page #panel-statistics .scorer-slim .scorer-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.teams-page #panel-statistics .scorer-slim .scorer-text strong {
  overflow: hidden;
  color: #fff;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.teams-page #panel-statistics .scorer-slim .scorer-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.teams-page #panel-statistics .scorer-slim .scorer-label #scorerPPG {
  margin-left: 6px;
  color: var(--stat-cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------------------------------------------------------------------
   Shooting Efficiency Heatmap
   (cell colours are set by teams.js; this rounds, spaces and polishes)
   --------------------------------------------------------------------- */
.teams-page #panel-statistics .heatmap {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  font-size: 11px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.teams-page #panel-statistics .heatmap div {
  min-width: 0;
  padding: 9px 4px;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  transition: transform .15s ease, filter .15s ease;
}
.teams-page #panel-statistics .heatmap div:hover {
  position: relative;
  z-index: 1;
  transform: scale(1.07);
  filter: brightness(1.15);
}
.teams-page #panel-statistics .heatmap .heat-head {
  padding: 4px 4px 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.teams-page #panel-statistics .heatmap .heat-head:hover {
  transform: none;
  filter: none;
}
.teams-page #panel-statistics .heatmap .heat-label {
  background: color-mix(in srgb, var(--border) 18%, var(--surface-2));
  border: 1px solid var(--stat-border);
  color: #dce9fa;
  font-weight: 700;
  letter-spacing: .04em;
}

/* ---------------------------------------------------------------------
   Home vs. Away chart card
   --------------------------------------------------------------------- */
.teams-page #panel-statistics .chart-box {
  display: flex;
  flex-direction: column;
}
.teams-page #panel-statistics .chart-box > div[id] {
  flex: 1;
  min-height: 0;
  padding: 10px 10px 6px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.teams-page #panel-statistics .chart-legend {
  gap: 8px 10px;
  margin: 2px 0 10px;
}
.teams-page #panel-statistics .chart-legend span {
  gap: 7px;
  padding: 5px 12px;
  border: 1px solid var(--stat-border);
  border-radius: 999px;
  background: var(--surface);
  color: #dce9fa;
  font-size: 12px;
  font-weight: 600;
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .teams-page #panel-statistics .stats-top-row,
  .teams-page #panel-statistics .stats-chart-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 700px) {
  .teams-page #panel-statistics .stats-top-row .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  .teams-page #panel-statistics .stats-top-row .summary-grid > div,
  .teams-page #panel-statistics .heatmap div {
    transition: none;
  }
}


/* ===== TEAMS PAGE (Other Tabs)===== */

.teams-page {
    --team-bg: var(--bg);
    --team-panel: var(--surface-2);
    --team-border: var(--border-soft);
    --team-blue: var(--accent);
    --team-cyan: var(--accent-cyan);
    --team-muted: var(--text-muted);
    background: var(--team-bg);
    color: #e7f0ff;
}
.teams-page .teams-main {
    margin-left: 270px;
    padding: 28px 30px 22px;
    min-width: 0;
}
.teams-page .teams-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 220px 250px minmax(260px, 1.1fr);
    gap: 14px;
    align-items: center;
    margin-bottom: 16px;
    min-width: 0;
}
.teams-page .teams-toolbar p {
    margin: 0;
    color: var(--team-muted);
    font-size: 14px;
    line-height: 1.45;
    white-space: normal;
}
.teams-page .teams-toolbar select,
.teams-page .teams-toolbar input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 44px;
    box-sizing: border-box;
    background: var(--surface-2);
    color: #e7f0ff;
    border: 1px solid var(--team-border);
    border-radius: 9px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: normal;
}
.teams-page .teams-toolbar select {
    cursor: pointer;
    padding-right: 30px;
    white-space: nowrap;
}
.teams-page .teams-toolbar input {
    padding-right: 12px;
}
.teams-page .teams-toolbar input::placeholder {
    color: var(--team-muted);
    font-size: 13px;
    opacity: 1;
}
.teams-page .teams-toolbar select:focus,
.teams-page .teams-toolbar input:focus {
    outline: 2px solid var(--team-blue);
    outline-offset: 2px;
}
.teams-page .team-hero-row {
    display: grid;
    grid-template-columns: 1.3fr 0.8fr;
    gap: 12px;
}
.teams-page .team-panel {
    background: var(--team-panel);
    border: 1px solid var(--team-border);
    border-radius: 22px;
    padding: 20px;
    min-width: 0;
}
.teams-page .team-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 86px;
}
.teams-page .team-mark {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    border: 2px solid #dceaff;
    display: grid;
    place-items: center;
    font-size: 25px;
    font-weight: 800;
    background: var(--table-head);
    flex: none;
}
.teams-page .team-hero h2 {
    margin: 0 0 5px;
    font-size: 20px;
}
.teams-page .team-hero p {
    margin: 0;
    color: #c4d5e9;
}
.teams-page .hero-metrics {
    margin-left: auto;
    display: flex;
    gap: 8px;
}
.teams-page .mini-metric {
    border: 1px solid var(--team-border);
    border-radius: 7px;
    padding: 10px 13px;
    min-width: 76px;
    text-align: center;
    font-size: 12px;
    color: #dce9fa;
}
.teams-page .mini-metric strong {
    display: block;
    color: var(--team-cyan);
    font-size: 14px;
    margin-top: 3px;
}
.teams-page .summary h3,
.teams-page .team-panel h3 {
    margin: 0 0 12px;
    font-size: 17px;
}
.teams-page .summary-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 8px;
}
.teams-page .summary-grid div {
    background: var(--surface);
    border: 1px solid var(--team-border);
    border-radius: 6px;
    padding: 11px;
    font-size: 12px;
}
.teams-page .summary-grid strong {
    display: block;
    color: var(--team-cyan);
    font-size: 14px;
    margin-top: 4px;
}
.teams-page .team-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 18px 0;
}
.teams-page .team-tab {
    background: var(--surface-2);
    border: 1px solid var(--team-border);
    color: #dce9fa;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
}
.teams-page .team-tab.active {
    background: var(--row-hover);
    border-color: var(--accent);
    box-shadow: inset 0 -2px var(--accent-cyan);
}
.teams-page .team-content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}
.teams-page .left-stack,
.teams-page .middle-stack,
.teams-page .right-stack {
    display: contents;
}
.teams-page .team-content-grid > section,
.teams-page .team-content-grid > .left-stack > section,
.teams-page .team-content-grid > .middle-stack > section,
.teams-page .team-content-grid > .right-stack > section {
    min-width: 0;
}
.teams-page .roster-table-wrap {
    overflow: auto;
}
.teams-page table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.teams-page th,
.teams-page td {
    padding: 8px 9px;
    text-align: left;
    white-space: nowrap;
}
.teams-page th {
    color: var(--team-muted);
    border-bottom: 1px solid var(--team-border);
}
.teams-page tbody tr:nth-child(odd) {
    background: var(--table-head);
}
.teams-page .coach-note {
    color: var(--team-muted);
    font-size: 11px;
    margin: 9px 0 0;
}
.teams-page .scorer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
}
.teams-page .scorer-avatar {
    width: 52px;
    height: 52px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--row-hover);
    font-weight: 700;
}
.teams-page .scorer strong {
    display: block;
}
.teams-page .scorer span {
    color: var(--team-cyan);
    font-size: 13px;
}
.teams-page .heatmap {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    font-size: 11px;
    text-align: center;
}
.teams-page .heatmap div {
    padding: 10px 4px;
    background: #126c7c;
    min-width: 0;
}
.teams-page .heatmap .heat-head {
    background: transparent;
    color: var(--team-muted);
    font-weight: 700;
}
.teams-page .heatmap .heat-label {
    background: var(--surface);
    color: #dce9fa;
    font-weight: 700;
}
.teams-page .chart-box {
    min-height: 300px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}
.teams-page .chart-box > div[id] {
    width: 100%;
    flex: 1;
    min-height: 0;
}
.teams-page .chart-box svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 230px;
    overflow: visible;
}
.teams-page .chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 16px;
    color: var(--team-muted);
    font-size: 11px;
    margin: 2px 0 12px;
}
.teams-page .chart-legend span {
    white-space: nowrap;
}
.teams-page .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}
.teams-page .insights {
    margin-top: 18px;
}
.teams-page .insight-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.teams-page .insight {
    border: 1px solid var(--team-border);
    background: var(--surface);
    border-radius: 10px;
    padding: 13px;
    font-size: 12px;
    color: var(--team-muted);
}
.teams-page .insight strong {
    display: block;
    color: #e7f0ff;
    margin-bottom: 7px;
    font-size: 13px;
}
.teams-page .insight b {
    display: block;
    color: var(--team-cyan);
    margin-top: 8px;
}
.teams-page .tab-panel[hidden] {
    display: none !important;
}
.teams-page .team-footer {
    color: #718ba8;
    text-align: center;
    font-size: 10px;
    padding: 14px 0 0;
}
@media (max-width: 1250px) {
    .teams-page .teams-main {
    padding: 22px 18px;
    }
    .teams-page .teams-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .teams-page .teams-toolbar p {
    grid-column: 1 / -1;
    }
    .teams-page .team-hero-row {
    grid-template-columns: 1fr;
    }
    .teams-page .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 900px) {
    .teams-page .team-content-grid {
    grid-template-columns: 1fr;
    }
    .teams-page .team-hero {
    flex-wrap: wrap;
    }
    .teams-page .hero-metrics {
    margin-left: 0;
    width: 100%;
    }
    .teams-page .mini-metric {
    flex: 1;
    }
}
@media (max-width: 650px) {
    .teams-page .teams-main {
    margin-left: 0;
    width: 100%;
    padding: 20px 14px;
    }
    .teams-page .teams-toolbar {
    grid-template-columns: 1fr;
    }
    .teams-page .insight-grid {
    grid-template-columns: 1fr;
    }
    .teams-page .summary-grid {
    grid-template-columns: 1fr;
    }
}
.teams-page .tab-panel:not([hidden]) {
    display: block;
}
.teams-page .team-content-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}
.teams-page .team-content-grid > * {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    align-self: start;
}
.teams-page .team-panel {
    height: auto;
    min-height: 0;
    box-sizing: border-box;
}
.teams-page .chart-box {
    min-width: 0;
    width: 100%;
    min-height: 0;
    height: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}
.teams-page .chart-box h3 {
    margin-bottom: 16px;
    flex-shrink: 0;
}
.teams-page .chart-box > div[id] {
    width: 100%;
    min-width: 0;
    flex: 1;
    box-sizing: border-box;
}
.teams-page .chart-box svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
    overflow: visible;
}
.teams-page .chart-legend {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 20px;
    width: 100%;
    margin: 4px 0 16px;
    box-sizing: border-box;
}
.teams-page .chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #9bb0c7;
    font-size: 12px;
    white-space: nowrap;
}
.teams-page .chart-legend .dot {
    width: 10px;
    height: 10px;
    min-width: 10px;
    border-radius: 50%;
    display: inline-block;
    margin: 0;
}
.teams-page .insights {
    width: 100%;
    margin-top: 20px;
}
.teams-page .insight-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.teams-page .insight {
    padding: 16px;
    border: 1px solid var(--team-border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--team-muted);
    font-size: 10px;
    line-height: 1.6;
    box-sizing: border-box;
}
.teams-page .insight strong {
    display: block;
    margin-bottom: 7px;
    color: #e7f0ff;
    font-size: 12px;
}
.teams-page .insight p {
    margin: 0 0 8px;
    font-size: 10px;
    line-height: 1.6;
}
.teams-page .insight b {
    display: block;
    margin: 8px 0 4px;
    color: var(--team-cyan);
    font-size: 10px;
}
.teams-page .tab-panel[hidden] {
    display: none !important;
}
@media (max-width: 900px) {
    .teams-page .team-content-grid {
    grid-template-columns: minmax(0, 1fr);
    }
}
@media (max-width: 650px) {
    .teams-page .insight-grid {
    grid-template-columns: 1fr;
    }
    .teams-page .chart-box {
    padding: 16px;
    }
    .teams-page .chart-legend {
    justify-content: flex-start;
    gap: 8px 14px;
    }
    .teams-page .chart-legend span {
    font-size: 11px;
    }
}
.teams-page #panel-roster {
    width: 100%;
    max-width: none;
}
.teams-page #panel-roster > .team-content-grid {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
}
.teams-page #panel-roster .team-panel {
    display: block;
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}
.teams-page #panel-roster .roster-table-wrap {
    width: 100%;
    overflow-x: auto;
}
.teams-page #panel-roster table {
    width: 100%;
    table-layout: auto;
}

.quarter-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.quarter-compare {
    height: 30px;
    padding: 0 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    color: var(--text);
    font-size: 11px;
    outline: none;
}
.quarter-compare:focus { border-color: var(--accent); }
.quarter-compare:disabled { opacity: 0.5; }
.quarter-compare option { background: var(--surface-2); }
.compare-chip {
    height: 30px;
    padding: 0 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 15px;
    color: var(--text);
    font-size: 11px;
    cursor: pointer;
}
.compare-chip:hover { border-color: var(--accent); }