
/* Leaderboard page styles reconstructed from the leaderboard HTML structure.
   These rules target only the leaderboard-specific ".lb-" classes. */

/* Page shell */
.lb-main {
  padding: var(--space-8) 0 var(--space-16);
  background: var(--bg);
}

/* Header */
.lb-page-header {
  position: relative;
  overflow: hidden;
  padding: var(--space-8) 0;
  background: linear-gradient(135deg, var(--primary-ultra) 0%, #f0fdf9 45%, #eff6ff 100%);
  border-bottom: 1px solid var(--border);
}

.lb-header-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background:
    radial-gradient(circle at 15% 20%, rgba(16,185,129,.12) 0%, transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(99,102,241,.10) 0%, transparent 32%),
    radial-gradient(circle at 50% 85%, rgba(245,158,11,.08) 0%, transparent 30%);
}

.lb-header-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.lb-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.lb-header-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: var(--text-2xl);
  box-shadow: var(--shadow-primary);
  flex-shrink: 0;
}

.lb-page-title {
  font-size: clamp(var(--text-3xl), 4vw, var(--text-5xl));
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.lb-page-sub {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-secondary);
}

.lb-page-sub strong {
  color: var(--primary-dark);
}

.lb-header-right {
  flex-shrink: 0;
}

.lb-live-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.22);
  color: var(--primary-dark);
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
}

.lb-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(16,185,129,.45);
  animation: lbPulse 1.8s ease-in-out infinite;
}

@keyframes lbPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.45); }
  70%  { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* User position card */
.lb-user-position {
  margin-bottom: var(--space-6);
}

.lb-user-card-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
  overflow: hidden;
}

/* Tabs */
.lb-tabs-wrap {
  position: sticky;
  top: calc(var(--nav-height) + 1px);
  z-index: 85;
  margin-bottom: var(--space-5);
}

.lb-tabs {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.lb-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease);
}

.lb-tab:hover {
  background: var(--bg-secondary);
  color: var(--text);
}

.lb-tab.active {
  background: var(--primary-pale);
  color: var(--primary-dark);
  border-color: rgba(16,185,129,.18);
  box-shadow: var(--shadow-xs);
}

/* Filters */
.lb-filters-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-6);
}

.lb-period-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.lb-period-btn {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all var(--duration-fast) var(--ease);
}

.lb-period-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-ultra);
}

.lb-period-btn.active {
  border-color: rgba(16,185,129,.25);
  background: var(--primary-pale);
  color: var(--primary-dark);
}

.lb-filter-select {
  min-width: 180px;
  max-width: 220px;
}

.lb-search-wrap {
  position: relative;
  min-width: 240px;
  max-width: 320px;
}

.lb-search-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#lbSearch,
#lbCountryFilter {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease);
}

#lbSearch {
  padding: var(--space-3) var(--space-4) var(--space-3) 42px;
}

#lbCountryFilter {
  padding: var(--space-3) var(--space-4);
}

#lbSearch:focus,
#lbCountryFilter:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

/* Podium */
.lb-podium-wrap {
  margin-bottom: var(--space-6);
}

.lb-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  align-items: end;
}

/* Generic podium card styles for JS-rendered content */
.lb-podium > * {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform var(--duration-base) var(--ease-spring),
              box-shadow var(--duration-base) var(--ease);
}

.lb-podium > *:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.lb-podium > *:first-child {
  margin-top: 0;
}

.lb-podium > *:nth-child(1) { min-height: 250px; }
.lb-podium > *:nth-child(2) { min-height: 220px; }
.lb-podium > *:nth-child(3) { min-height: 200px; }

.lb-podium > *::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(16,185,129,.04) 100%);
  pointer-events: none;
}

/* Table */
.lb-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.lb-th {
  text-align: left;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.lb-table tbody td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.lb-table tbody tr:hover {
  background: var(--bg-secondary);
}

.lb-th-hide-sm,
.lb-th-hide-xs {
  display: table-cell;
}

.lb-skeleton-row td {
  padding: 0;
}

.lb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-8);
  color: var(--text-muted);
  font-weight: 600;
}

.lb-skeleton-row .lb-loading i {
  animation: spin 1s linear infinite;
}

