/* Leaderboard 2.0 - Premium Card Design */

.leaderboard-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header Section */
.glass-card h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Period Tabs */
.period-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: rgba(17, 24, 39, 0.5);
    border: 1px solid var(--border);
    border-radius: 99px;
    backdrop-filter: blur(10px);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.period-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 99px;
    transition: var(--transition);
}

.period-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.period-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* User Stats Widget */
.user-stats-widget {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 95, 70, 0.3));
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.6s ease-out;
}

.user-stats-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: var(--success);
}

.user-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stat-box {
    text-align: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    transition: transform 0.2s;
}

.stat-box:hover {
    transform: translateY(-2px);
    background: rgba(0, 0, 0, 0.3);
}

.stat-box-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--success);
    text-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

/* Leaderboard List (Replacing Table) */
.leaderboard-header {
    display: none;
    /* Hidden for card layout */
}

/* Base Card Style */
.leaderboard-row {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    align-items: center;
    gap: 1.5rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    opacity: 0;
    /* Animated in via JS or CSS */
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Stagger Animations */
.leaderboard-row:nth-child(1) {
    animation-delay: 0.1s;
}

.leaderboard-row:nth-child(2) {
    animation-delay: 0.15s;
}

.leaderboard-row:nth-child(3) {
    animation-delay: 0.2s;
}

.leaderboard-row:nth-child(4) {
    animation-delay: 0.25s;
}

.leaderboard-row:nth-child(5) {
    animation-delay: 0.3s;
}

.leaderboard-row:hover {
    transform: scale(1.02);
    z-index: 10;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.leaderboard-row.current-user {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Rank Column */
.rank-badge {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.2rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

/* Medal Styles */
.rank-badge.gold {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: white;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
    font-size: 1.5rem;
}

.leaderboard-row:has(.gold) {
    border-color: rgba(251, 191, 36, 0.4);
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.05), transparent);
}

.rank-badge.silver {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    color: white;
    box-shadow: 0 4px 12px rgba(148, 163, 184, 0.4);
    font-size: 1.4rem;
}

.rank-badge.bronze {
    background: linear-gradient(135deg, #b45309, #78350f);
    color: white;
    box-shadow: 0 4px 12px rgba(180, 83, 9, 0.4);
    font-size: 1.3rem;
}

/* User Info Column */
.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.user-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-name span {
    /* 'Tu' badge */
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8 !important;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

/* Stats Column (Right Side) */
.stats-grid {
    display: flex;
    gap: 2rem;
    text-align: right;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.score-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.secondary-stats {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mini-stat span:first-child {
    font-weight: 700;
    color: var(--text-secondary);
}

.mini-stat span:last-child {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .leaderboard-row {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 1rem;
        padding: 1rem;
    }

    .rank-badge {
        grid-row: 1 / 3;
    }

    .user-info {
        grid-column: 2;
    }

    .stats-grid {
        grid-column: 1 / -1;
        justify-content: space-between;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
        width: 100%;
        text-align: left;
    }

    .secondary-stats {
        gap: 1rem;
    }

    .hide-mobile {
        display: none !important;
    }
}

/* Loading Spinner */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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