/* ========================================
   Tier List Page Styles
   ======================================== */

.leaderboard-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 32px;
  gap: 16px;
}

/* Scrollbar */
.leaderboard-container::-webkit-scrollbar {
  width: 6px;
}
.leaderboard-container::-webkit-scrollbar-track {
  background: transparent;
}
.leaderboard-container::-webkit-scrollbar-thumb {
  background: #2a3040;
  border-radius: 3px;
}

/* ── Controls Bar ───────────────────── */
.leaderboard-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: #141820;
  border-radius: 10px;
  border: 1px solid #2a3040;
}

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-label {
  font-size: 13px;
  font-weight: 600;
  color: #8892a8;
}

.control-select {
  background: #1a1e2a;
  color: #f2f4f8;
  border: 1px solid #2a3040;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.control-select:focus {
  border-color: #3b82f6;
}

.control-btn {
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.control-btn:hover {
  background: #2563eb;
}
.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.control-search {
  background: #1a1e2a;
  color: #f2f4f8;
  border: 1px solid #2a3040;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  width: 220px;
  outline: none;
  transition: border-color 0.15s;
}
.control-search:focus {
  border-color: #3b82f6;
}
.control-search::placeholder {
  color: #555d70;
}

/* ── Summary Stats ──────────────────── */
.summary-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 160px;
  background: #141820;
  border-radius: 10px;
  border: 1px solid #2a3040;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #f2f4f8;
}

