/*
 * Leaderboards Page
 *
 * Styles public leaderboard browsing. Includes board tabs, filter controls,
 * leaderboard tables, rank movement indicators, weekly vote timer, export
 * actions, pagination, empty states, and responsive layouts.
 */

.leaderboards-page {
    min-height: calc(100vh - 200px);
    padding: 40px 20px 60px;
    position: relative;
    overflow: hidden;
}

.leaderboards-page::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 900px;
    height: 900px;
    background: radial-gradient(circle, rgba(74, 163, 255, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.leaderboards-container {
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* HEADER */
.leaderboards-header {
    text-align: center;
    margin-bottom: 32px;
}

.leaderboards-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, rgba(74, 163, 255, 0.2), rgba(74, 163, 255, 0.05));
    border: 1px solid rgba(74, 163, 255, 0.3);
    border-radius: 18px;
    margin-bottom: 20px;
}

.leaderboards-icon i {
    font-size: 1.8rem;
    color: #60a5fa;
}

.leaderboards-title {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(to bottom, #e0f0ff, #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.leaderboards-subtitle {
    color: #8899b5;
    font-size: 1rem;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto;
}

/* CATEGORY TABS */
.category-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.category-tab {
    padding: 12px 24px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #8a94a8;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-tab:hover {
    background: rgba(74, 163, 255, 0.1);
    border-color: rgba(74, 163, 255, 0.25);
    color: #c5d9f0;
    transform: translateY(-2px);
}

.category-tab.active {
    background: rgba(74, 163, 255, 0.18);
    border-color: rgba(74, 163, 255, 0.4);
    color: #fff;
    box-shadow: 0 4px 12px rgba(74, 163, 255, 0.2);
}

.category-tab i {
    font-size: 1.1rem;
}

/* MAIN CONTENT CARD */
.leaderboards-card {
    background: rgba(15, 20, 35, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* EXPORT BUTTONS */
.export-section {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    background: rgba(74, 163, 255, 0.1);
    border: 1px solid rgba(74, 163, 255, 0.2);
    color: #60a5fa;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.25s ease;
    margin: 0 6px;
}

.export-btn:hover {
    background: rgba(74, 163, 255, 0.18);
    border-color: rgba(74, 163, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 163, 255, 0.25);
}

.export-btn:active {
    transform: translateY(0);
}

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

/* TABLE */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.leaderboard-table th {
    padding: 14px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #7a8aa5;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leaderboard-table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: #d4e4ff;
}

.leaderboard-table tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.leaderboard-table tr:hover {
    background: rgba(74, 163, 255, 0.06);
}

.leaderboard-table tr.top-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.08), rgba(255, 215, 0, 0.02));
    border-left: 3px solid rgba(255, 215, 0, 0.5);
}

.leaderboard-table tr.top-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.06), rgba(192, 192, 192, 0.02));
    border-left: 3px solid rgba(192, 192, 192, 0.4);
}

.leaderboard-table tr.top-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.06), rgba(205, 127, 50, 0.02));
    border-left: 3px solid rgba(205, 127, 50, 0.4);
}

.gold-text {
    color: #ffd700;
    font-weight: 700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Rank Badge Inline */
.rank-badge-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.85rem;
    margin-right: 8px;
    vertical-align: middle;
}

