/* ── Base ───────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background-color: #eceef0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
}

/* ── Site navbar ────────────────────────────────────────── */
.site-nav {
  background-color: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.site-nav-inner {
  display: flex;
  align-items: center;
  padding-top: 2vw;
  padding-bottom: 2vw;
  padding-left: 8vw;
  padding-right: 8vw;
  gap: 1.25rem;
}

.site-nav-logo {
  display: block;
  flex-shrink: 0;
  line-height: 0;
}

.site-nav-logo img {
  height: 46px;
  width: auto;
}

.site-nav-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: auto;
}

/* ── Language selector ──────────────────────────────────── */
.lang-selector {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.lang-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #888;
  cursor: pointer;
  line-height: 1.4;
  transition: color .15s, border-color .15s;
}

.lang-btn:hover {
  color: #E30613;
  border-color: rgba(227,6,19,.4);
}

.lang-btn.active {
  color: #E30613;
  border-color: #E30613;
}

@media (max-width: 480px) {
  .site-nav-logo img { height: 36px; }
  .site-nav-title { display: none; }
  .lang-selector { margin-left: auto; }
}

/* ── Filter row ─────────────────────────────────────────── */
.filter-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 0.35rem;
}

.filter-control {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid #bbb;
  border-radius: 0;
  padding: 0.4rem 1.8rem 0.4rem 0.1rem;
  font-size: 1rem;
  color: #222;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%23555' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.3rem center;
  cursor: pointer;
  transition: border-color .15s;
}

input.filter-control {
  background-image: none;
  padding-right: 0.1rem;
}

.filter-control:focus {
  outline: none;
  border-bottom-color: #E30613;
}

/* ── Hide-past toggle ───────────────────────────────────── */
.form-check-input:checked {
  background-color: #E30613;
  border-color: #E30613;
}

/* ── Share button ───────────────────────────────────────── */
.share-btn {
  background: none;
  border: none;
  padding: 0.2rem 0.45rem;
  color: #999;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 4px;
  transition: color .15s, background .15s;
  line-height: 1;
}

.share-btn:hover {
  color: #E30613;
  background: rgba(227,6,19,.07);
}

/* ── Table card ─────────────────────────────────────────── */
.table-card {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Make the tbody scrollable while keeping the header fixed */
.table-scroll-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: scroll;
}

