/* Leaderboard Page - extends winners.css patterns */

/* Prevent page-level horizontal overflow - tables scroll within their wrappers */
#leaderboard {
  overflow-x: hidden;
}

#leaderboard .container {
  min-width: 0;
  /* Inherits max-width: 1200px from global .container - no override needed */
}

/* Table scroll wrapper - allows horizontal scroll on mobile without page overflow */
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -1px; /* slight negative margin so scrollbar doesn't add width */
  border-radius: var(--border-radius);
}

.table-scroll-wrapper .leaderboard-table {
  min-width: 500px; /* ensure table doesn't collapse on narrow screens */
}

/* Minimal stat tiles - metrics, not content cards */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 22px;
}

.stat-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #E8C047;
  line-height: 1.2;
}

.stat-value .jackpot-amount {
  color: #E8C047;
}

.stat-value .jackpot-detail {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.35rem;
}

.stat-value .no-data {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 400;
}

.stat-value .popular-card-name {
  display: block;
  color: #E8C047;
  font-size: 28px;
}

/* Card links: gold, underline only */
.stat-value a.popular-card-name {
  color: #E8C047;
  text-decoration: underline;
}
.stat-value a.popular-card-name:hover {
  color: #E8C047;
  opacity: 0.85;
}

.stat-value .popular-card-count {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.35rem;
}

.stat-note {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 0.35rem;
}

.leaderboard-table td a {
  color: var(--text-light);
  text-decoration: underline;
}
.leaderboard-table td a:hover {
  color: var(--text-light);
  opacity: 0.85;
}

/* Top Players Section - inline period filter */
.top-players-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.top-players-header .section-title {
  margin-bottom: 0;
}

.period-filter-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-select-sm {
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--light-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  color: var(--text-light);
  font-size: 0.9rem;
  min-width: 120px;
}

.filter-select-sm:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-btn-sm {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn-sm:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Competitions */
.competitions-section {
  margin-bottom: 2.5rem;
}

.competitions-section .section-title {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.competition-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--light-color);
  box-shadow: var(--shadow);
}

.competition-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.competition-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-light);
  flex: 1 1 auto;
  min-width: 0;
}

.comp-name-with-info {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.25rem;
  white-space: nowrap;
}

.comp-name-with-info .comp-info-btn {
  flex-shrink: 0;
}

.competition-type {
  background: rgba(76, 110, 245, 0.2);
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
}

.competition-dates {
  color: var(--text-gray);
  font-size: 0.9rem;
  white-space: nowrap;
}

.comp-countdown {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}

.comp-countdown i {
  font-size: 0.85em;
  opacity: 0.9;
}

.no-standings, .no-competitions {
  color: var(--text-gray);
  text-align: center;
  padding: 1.5rem;
}

.past-filter {
  margin-bottom: 1rem;
}

.past-filter label {
  margin-right: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
}

.past-standings-container {
  margin-top: 1rem;
}

/* Leaderboard tabs */
.leaderboards-section {
  margin-top: 2rem;
}

.leaderboard-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  list-style: none;
  padding: 0;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 0.6rem 1.25rem;
  background: var(--bg-card);
  border: 2px solid var(--light-color);
  border-radius: var(--border-radius);
  color: var(--text-light);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Mobile leaderboard tabs - hidden by default */
.mobile-leaderboard-tabs {
  display: none;
}

/* Tablet and below (992px): use native select for reliable fit */
@media (max-width: 992px) {
  .desktop-leaderboard-tabs {
    display: none !important;
  }
  .mobile-leaderboard-tabs {
    display: block !important;
    margin-bottom: 1rem;
  }
  .mobile-tab-select {
    width: 100%;
    max-width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--bg-card);
    border: 2px solid var(--light-color);
    border-radius: var(--border-radius);
    color: var(--text-light);
    cursor: pointer;
    appearance: auto;
    -webkit-appearance: menulist;
  }
  .mobile-tab-select:focus {
    outline: none;
    border-color: var(--primary);
  }
}

@media (min-width: 993px) {
  .mobile-leaderboard-tabs {
    display: none !important;
  }
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leaderboard-table th {
  background: var(--bg-card);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid var(--light-color);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.leaderboard-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-color);
}

.leaderboard-table tbody tr:hover {
  background: var(--card-hover);
}

.rank-cell {
  font-weight: 600;
  color: var(--text-light);
}

.empty-row {
  text-align: center;
  color: var(--text-gray);
  padding: 2rem !important;
}

.filter-select {
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--light-color);
  border-radius: var(--border-radius);
  background: var(--bg-card);
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Competition info button */
.comp-info-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  margin-left: 0.35rem;
  font-size: 1rem;
  opacity: 0.8;
  vertical-align: middle;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.comp-info-btn:hover {
  opacity: 1;
}

.comp-info-btn i {
  font-size: 1rem;
}

.past-comp-header {
  margin-bottom: 1rem;
}

.past-comp-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--text-light);
}

/* Competition info popup */
.comp-info-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.comp-info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.comp-info-content {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--light-color);
}

.comp-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.comp-info-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-light);
}

.comp-info-close {
  background: none;
  border: none;
  color: var(--text-gray);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s;
}

.comp-info-close:hover {
  color: var(--text-light);
}

.comp-info-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.comp-info-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.6;
  color: var(--text-color);
}

@media (max-width: 768px) {
  .stats-cards {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .stat-card {
    min-width: 0;
  }

  .stat-value {
    font-size: 22px;
  }

  .stat-value .popular-card-name {
    font-size: 22px;
    word-break: break-word;
  }

  .top-players-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .period-filter-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  .period-filter-inline .filter-select-sm {
    flex: 1 1 140px;
    min-width: 0;
  }

  .period-filter-inline .filter-btn-sm {
    flex-shrink: 0;
  }

  .filter-select,
  .filter-select-sm {
    min-width: 0;
  }

  .competition-header {
    gap: 0.5rem;
  }

  .competition-type,
  .competition-dates,
  .comp-countdown {
    font-size: 0.8rem;
  }

  .competition-card {
    overflow: visible;
    min-width: 0;
  }

  .competition-standings {
    min-width: 0;
  }

  .table-scroll-wrapper {
    margin: 0 -0.5rem;
    padding: 0 0.25rem;
  }

  .table-scroll-wrapper .leaderboard-table {
    min-width: 480px;
  }

  .leaderboard-table {
    font-size: 0.8rem;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.5rem 0.4rem;
  }

  .past-filter {
    width: 100%;
  }

  .past-filter .filter-select {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .table-scroll-wrapper .leaderboard-table {
    min-width: 400px;
  }

  .stat-value .jackpot-detail {
    font-size: 12px;
  }

  /* Stack period filter so Apply button is always visible */
  .period-filter-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .period-filter-inline .filter-select-sm {
    flex: none;
    width: 100%;
  }

  .period-filter-inline .filter-btn-sm {
    width: 100%;
  }
}