.rank-badge-inline.gold {
    background: linear-gradient(135deg, #ffd700, #b8860b);
    border: 2px solid #ffd700;
    color: #1a1a2e;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

.rank-badge-inline.silver {
    background: linear-gradient(135deg, #c0c0c0, #808080);
    border: 2px solid #c0c0c0;
    color: #1a1a2e;
    box-shadow: 0 0 10px rgba(192, 192, 192, 0.4);
}

.rank-badge-inline.bronze {
    background: linear-gradient(135deg, #cd7f32, #8b4513);
    border: 2px solid #cd7f32;
    color: #1a1a2e;
    box-shadow: 0 0 10px rgba(205, 127, 50, 0.4);
}

/* Rank Change Indicators */
.rank-change {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-left: 6px;
    vertical-align: middle;
    animation: rankPulse 0.5s ease-out;
}

.rank-change.up {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.rank-change.down {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.rank-change.same {
    background: rgba(156, 163, 175, 0.15);
    color: #9ca3af;
    border: 1px solid rgba(156, 163, 175, 0.25);
}

@keyframes rankPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes rankBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

/* Rank Change Cell */
.rank-change-cell {
    text-align: right;
    width: 50px;
}

/* Week Timer */
.week-timer {
    background: linear-gradient(135deg, rgba(74, 163, 255, 0.08), rgba(37, 99, 235, 0.04));
    border: 1px solid rgba(74, 163, 255, 0.15);
    border-radius: 14px;
    padding: 18px 24px;
    text-align: center;
    margin-bottom: 24px;
}

.week-timer-label {
    font-size: 0.8rem;
    color: #7a8aa5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.week-timer-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #60a5fa;
}

/* Section Title */
.section-title {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #d4e4ff;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.section-title i {
    color: #60a5fa;
}

/* Empty State */
.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #5a6a85;
}

.no-data-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.4;
    color: #5a6a85;
}

.no-data-text {
    font-size: 1rem;
    margin-bottom: 8px;
    color: #8899b5;
}

.no-data-subtext {
    font-size: 0.85rem;
    color: #5a6a85;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .leaderboards-card {
        padding: 24px 20px;
    }

    .leaderboards-title {
        font-size: 2rem;
    }

    .category-tabs {
        gap: 8px;
    }

    .category-tab {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

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

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px 8px;
    }
}

@media (max-width: 576px) {
    .leaderboards-page {
        padding: 24px 16px 40px;
    }

    .leaderboards-title {
        font-size: 1.8rem;
    }

    .category-tabs {
        flex-direction: column;
        align-items: stretch;
    }

    .category-tab {
        justify-content: center;
    }

    .export-section {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .export-btn {
        width: 100%;
        justify-content: center;
        margin: 0;
    }
}

/* Modern leaderboards refresh */
.leaderboards-page {
    padding: 42px 20px 70px;
}

.leaderboards-page::before {
    top: -120px;
    left: 12%;
    transform: none;
    width: 980px;
    height: 680px;
    background:
        radial-gradient(ellipse at 20% 8%, rgba(74, 163, 255, 0.12), transparent 52%),
        radial-gradient(ellipse at 72% 26%, rgba(251, 191, 36, 0.06), transparent 46%);
}

.leaderboards-page::after {
    content: '';
    position: absolute;
    right: -220px;
    bottom: 8%;
    width: 620px;
    height: 620px;
    background: radial-gradient(circle, rgba(125, 175, 255, 0.055), transparent 64%);
    pointer-events: none;
}

.leaderboards-container {
    max-width: 1180px;
}

.leaderboards-header,
.category-tabs,
.leaderboards-card {
    background:
        radial-gradient(ellipse at 18% 0%, rgba(74, 163, 255, 0.10), transparent 44%),
        linear-gradient(180deg, rgba(10, 15, 25, 0.62), rgba(7, 12, 22, 0.54));
    backdrop-filter: blur(16px) saturate(130%);
    border: 1px solid rgba(125, 175, 255, 0.14);
    box-shadow: 0 18px 44px rgba(0,0,0,0.24);
    position: relative;
    overflow: hidden;
}

.leaderboards-header::before,
.category-tabs::before,
.leaderboards-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(125, 175, 255, 0.42), transparent);
}

.leaderboards-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 22px;
    text-align: left;
    padding: 30px;
    border-radius: 18px;
    margin-bottom: 18px;
}

.leaderboards-icon {
    width: 58px;
    height: 58px;
    margin: 0;
    border-radius: 16px;
    background: rgba(74, 163, 255, 0.11);
    border-color: rgba(125, 175, 255, 0.20);
}

.leaderboards-title {
    margin: 0 0 8px;
    color: #f4f8ff;
    background: none;
    -webkit-text-fill-color: currentColor;
    font-size: 2.1rem;
    line-height: 1.05;
}

.leaderboards-subtitle {
    max-width: none;
    margin: 0;
    color: #9fb2ce;
}

.leaderboards-hero-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 14px;
    border-radius: 999px;
    color: #7bb4ff;
    border: 1px solid rgba(125, 175, 255, 0.18);
    background: rgba(255,255,255,0.045);
    font-weight: 900;
    white-space: nowrap;
}

.leaderboard-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(125, 175, 255, 0.12);
    background: rgba(255,255,255,0.035);
}

.leaderboard-filters label {
    display: grid;
    gap: 6px;
    color: #8fa5c4;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.leaderboard-filters select {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(125, 175, 255, 0.16);
    color: #e7f0ff;
    background: rgba(8, 14, 25, 0.78);
    font-weight: 800;
}

.leaderboard-filters option {
    color: #e7f0ff;
    background: #08111f;
}

.leaderboard-reset {
    align-self: end;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: #c8d7ee;
    background: rgba(255,255,255,0.045);
    font-weight: 900;
}

.leaderboard-reset.is-hidden {
    visibility: hidden;
    pointer-events: none;
}

.leaderboard-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.leaderboard-meta .section-title {
    margin-bottom: 0;
}

