/* ========================================
   قياس أونلاين — Leaderboard Styles
   لوحة المتصدرين
   ======================================== */

/* ========== Page Layout ========== */
.leaderboard-page {
    padding-top: 100px;
    min-height: 100vh;
    padding-bottom: 60px;
}

.leaderboard-header {
    text-align: center;
    margin-bottom: 40px;
}

.leaderboard-header h1 {
    font-size: clamp(1.8rem, 3.5vw, 2.5rem);
}

/* ========== Podium (Top 3) ========== */
.podium-section {
    margin-bottom: 40px;
}

.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 180px;
    position: relative;
}

.podium-crown {
    font-size: 1.8rem;
    animation: float 3s ease-in-out infinite;
    line-height: 1;
}

.podium-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: var(--bg-card);
    border: 3px solid var(--border-color);
    backdrop-filter: blur(10px);
    transition: all 0.4s ease;
}

.podium-first .podium-avatar {
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
    border-color: #FFD700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.3);
}

.podium-second .podium-avatar {
    border-color: #C0C0C0;
    box-shadow: 0 0 15px rgba(192, 192, 192, 0.2);
}

.podium-third .podium-avatar {
    border-color: #CD7F32;
    box-shadow: 0 0 15px rgba(205, 127, 50, 0.2);
}

.podium-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-score {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--green-400);
    direction: ltr;
    display: inline-block;
}

.podium-bar {
    width: 100%;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 12px;
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-bottom: none;
    position: relative;
    overflow: hidden;
}

.podium-bar::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px 12px 0 0;
    opacity: 0.12;
}

.podium-first .podium-bar {
    height: 120px;
    background: rgba(255, 215, 0, 0.08);
}

.podium-first .podium-bar::before {
    background: linear-gradient(to top, rgba(255, 215, 0, 0.2), transparent);
}

.podium-second .podium-bar {
    height: 90px;
    background: rgba(192, 192, 192, 0.06);
}

.podium-second .podium-bar::before {
    background: linear-gradient(to top, rgba(192, 192, 192, 0.15), transparent);
}

.podium-third .podium-bar {
    height: 70px;
    background: rgba(205, 127, 50, 0.06);
}

.podium-third .podium-bar::before {
    background: linear-gradient(to top, rgba(205, 127, 50, 0.15), transparent);
}

.podium-bar span {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-muted);
    opacity: 0.5;
}

/* ========== Controls ========== */
.leaderboard-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

.lb-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: 14px;
    padding: 4px;
    border: 1px solid var(--border-color);
}

.lb-tab {
    padding: 10px 24px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

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

.lb-tab.active {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

.lb-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.lb-filter {
    padding: 8px 18px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-glass-light);
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-family: inherit;
}

.lb-filter:hover {
    border-color: var(--green-400);
    color: var(--green-400);
}

.lb-filter.active {
    border-color: var(--green-400);
    color: var(--green-400);
    background: rgba(99, 102, 241, 0.08);
}

/* ========== My Rank Card ========== */
.my-rank-card {
    max-width: 700px;
    margin: 0 auto 24px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 2px solid var(--green-400);
    padding: 16px 24px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.12);
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.1); }
    50% { box-shadow: 0 0 35px rgba(99, 102, 241, 0.2); }
}

.my-rank-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(99, 102, 241, 0.05));
    pointer-events: none;
}

.my-rank-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--green-400);
    margin-bottom: 8px;
    position: relative;
}

.my-rank-content {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.my-rank-position {
    font-size: 1.8rem;
    font-weight: 900;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 60px;
    text-align: center;
    direction: ltr;
    display: inline-block;
}

.my-rank-info {
    flex: 1;
}

.my-rank-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.my-rank-stats {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
}

.my-rank-divider {
    color: var(--text-muted);
}

/* ========== Loading State ========== */
.lb-loading {
    text-align: center;
    padding: 80px 20px;
}

.lb-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--green-400);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

.lb-loading p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ========== Empty / Error State ========== */
.lb-empty {
    text-align: center;
    padding: 80px 20px;
}

.lb-empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.lb-empty h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.lb-empty p {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 24px;
}

/* ========== Leaderboard Table ========== */
.lb-table-wrapper {
    max-width: 700px;
    margin: 0 auto;
}

.lb-table {
    width: 100%;
}