/* Tier accent colors */
.challenger-accent .stat-label { color: #f59e0b; }
.challenger-accent { border-left: 3px solid #f59e0b; }

.grandmaster-accent .stat-label { color: #ef4444; }
.grandmaster-accent { border-left: 3px solid #ef4444; }

.master-accent .stat-label { color: #a855f7; }
.master-accent { border-left: 3px solid #a855f7; }

/* ── Loading / Error ────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 0;
  color: #8892a8;
  font-size: 14px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #2a3040;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-state {
  padding: 40px 0;
  text-align: center;
  color: #ef4444;
  font-size: 14px;
}

/* ── Tier Sections ──────────────────── */
.tier-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tier-section {
  background: #141820;
  border-radius: 10px;
  border: 1px solid #2a3040;
  overflow: hidden;
}

/* Tier Header */
.tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  user-select: none;
}

.tier-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tier-icon {
  font-size: 20px;
}

.tier-name {
  font-size: 16px;
  font-weight: 700;
}

.tier-count {
  font-size: 12px;
  font-weight: 600;
  color: #555d70;
  background: #1a1e2a;
  padding: 2px 8px;
  border-radius: 10px;
}

.chevron {
  width: 20px;
  height: 20px;
  color: #555d70;
  transition: transform 0.2s;
}

.tier-section.collapsed .chevron {
  transform: rotate(-90deg);
}

.tier-section.collapsed .tier-body {
  display: none;
}

/* Header color accents */
.challenger-header {
  border-left: 3px solid #f59e0b;
}
.challenger-header .tier-name { color: #f59e0b; }

.grandmaster-header {
  border-left: 3px solid #ef4444;
}
.grandmaster-header .tier-name { color: #ef4444; }

.master-header {
  border-left: 3px solid #a855f7;
}
.master-header .tier-name { color: #a855f7; }

/* ── Tier Table ─────────────────────── */
.tier-body {
  max-height: 500px;
  overflow-y: auto;
}
.tier-body::-webkit-scrollbar {
  width: 5px;
}
.tier-body::-webkit-scrollbar-track {
  background: transparent;
}
.tier-body::-webkit-scrollbar-thumb {
  background: #2a3040;
  border-radius: 3px;
}

.tier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tier-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.tier-table th {
  background: #1a1e2a;
  color: #8892a8;
  font-weight: 600;
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid #2a3040;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.tier-table th:hover {
  color: #f2f4f8;
}
.tier-table th.sorted-asc::after {
  content: ' ▲';
  font-size: 10px;
}
.tier-table th.sorted-desc::after {
  content: ' ▼';
  font-size: 10px;
}

.tier-table td {
  padding: 9px 16px;
  border-bottom: 1px solid #1e2536;
  color: #c8d0e0;
  white-space: nowrap;
}

.tier-table tbody tr {
  transition: background 0.1s;
}
.tier-table tbody tr:hover {
  background: #1e2536;
}

/* Highlight search match */
.tier-table tbody tr.search-match {
  background: #1e2a40;
}
.tier-table tbody tr.search-match td {
  color: #f2f4f8;
}

/* Column widths */
.col-rank { width: 60px; text-align: center; }
.col-name { min-width: 200px; }
.col-lp { width: 90px; text-align: right; }
.col-wins { width: 70px; text-align: right; }
.col-losses { width: 70px; text-align: right; }
.col-wr { width: 80px; text-align: right; }

.tier-table td.col-rank { text-align: center; color: #555d70; font-weight: 600; }
.tier-table td.col-lp { text-align: right; font-weight: 700; color: #f2f4f8; }
.tier-table td.col-wins { text-align: right; color: #22c55e; }
.tier-table td.col-losses { text-align: right; color: #ef4444; }
.tier-table td.col-wr { text-align: right; font-weight: 600; }

/* WR color coding */
.wr-high { color: #22c55e; }
.wr-mid { color: #eab308; }
.wr-low { color: #ef4444; }

/* Name loading placeholder */
.name-loading {
  color: #555d70;
  font-style: italic;
  font-size: 12px;
}

/* Top 3 rank badges */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}
.rank-1 { background: #f59e0b22; color: #f59e0b; border: 1px solid #f59e0b44; }
.rank-2 { background: #94a3b822; color: #94a3b8; border: 1px solid #94a3b844; }
.rank-3 { background: #cd7f3222; color: #cd7f32; border: 1px solid #cd7f3244; }

/* ── Player Expand (champion pool) ──── */
.player-expand-row td {
  padding: 0 !important;
  border-bottom: 1px solid #2a3040;
  background: #111520;
}

.expand-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  color: #8892a8;
  font-size: 13px;
}

.expand-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #2a3040;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.expand-error {
  padding: 16px 20px;
  color: #ef4444;
  font-size: 13px;
}

.expand-empty {
  padding: 16px 20px;
  color: #555d70;
  font-size: 13px;
}

.expand-content {
  padding: 12px 20px 16px;
}

.expand-header {
  font-size: 12px;
  font-weight: 600;
  color: #8892a8;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.expand-champs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.expand-champ {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a1e2a;
  border: 1px solid #2a3040;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 180px;
}

.expand-champ-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #2a3040;
  flex-shrink: 0;
}

.expand-champ-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.expand-champ-name {
  font-size: 12px;
  font-weight: 600;
  color: #f2f4f8;
}

.expand-champ-stats {
  font-size: 11px;
  color: #8892a8;
}

/* ── Pagination ─────────────────────── */
#pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 14px 0;
  flex-wrap: wrap;
}

.page-btn {
  background: #1a1f2e;
  color: #c5cee0;
  border: 1px solid #2a3040;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.page-btn:hover:not(.disabled):not(.active) {
  background: #252b3b;
  border-color: #3a4560;
}
.page-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}
.page-btn.disabled {
  opacity: 0.35;
  cursor: default;
}

.page-ellipsis {
  color: #556;
  font-size: 14px;
  padding: 0 4px;
}

/* ── Responsive ─────────────────────── */
@media (max-width: 768px) {
  .leaderboard-container {
    padding: 12px 12px;
  }
  .leaderboard-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .controls-left, .controls-right {
    width: 100%;
  }
  .control-search {
    width: 100%;
  }
  .summary-stats {
    flex-direction: column;
  }
  .col-wins, .col-losses {
    display: none;
  }
}
