/* ═══════════════════════════════════════
   Ranking Page Styles
   ═══════════════════════════════════════ */

/* ── LIVE BADGE ── */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  padding: 8px 18px;
  margin-top: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}

/* ── HERO STATS ── */
.hero-stats {
  display: flex;
  gap: 32px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-stat-val {
  font-size: 28px;
  font-weight: 900;
  color: var(--white);
  letter-spacing: -0.5px;
}

.hero-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ── CONTROLS BAR ── */
.controls-bar {
  background: var(--white);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 99, 63, 0.06);
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
}

.controls-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 14px var(--container-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tab-group { display: flex; }

.tab-btn {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--green-muted);
  background: transparent;
  border: 1.5px solid var(--border);
  border-right: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:first-child { border-radius: 8px 0 0 8px; }
.tab-btn:last-child { border-right: 1.5px solid var(--border); border-radius: 0 8px 8px 0; }
.tab-btn.active { background: var(--green); color: var(--white); border-color: var(--green); }
.tab-btn:hover:not(.active) { background: var(--green-light); color: var(--green); border-color: var(--green-border); }

.filter-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-select {
  padding: 8px 28px 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--dark);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a9e92'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition-fast);
}

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

.search-wrap { position: relative; }

.search-input {
  padding: 8px 14px 8px 36px;
  font-size: 13.5px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--dark);
  width: 220px;
  transition: border-color var(--transition-fast);
}

.search-input:focus { outline: none; border-color: var(--green); }

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--green-muted);
  pointer-events: none;
}

.refresh-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.refresh-btn:hover { border-color: var(--green); color: var(--green); }

.updated-label {
  font-size: 12px;
  color: var(--green-muted);
  white-space: nowrap;
}

/* ── MAIN LAYOUT ── */
.main {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 24px var(--container-padding) 48px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.ranking-col { flex: 1; min-width: 0; }

.sidebar {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── RANKING TABLE ── */
.table-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.table-title { font-size: 16px; font-weight: 800; color: var(--dark); }
.table-subtitle { font-size: 13px; color: var(--green-muted); margin-top: 2px; }
.table-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-muted);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  padding: 3px 10px;
  border-radius: 20px;
}

.table-header-right { display: flex; align-items: center; gap: 12px; }
.pagination-actions { display: flex; align-items: center; gap: 12px; }

table { width: 100%; border-collapse: collapse; }

thead tr { background: var(--bg); border-bottom: 2px solid var(--border); }

thead th {
  padding: 11px 14px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--green-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  white-space: nowrap;
}

thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--green); }
thead th.sorted { color: var(--green); }
thead th.r { text-align: center; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--green-light); }
tbody tr.podium-1 { background: #fffbeb; }
tbody tr.podium-2 { background: #f8f9fa; }
tbody tr.podium-3 { background: #fff7f0; }
tbody tr.podium-1:hover { background: #fef3c7; }

td { padding: 12px 14px; font-size: 14px; color: var(--text); vertical-align: middle; text-align: center; }
td.r { text-align: center; }
td.bold { font-weight: 700; color: var(--dark); }

.rank-cell { display: flex; align-items: center; justify-content: center; gap: 6px; width: 48px; margin: 0 auto; }
.rank-num { font-size: 14px; font-weight: 800; color: var(--dark); min-width: 22px; }
.rank-change { font-size: 11px; font-weight: 700; }
.rank-up { color: #16a34a; }
.rank-down { color: #dc2626; }
.rank-same { color: var(--green-muted); }

.player-cell { display: flex; align-items: center; gap: 10px; text-align: left; }

.player-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--white);
}

.player-name { font-weight: 700; color: var(--dark); font-size: 14px; }
.player-country { font-size: 12px; color: var(--green-muted); display: flex; align-items: center; gap: 4px; }

.score-bar-wrap { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 140px; margin: 0 auto; }
.score-bar-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; background: var(--green); }
.score-bar-fill.blue { background: var(--blue); }
.score-bar-fill.purple { background: var(--purple); }
.score-val { font-size: 14px; font-weight: 800; color: var(--dark); min-width: 42px; text-align: right; }

.path-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.path-open { background: var(--blue-light); color: var(--blue); }
.path-chal { background: var(--purple-light); color: var(--purple); }

.plat-badge { padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.plat-bbo { background: #dbeafe; color: #1e40af; }
.plat-fb { background: #dcfce7; color: #166534; }
.plat-both { background: var(--green-light); color: var(--green); }

.medal { font-size: 18px; }

/* ── PAGINATION ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--green-muted);
}

.page-btns { display: flex; gap: 4px; }

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.page-btn.active { background: var(--green); color: var(--white); border-color: var(--green); }
.page-btn:hover:not(.active):not(:disabled) { border-color: var(--green); color: var(--green); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── SIDEBAR CARDS ── */
.sidebar-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.sidebar-card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-card-body { padding: 14px 18px; }

/* Phase progress */
.phase-item { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.phase-item:last-child { margin-bottom: 0; }
.phase-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.phase-name { font-weight: 600; color: var(--dark); }

.phase-status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.phase-active { background: #dcfce7; color: #166534; }
.phase-upcoming { background: var(--bg); color: var(--green-muted); border: 1px solid var(--border); }
.phase-done { background: var(--green-light); color: var(--green); }

.phase-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.phase-bar-fill { height: 100%; border-radius: 3px; background: var(--green); }
.phase-detail { font-size: 12px; color: var(--green-muted); }

/* Distribution */
.distrib-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 13px; }
.distrib-row:last-child { margin-bottom: 0; }
.distrib-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.distrib-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.distrib-bar-fill.open { background: var(--blue); }
.distrib-bar-fill.chal { background: var(--purple); }
.distrib-bar-fill.bbo { background: #2563eb; }
.distrib-bar-fill.fb { background: var(--green); }
.distrib-label { font-weight: 600; color: var(--dark); min-width: 70px; }
.distrib-val { font-weight: 700; color: var(--dark); min-width: 38px; text-align: right; font-size: 13px; }

/* Top movers */
.mover-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mover-item:last-child { border-bottom: none; }
.mover-rank { font-size: 12px; font-weight: 700; color: var(--green-muted); width: 20px; }
.mover-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--dark); }
.mover-change { font-size: 13px; font-weight: 800; }
.mover-up { color: #16a34a; }

/* ═══════════════════════════════════════
   Responsive — Ranking
   ═══════════════════════════════════════ */
@media (max-width: 1100px) {
  .sidebar { display: none; }
  .main { padding: 24px 32px; }
}

@media (max-width: 768px) {
  .controls-inner { flex-direction: column; align-items: stretch; }
  .filter-group { flex-wrap: wrap; }
  .search-input { width: 100%; }
  .hero-stats { gap: 16px; }
  .hero-stat-val { font-size: 22px; }

  .main { padding: 16px; }

  /* Compact card chrome */
  .table-header { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .table-title { font-size: 14px; }
  .table-subtitle { display: none; }
  .table-header-right { gap: 8px; }
  .pagination { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .pagination-actions { gap: 8px; flex-wrap: wrap; }
  .updated-label { font-size: 11px; }

  /* Hide secondary columns: Sessions (4), Platform (5), Path (6).
     Keep #, Player, Score, Status. */
  thead th, td { padding: 10px 8px; font-size: 13px; }
  thead th:nth-child(4), tbody td:nth-child(4),
  thead th:nth-child(5), tbody td:nth-child(5),
  thead th:nth-child(6), tbody td:nth-child(6) { display: none; }

  .score-bar-wrap { min-width: 0; gap: 6px; }
  .score-bar-track { display: none; }
  .score-val { min-width: 0; font-size: 13px; }
  .player-avatar { width: 30px; height: 30px; font-size: 12px; }
  .player-name { font-size: 13px; }
  .player-country { font-size: 11px; }
  .rank-cell { width: auto; }
}

@media (max-width: 480px) {
  /* Drop Status (7) too — Player + Score is the essential pair. */
  thead th:nth-child(7), tbody td:nth-child(7) { display: none; }
  thead th, td { padding: 8px 6px; }
  .player-cell { gap: 8px; }
}

/* Avatar background colors — one class per slot (0–9), cycled in ranking.js */
.avatar-c0 { background: var(--green); }
.avatar-c1 { background: var(--blue); }
.avatar-c2 { background: var(--purple); }
.avatar-c3 { background: var(--red); }
.avatar-c4 { background: #c0781a; }
.avatar-c5 { background: #1a6b5a; }
.avatar-c6 { background: #5b4a00; }
.avatar-c7 { background: #1a3a6b; }
.avatar-c8 { background: #6b1a1a; }
.avatar-c9 { background: #2d6b1a; }
