/* app/assets/stylesheets/components/games.css */

/* -- View switch (List / Matches) -- */

.games-view-switch {
  display: inline-flex;
  width: auto;
  gap: 0;
  margin-bottom: 0.75rem;
  border: 1px solid var(--ink-4);
  border-radius: 999px;
  overflow: hidden;
  background: white;
}

.games-view-switch__btn {
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  color: var(--ink-3);
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  min-width: 90px;
}

.games-view-switch__btn.is-active {
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
}

/* -- Filters: override schedule-filter width rules inside this page so the
   filter controls fill the grey container.
   schedule.css sets min-width: 150px on .schedule-filter__select, which the
   games container overrides with flex:1 on each filter group. -- */

.games-container .schedule-filters {
  align-items: stretch;
}
.games-container .schedule-filter {
  flex: 1 1 0;
  min-width: 140px;
}
.games-container .schedule-filter__select {
  width: 100%;
  min-width: 0;
}

/* Tighter pill for Clear action */
.games-container .schedule-actions__clear {
  min-width: 0;
  padding: 0.35rem 0.85rem;
  display: inline-block;
  align-self: flex-end;
}

/* -- Table --
   The wrapping .card normally clips overflow to keep its rounded
   corners crisp; for the games table specifically we let the card
   scroll horizontally so the wide table doesn't get cut off at narrow
   viewport widths. Vertical clipping is preserved. */

.games-container { overflow: visible; }
.games-container .card {
  overflow-x: auto;
  overflow-y: hidden;
}

.games-table {
  width: 100%;
  min-width: 1500px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 1rem;
  margin: 0;
}

/* Canonical card-table header look (style guide). */
.games-table thead th {
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.games-table tbody td {
  border-top: 1px solid var(--line-2);
  padding: 10px 14px;
}
.games-table tbody tr:first-child td { border-top: 0; }
/* Bottom row gets extra space below the last cell so it doesn't sit
   flush against the card's bottom edge. */
.games-table tbody tr:last-child td { padding-bottom: 14px; }

/* Fixed widths chosen so static-width columns (Period/Date/Time/Game/Score)
   don't steal horizontal space from team/location columns. Widths sized
   to fit the column header label + a comfortable typical value. */
.games-table col.col-period   { width: 7rem;   }
.games-table col.col-date     { width: 8.5rem; }  /* fits "Sep 26, 2026" */
.games-table col.col-time     { width: 11rem;  }  /* fits "12:22 ~ 12:22pm" */
.games-table col.col-location { width: auto;   }
.games-table col.col-group    { width: 7rem;   }
.games-table col.col-game     { width: 5rem;   }
.games-table col.col-team     { width: auto;   }
.games-table col.col-score    { width: 6.5rem; }  /* fits header "Score B" */
.games-table col.col-ref      { width: auto;   }
.games-table col.col-status   { width: 7.5rem; }

.games-table tbody tr:hover {
  background: var(--bg-2);
}

.games-row {
  height: 2.5rem;
}

.games-table__empty {
  text-align: center;
  padding: 2rem;
  color: var(--ink-3);
  font-size: 0.9rem;
}

/* -- Sort headers -- */

.games-table__sort {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.games-table__sort:hover {
  color: var(--gold);
}

.games-table__sort.is-active {
  font-weight: 700;
}

.games-table__sort sup {
  font-size: 0.6rem;
  font-weight: 700;
  margin-left: 0.15rem;
  color: var(--ink-3);
}

/* -- Cells -- */

.game-cell {
  position: relative;
  height: 100%;
  padding: 0 0.35rem;
  vertical-align: middle;
  white-space: nowrap;
  /* No overflow: hidden on the cell itself — the tooltip ::after would get
     clipped. Ellipsis clipping lives on the inner .game-cell__text wrapper. */
}

.game-cell--readonly {
  padding: 0 0.5rem;
  color: var(--ink);
}

/* Text wrapper — owns the ellipsis behavior so the cell itself can stay
   overflow:visible (required for tooltip rendering). */
.game-cell__text {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Location: keep the <td> as a normal table cell (so it aligns with other
   columns) and put flex on an inner wrapper. Facility shrinks with ellipsis;
   location suffix (e.g. "(Court 3)") is always fully visible. */
.game-cell__location-inner {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  min-width: 0;
}

.game-cell__location-facility {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.game-cell__location-name {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--ink-3);
}

/* Tooltip styles for [data-tooltip] now live in base/base.css. */

/* Display link (click-to-edit target) */
.game-cell__display {
  display: block;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  padding: 0.1rem 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1.5rem;
}

.game-cell__display:hover {
  background-color: var(--ink-4);
}

/* Score cell display */
.game-cell__score {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Empty score cell — show a bordered box */
.game-cell__score--empty {
  border: 1px solid var(--ink-4);
  border-radius: 8px;
  min-height: 1.6rem;
}

/* Input in edit state — padding/typography matches the display link so the
   text position is stable between the two states. */
.game-cell__input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--silver);
  border-radius: 8px;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  background: white;
  -moz-appearance: textfield;
}
.game-cell__input::-webkit-outer-spin-button,
.game-cell__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.game-cell__input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 204, 0, 0.25);
}

/* -- Winner / loser / tie coloring -- */

.game-cell--win {
  color: var(--green);
  font-weight: 700;
}

.game-cell--lose {
  color: var(--red);
}

.game-cell--tie {
  color: var(--bronze);
  font-weight: 700;
}

/* -- Status filter --
   Uses the canonical .segmented control. Radio inputs are hidden
   visually but kept for form submission and accessibility; the label
   itself is the .segmented__btn click target. */
.segmented__radio { position: absolute; opacity: 0; pointer-events: none; }

/* -- Status pill -- */

.game-status {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-2);
  color: var(--ink-3);
}

.game-status--completed,
.game-status--finalized {
  background: rgba(39, 174, 96, 0.12);
  color: var(--green);
}

.game-status--scheduled {
  background: rgba(255, 204, 0, 0.18);
  color: var(--gold-dark);
}

/* -- Matches (cards) view — lofi -- */

.games-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.games-card {
  border: 1px solid var(--ink-4);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  background: white;
}

.games-card__header {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--ink-3);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bg-2);
  margin-bottom: 0.5rem;
}

.games-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.games-card__teams {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  padding-bottom: 0.25rem;
}

.games-card__game {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.games-card__game-label {
  min-width: 5rem;
  color: var(--ink-3);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
}

.games-card__dash {
  color: var(--ink-3);
}

.games-card__footer {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--bg-2);
  font-size: 0.85rem;
  color: var(--ink-3);
}