.leaderboard-updated {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border-radius: 999px;
    border: 1px solid rgba(125, 175, 255, 0.14);
    color: #9fb2ce;
    background: rgba(255,255,255,0.04);
    font-size: 0.78rem;
    font-weight: 900;
    white-space: nowrap;
}

.category-tabs {
    justify-content: flex-start;
    padding: 12px;
    border-radius: 18px;
    margin-bottom: 18px;
}

.category-tab {
    flex: 1;
    min-width: 150px;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255,255,255,0.045);
    border-color: rgba(255,255,255,0.08);
    color: #d7e6ff;
    font-weight: 900;
}

.category-tab:hover {
    transform: translateY(-1px);
}

.category-tab.active {
    background: rgba(74, 163, 255, 0.18);
    border-color: rgba(125, 175, 255, 0.34);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.leaderboards-card {
    border-radius: 18px;
    padding: 24px;
}

.section-title {
    margin-bottom: 18px;
    color: #f4f8ff;
    font-weight: 900;
    text-shadow: none;
}

.leaderboard-table {
    border-collapse: separate;
    border-spacing: 0 8px;
}

.leaderboard-table th {
    padding: 10px 14px;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    color: #8fa5c4;
    font-weight: 900;
}

.leaderboard-table td {
    padding: 14px;
    background: rgba(255,255,255,0.04);
    border-top: 1px solid rgba(255,255,255,0.07);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    color: #d7e6ff;
}

.leaderboard-table td:first-child {
    border-left: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px 0 0 14px;
    width: 86px;
}

.leaderboard-table td:last-child {
    border-right: 1px solid rgba(255,255,255,0.07);
    border-radius: 0 14px 14px 0;
}

.leaderboard-table tr:nth-child(even) {
    background: transparent;
}

.leaderboard-table tr:hover td {
    background: rgba(74, 163, 255, 0.075);
}

.leaderboard-table tr.top-1 td {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.13), rgba(255,255,255,0.04));
    border-color: rgba(251, 191, 36, 0.24);
}

.leaderboard-table tr.top-2 td {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.13), rgba(255,255,255,0.04));
    border-color: rgba(148, 163, 184, 0.22);
}

.leaderboard-table tr.top-3 td {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.10), rgba(255,255,255,0.04));
    border-color: rgba(245, 158, 11, 0.20);
}

.rank-number {
    width: 38px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #b9d7ff;
    background: rgba(74, 163, 255, 0.10);
    border: 1px solid rgba(125, 175, 255, 0.16);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.top-1 .rank-number {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.12);
    border-color: rgba(251, 191, 36, 0.26);
}

.top-2 .rank-number {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.13);
    border-color: rgba(148, 163, 184, 0.24);
}

.top-3 .rank-number {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.11);
    border-color: rgba(245, 158, 11, 0.22);
}

.leaderboard-name {
    color: #f4f8ff;
    font-weight: 900;
}

.rank-badge-inline {
    display: none;
}

.rank-change {
    width: auto;
    min-width: 42px;
    height: 30px;
    gap: 2px;
    padding: 0 10px;
    border-radius: 999px;
    margin-left: 0;
    animation: none;
    font-weight: 900;
}

.rank-change.up,
.rank-change.down {
    animation: none;
}

.rank-change.same {
    color: #8fa5c4;
    background: rgba(148, 163, 184, 0.10);
    border-color: rgba(148, 163, 184, 0.16);
}

.rank-change-cell {
    width: 115px;
    text-align: left;
}

.week-timer {
    margin: 18px 0 0;
    border-radius: 16px;
    background: rgba(74, 163, 255, 0.075);
    border-color: rgba(125, 175, 255, 0.16);
}

.leaderboard-pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.leaderboard-page-btn,
.leaderboard-page-gap {
    min-width: 38px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(125, 175, 255, 0.14);
    color: #b9d7ff;
    background: rgba(255,255,255,0.04);
    font-weight: 900;
}

.leaderboard-page-btn.active {
    color: #fff;
    border-color: rgba(74, 163, 255, 0.44);
    background: rgba(74, 163, 255, 0.22);
}

#leaderboard-content.is-loading {
    opacity: 0.62;
    pointer-events: none;
}

@media (max-width: 768px) {
    .leaderboards-header {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .leaderboards-icon,
    .leaderboards-hero-pill {
        margin: 0 auto;
    }

    .category-tabs {
        flex-direction: column;
    }

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

    .leaderboard-meta {
        align-items: flex-start;
        flex-direction: column;
    }

    .leaderboard-table {
        min-width: 640px;
    }

    #leaderboard-content {
        overflow-x: auto;
    }
}