/* Load more */
.lb-load-more-wrap {
  margin-top: var(--space-6);
  display: flex;
  justify-content: center;
}

/* Leaderboard-specific utility styles for JS-generated content */
.lb-rank {
  font-weight: 800;
  color: var(--primary-dark);
}

.lb-student {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 220px;
}

.lb-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.lb-student-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.lb-student-name {
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.lb-student-country {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.lb-score {
  font-weight: 800;
  color: var(--primary-dark);
}

.lb-mcq,
.lb-accuracy,
.lb-streak {
  color: var(--text-secondary);
  font-weight: 600;
}

.lb-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.lb-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--primary-pale);
  color: var(--primary-dark);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

.lb-rank-top {
  background: linear-gradient(135deg, var(--accent-pale), #fff7ed);
  color: var(--accent-dark);
}

/* Dark mode */
[data-theme="dark"] .lb-page-header {
  background: linear-gradient(135deg, rgba(16,185,129,.08) 0%, rgba(10,15,30,1) 70%);
}

[data-theme="dark"] .lb-tabs {
  background: rgba(17,24,39,.75);
}

[data-theme="dark"] .lb-tab:hover {
  background: var(--bg-tertiary);
}

[data-theme="dark"] .lb-user-card-inner,
[data-theme="dark"] .lb-table-wrap,
[data-theme="dark"] .lb-podium > * {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .lb-th {
  background: var(--bg-secondary);
}

[data-theme="dark"] .lb-table tbody tr:hover {
  background: var(--bg-secondary);
}

[data-theme="dark"] .lb-live-badge {
  background: rgba(16,185,129,.08);
  border-color: rgba(16,185,129,.18);
}

[data-theme="dark"] .lb-period-btn {
  background: var(--surface);
}

/* Responsive */
@media (max-width: 1024px) {
  .lb-filters-row {
    grid-template-columns: 1fr 1fr;
  }

  .lb-search-wrap {
    grid-column: span 2;
    max-width: 100%;
  }

  .lb-podium {
    gap: var(--space-3);
  }

  .lb-podium > * {
    padding: var(--space-4);
  }
}

@media (max-width: 768px) {
  .lb-main {
    padding: var(--space-6) 0 var(--space-12);
  }

  .lb-page-header {
    padding: var(--space-6) 0;
  }

  .lb-header-content {
    align-items: flex-start;
  }

  .lb-tabs-wrap {
    top: calc(var(--nav-height) + 1px);
  }

  .lb-tabs {
    padding: var(--space-2);
  }

  .lb-tab {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  .lb-filters-row {
    grid-template-columns: 1fr;
  }

  .lb-search-wrap,
  .lb-filter-select {
    min-width: 100%;
    max-width: 100%;
  }

  .lb-podium {
    grid-template-columns: 1fr;
  }

  .lb-podium > *:nth-child(1),
  .lb-podium > *:nth-child(2),
  .lb-podium > *:nth-child(3) {
    min-height: auto;
  }

  .lb-th-hide-sm {
    display: none;
  }

  .lb-table tbody td:nth-child(4),
  .lb-table tbody td:nth-child(5) {
    display: none;
  }

  .lb-student {
    min-width: 0;
  }

  .lb-user-card-inner {
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .lb-page-title {
    font-size: var(--text-2xl);
  }

  .lb-page-sub {
    font-size: var(--text-sm);
  }

  .lb-live-badge {
    font-size: var(--text-xs);
  }

  .lb-tab {
    padding: var(--space-2);
    gap: 6px;
  }

  .lb-period-group {
    gap: 6px;
  }

  .lb-period-btn {
    padding: 7px 12px;
    font-size: 11px;
  }

  .lb-table thead {
    display: none;
  }

  .lb-table,
  .lb-table tbody,
  .lb-table tr,
  .lb-table td {
    display: block;
    width: 100%;
  }

  .lb-table tbody tr {
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) var(--space-4);
  }

  .lb-table tbody td {
    border: 0;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .lb-table tbody td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .lb-th-hide-xs {
    display: none;
  }

  .lb-badges {
    justify-content: flex-end;
  }
}