.lb-table-header {
    display: grid;
    grid-template-columns: 60px 1fr 100px 100px;
    gap: 12px;
    padding: 12px 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.lb-table-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Row */
.lb-row {
    display: grid;
    grid-template-columns: 60px 1fr 100px 100px;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    align-items: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    animation: fadeInUp 0.4s ease both;
}

.lb-row:hover {
    border-color: var(--border-glow);
    transform: translateX(-4px);
    box-shadow: var(--shadow-sm);
}

/* Current user row highlight */
.lb-row.is-me {
    border-color: var(--green-400);
    background: rgba(99, 102, 241, 0.06);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.08);
}

.lb-row.is-me:hover {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.12);
}

/* Top 3 rows */
.lb-row.rank-1 {
    border-color: rgba(255, 215, 0, 0.3);
    background: rgba(255, 215, 0, 0.04);
}

.lb-row.rank-2 {
    border-color: rgba(192, 192, 192, 0.2);
    background: rgba(192, 192, 192, 0.03);
}

.lb-row.rank-3 {
    border-color: rgba(205, 127, 50, 0.2);
    background: rgba(205, 127, 50, 0.03);
}

/* Rank Column */
.lb-col-rank {
    text-align: center;
    font-weight: 800;
    font-size: 1rem;
}

.lb-rank-badge {
    font-size: 1.4rem;
    line-height: 1;
}

.lb-rank-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-glass-light);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* User Column */
.lb-col-user {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.lb-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 800;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.lb-user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Score Column */
.lb-col-score {
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    direction: ltr;
    display: inline-block;
}

.lb-col-score.high { color: var(--success); }
.lb-col-score.medium { color: var(--warning); }
.lb-col-score.low { color: var(--danger); }

/* Quizzes Column */
.lb-col-quizzes {
    text-align: center;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ========== Stagger Animation ========== */
.lb-row:nth-child(1) { animation-delay: 0.05s; }
.lb-row:nth-child(2) { animation-delay: 0.1s; }
.lb-row:nth-child(3) { animation-delay: 0.15s; }
.lb-row:nth-child(4) { animation-delay: 0.2s; }
.lb-row:nth-child(5) { animation-delay: 0.25s; }
.lb-row:nth-child(6) { animation-delay: 0.3s; }
.lb-row:nth-child(7) { animation-delay: 0.35s; }
.lb-row:nth-child(8) { animation-delay: 0.4s; }
.lb-row:nth-child(9) { animation-delay: 0.45s; }
.lb-row:nth-child(10) { animation-delay: 0.5s; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .leaderboard-page {
        padding-top: 90px;
    }

    .podium {
        gap: 10px;
    }

    .podium-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.6rem;
    }

    .podium-first .podium-avatar {
        width: 64px;
        height: 64px;
        font-size: 2rem;
    }

    .podium-first .podium-bar { height: 90px; }
    .podium-second .podium-bar { height: 65px; }
    .podium-third .podium-bar { height: 50px; }

    .podium-name {
        font-size: 0.8rem;
        max-width: 90px;
    }

    .lb-table-header {
        grid-template-columns: 50px 1fr 70px 70px;
        gap: 8px;
        padding: 10px 14px;
        font-size: 0.75rem;
    }

    .lb-row {
        grid-template-columns: 50px 1fr 70px 70px;
        gap: 8px;
        padding: 12px 14px;
    }

    .lb-user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
        border-radius: 8px;
    }

    .lb-user-name {
        font-size: 0.85rem;
    }

    .lb-col-score {
        font-size: 0.85rem;
    }

    .lb-col-quizzes {
        font-size: 0.8rem;
    }

    .my-rank-card {
        padding: 14px 18px;
    }

    .my-rank-position {
        font-size: 1.4rem;
        min-width: 45px;
    }

    .lb-tabs {
        width: 100%;
        justify-content: center;
    }

    .lb-tab {
        padding: 8px 18px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .lb-table-header {
        grid-template-columns: 40px 1fr 60px;
        font-size: 0.7rem;
    }

    .lb-col-quizzes.header-quizzes {
        display: none;
    }

    .lb-row {
        grid-template-columns: 40px 1fr 60px;
    }

    .lb-row .lb-col-quizzes {
        display: none;
    }

    .lb-user-avatar {
        display: none;
    }

    .podium-crown {
        font-size: 1.3rem;
    }

    .podium-score {
        font-size: 0.75rem;
    }

    .lb-tab {
        padding: 7px 14px;
        font-size: 0.85rem;
    }

    .lb-filter {
        padding: 6px 14px;
        font-size: 0.82rem;
    }
}