.table-scroll-wrapper::-webkit-scrollbar { width: 6px; }
.table-scroll-wrapper::-webkit-scrollbar-track { background: #f5f5f5; }
.table-scroll-wrapper::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.table-scroll-wrapper::-webkit-scrollbar-thumb:hover { background: #aaa; }

/* ── Page content wrapper (fills remaining viewport below nav) */
.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Tournament table ───────────────────────────────────── */
.t-table {
  margin-bottom: 0;
  border-collapse: collapse;
}

.t-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #999;
  border-top: none;
  border-bottom: 1px solid #e4e4e4;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}

.t-table tbody tr {
  border-bottom: 1px solid #f2f2f2;
  transition: background .1s;
}

.t-table tbody tr:last-child { border-bottom: none; }

/* Override --bs-table-bg so Bootstrap's td `background-color: var(--bs-table-bg)` picks up row colours */
.t-table tbody tr { --bs-table-bg: #ffffff; }
.t-table tbody tr:hover { --bs-table-bg: #fdf5f5; }

.t-table tbody tr.is-past { --bs-table-bg: #f5f5f5; }
.t-table tbody tr.is-past:hover { --bs-table-bg: #eeeeee; }
.t-table tbody tr.is-past .t-name,
.t-table tbody tr.is-past .t-date { color: #666; }

.t-table tbody td {
  padding: 0.9rem 1rem;
  vertical-align: middle;
  border: none;
}

/* ── Actions column: fixed right padding without !important override ── */
.t-table .col-actions { padding-right: 1rem; }

/* ── Category cell ──────────────────────────────────────── */
.cat-logo {
  max-height: 30px;
  max-width: 110px;
  object-fit: contain;
}

.cat-text {
  display: inline-block;
  width: 3.8rem;
  box-sizing: border-box;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  padding: 3px 8px;
  border-radius: 3px;
  white-space: nowrap;
  /* background is set inline by getCategoryStyle() */
}

/* ── Name cell ──────────────────────────────────────────── */
.t-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: #1a1a1a;
}

/* ── Country cell ───────────────────────────────────────── */
.country-flag {
  font-size: 1.25rem;
  line-height: 1;
  vertical-align: middle;
}

.country-code {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  vertical-align: middle;
  margin-left: 0.3rem;
}

/* ── STF membership badge (ranking table country column) ─ */
.stf-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: #E30613;
  border-radius: 3px;
  padding: 2px 5px;
  vertical-align: middle;
  margin-left: 0.4rem;
}

/* ── Date cell ──────────────────────────────────────────── */
.t-date {
  white-space: nowrap;
  font-size: 0.875rem;
  color: #333;
}

.date-link {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  text-decoration-color: #ccc;
  transition: color .15s, text-decoration-color .15s;
}

.date-link:hover {
  text-decoration-color: #E30613;
  color: #E30613;
}

/* ── STS row: light-red background + dark-red bold name + date ── */
.t-table tbody tr[data-cat="STS"]:not(.is-past) { --bs-table-bg: rgba(227, 6, 19, 0.2); }
.t-table tbody tr[data-cat="STS"]:not(.is-past):hover { --bs-table-bg: rgba(227, 6, 19, 0.3); }

tr[data-cat="STS"] .t-name,
tr[data-cat="STS"] .t-date {
  color: #a8000f;
  font-weight: 700;
}

/* ── Playground cell ────────────────────────────────────── */
.pg-logo {
  max-height: 26px;
  max-width: 100px;
  object-fit: contain;
}

.pg-text {
  font-size: 0.82rem;
  color: #555;
}

/* ── Action links ───────────────────────────────────────── */
.action-link {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #E30613;
  text-decoration: none;
  border-bottom: 2px solid #E30613;
  padding-bottom: 1px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}

.action-link + .action-link { margin-left: 1rem; }

.action-link:hover {
  color: #a8000f;
  border-bottom-color: #a8000f;
}

.action-link.is-disabled {
  color: #ccc;
  border-bottom-color: #e0e0e0;
  pointer-events: none;
}

/* ── State rows ─────────────────────────────────────────── */
.state-row td {
  text-align: center;
  padding: 3.5rem 1rem;
  color: #aaa;
  font-size: 0.95rem;
}

.state-row.is-error td { color: #dc3545; }

/* ── Footer ─────────────────────────────────────────────── */
.page-footer {
  font-size: 0.78rem;
  color: #aaa;
}

.page-footer a { color: #aaa; }
.page-footer a:hover { color: #E30613; }

/* ── ITSF badge cell ────────────────────────────────────── */
.col-itsf {
  width: 48px;
  text-align: center;
}

.itsf-badge {
  height: 14px;
  width: auto;
}

/* ── Responsive hide ────────────────────────────────────── */
@media (max-width: 767px) {
  .col-pg, .col-country { display: none; }
}
@media (max-width: 575px) {
  .col-cat, .col-itsf { display: none; }
}

/* ── Action links: icon vs text ─────────────────────────── */
.action-icon-mobile { display: none; }

/* ── Filter toggle ──────────────────────────────────────── */
.filter-toggle-btn {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color .15s, color .15s;
}
.filter-toggle-btn:hover { border-color: #E30613; color: #E30613; }
.filter-toggle-btn .chevron {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}
.filter-toggle-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

@media (max-width: 480px) {
  /* Switch action links to icon-only */
  .action-icon-mobile {
    display: inline-block;
    font-size: 1.1rem;
  }
  .action-text-desktop { display: none; }
  .action-link {
    border-bottom: none;
    padding: 0.2rem 0.3rem;
    font-size: 1rem;
    letter-spacing: 0;
  }
  .action-link + .action-link { margin-left: 0.5rem; }

  /* Tighter cell padding */
  .t-table thead th { padding: 0.7rem 0.5rem; }
  .t-table tbody td { padding: 0.65rem 0.5rem; }

  /* Smaller table font sizes */
  .t-name  { font-size: 0.78rem; }
  .t-date  { font-size: 0.73rem; }
  .pg-text { font-size: 0.7rem; }
  .t-table thead th { font-size: 0.6rem; }

  /* Reduce nav padding */
  .site-nav-inner {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    padding-left: 4vw;
    padding-right: 4vw;
  }

  /* Prevent horizontal scroll */
  .table-scroll-wrapper { overflow-x: hidden; }
}

/* ── Rankings two-column layout ─────────────────────────── */
.ranking-layout {
  display: flex;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

.ranking-col-left {
  flex: 1;          /* equal half of available space */
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ranking-col-right {
  flex: 1;          /* equal half of available space */
  min-width: 0;
  flex-direction: column;
}

/* ── Player detail panel ────────────────────────────────── */
.player-detail-panel {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.player-detail-panel::-webkit-scrollbar { width: 6px; }
.player-detail-panel::-webkit-scrollbar-track { background: #f5f5f5; }
.player-detail-panel::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
.player-detail-panel::-webkit-scrollbar-thumb:hover { background: #aaa; }

.pd-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem;
}

.pd-inner {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Stats row ── */
.pd-stats {
  display: flex;
  gap: 1rem;
  justify-content: center;
  border-bottom: 1px solid #f2f2f2;
  padding-bottom: 1.25rem;
}

.pd-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 5rem;
}

.pd-stat-val {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1a1a1a;
  line-height: 1;
}

.pd-stat-val.is-top3 { color: #E30613; }

.pd-stat-lbl {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #aaa;
}

/* ── Member card ── */
.pd-member {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.pd-avatar {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e4e4e4;
  background: #f5f5f5;
}

.pd-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a1a;
}

.pd-country {
  font-size: 1.1rem;
}

.pd-metas {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: center;
}

.pd-meta {
  display: flex;
  gap: 0.4rem;
  font-size: 0.82rem;
  align-items: baseline;
}

.pd-meta-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #aaa;
}

.pd-meta-val {
  font-weight: 600;
  color: #333;
}

.pd-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.pd-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: #888;
  border-radius: 3px;
  padding: 2px 7px;
}

/* ── Clickable ranking rows ─────────────────────────────── */
.ranking-row {
  cursor: pointer;
}

.ranking-row.is-selected {
  --bs-table-bg: #fff0f1 !important;
  outline: none;
}

.ranking-row.is-selected td:first-child {
  border-left: 3px solid #E30613;
}

/* ── Rankings tab bar ───────────────────────────────────── */
.ranking-tabs {
  display: flex;
  overflow-x: auto;
  flex-shrink: 0;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ranking-tabs::-webkit-scrollbar { display: none; }

.ranking-tab {
  flex-shrink: 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #777;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}

.ranking-tab:hover { color: #E30613; }

.ranking-tab.active {
  color: #E30613;
  border-bottom-color: #E30613;
}

/* ── Tab label / abbreviation (mobile swap) ───────────── */
.tab-abbr { display: none; }

@media (max-width: 575px) {
  .tab-label { display: none; }
  .tab-abbr  { display: inline; }
  .ranking-tab[data-cat="OC"] { display: none; }
}

/* ── Rankings table ─────────────────────────────────────── */
.col-rank {
  width: 3rem;
  text-align: center;
  color: #999;
  font-size: 0.82rem;
}

.col-points {
  width: 6rem;
}

.r-rank {
  font-size: 0.85rem;
  font-weight: 700;
  color: #aaa;
}

.r-rank.is-top3 {
  color: #E30613;
}

.r-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: #1a1a1a;
}

.r-points {
  font-weight: 700;
  font-size: 0.92rem;
  color: #1a1a1a;
}
