/* ==========================================================================
   🏆 NEXTEDU - ELITE LEADERBOARD CSS (v2.6 Glassmorphism Edition)
   ========================================================================== */

:root {
    --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --font-outfit: 'Outfit', sans-serif;
}

/* Disable text selection everywhere except inputs */
body {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    font-family: var(--font-outfit);
}

input, textarea {
    -webkit-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Drift glow background shapes */
body.dashboard-body::before {
    content: '';
    position: fixed;
    width: 45vw;
    height: 45vw;
    max-width: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.05) 0%, rgba(99, 102, 241, 0) 70%);
    top: -10%;
    left: -10%;
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
}

body.dashboard-body::after {
    content: '';
    position: fixed;
    width: 35vw;
    height: 35vw;
    max-width: 400px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.05) 0%, rgba(236, 72, 153, 0) 70%);
    bottom: 5%;
    right: -10%;
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
}

/* Adjust Main Content Padding for Leaderboard */
.main-content {
    padding-bottom: 120px !important;
}

.leaderboard-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 4px;
}

/* iOS Style Toggle for Weekly/Monthly */
.rank-toggle-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
    margin-top: 10px;
}

.rank-toggle-pill {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 5px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 350px;
}

.toggle-btn {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 800;
    font-size: 0.9rem;
    border-radius: 15px;
    cursor: pointer;
    transition: var(--transition-smooth);
    font-family: var(--font-outfit);
}

.toggle-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.25);
}

.refresh-text {
    font-size: 0.76rem;
    color: var(--success, #10b981);
    margin-top: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reset-text {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
    min-height: 18px;
    font-weight: 600;
}

/* =========================================
   🥇 PODIUM SECTION (Top 3)
   ========================================= */
.podium-section {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    margin-top: 15px;
    padding: 25px 0;
    overflow: visible !important;
}

.podium-item {
    padding: 24px 12px;
    border-radius: 26px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 32%;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.4s ease, box-shadow 0.4s ease;
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    will-change: transform;
    box-shadow: var(--glass-shadow);
    overflow: visible !important;
}

/* ✨ Scaling & Glowing the Winners */
.podium-item.gold.main {
    transform: scale(1.1) translateY(-12px);
    z-index: 10;
    border: 1px solid rgba(251, 191, 36, 0.4);
    box-shadow: 0 15px 40px rgba(251, 191, 36, 0.15), inset 0 0 15px rgba(251, 191, 36, 0.05);
}
.podium-item.silver {
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 8px 25px rgba(148, 163, 184, 0.06);
}
.podium-item.bronze {
    border: 1px solid rgba(217, 119, 6, 0.35);
    box-shadow: 0 8px 25px rgba(217, 119, 6, 0.06);
}

.podium-item:hover {
    transform: translateY(-8px);
}
.podium-item.gold.main:hover {
    transform: scale(1.12) translateY(-18px);
    box-shadow: 0 20px 45px rgba(251, 191, 36, 0.22);
}

/* Avatar Adjustments inside Podium */
.podium-avatar {
    position: relative;
    overflow: visible !important;
    width: 65px;
    height: 65px;
    margin-bottom: 18px;
    border-radius: 50%;
}

.podium-item.gold.main .podium-avatar {
    width: 80px;
    height: 80px;
}

.podium-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    /* z-index: 2; */
    border: 3px solid var(--card-bg);
}

.podium-item.gold.main img { border-color: #fbbf24; }
.podium-item.silver img { border-color: #cbd5e1; }
.podium-item.bronze img { border-color: #d97706; }

/* Medals / Badges */
.rank-badge {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 900;
    font-size: 0.85rem;
    border: 2px solid var(--bg-color);
    z-index: 10;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
}
.badge-gold { background: linear-gradient(135deg, #fbbf24, #d97706); }
.badge-silver { background: linear-gradient(135deg, #cbd5e1, #64748b); }
.badge-bronze { background: linear-gradient(135deg, #d97706, #92400e); }

/* 👑 Gold Crown 3D Float Animation */
.crown {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translate3d(-50%, 0, 0) rotate(-12deg);
    font-size: 1.8rem;
    color: #FFD700;
    z-index: 20;
    filter: drop-shadow(0 4px 8px rgba(255, 215, 0, 0.45));
    animation: floatCrown 2.5s infinite ease-in-out alternate;
    will-change: transform;
}

@keyframes floatCrown {
    0% { transform: translate3d(-50%, 0, 0) rotate(-12deg); }
    100% { transform: translate3d(-50%, -8px, 0) rotate(-4deg); }
}

.podium-info h4 {
    margin: 0 0 4px;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
    word-break: break-word;
    font-family: var(--font-outfit);
}
.podium-info p {
    margin: 0 0 8px 0;
    font-weight: 900;
    font-size: 1.1rem;
    font-family: 'Orbitron', sans-serif;
}
.podium-item.gold p { color: #fbbf24; text-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }
.podium-item.silver p { color: #cbd5e1; }
.podium-item.bronze p { color: #d97706; }

/* Podium Extra Stats */
.podium-stats {
    display: flex;
    gap: 8px;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(0,0,0,0.18);
    padding: 5px 10px;
    border-radius: 10px;
    color: var(--text-muted);
}
[data-theme="light"] .podium-stats { background: rgba(0,0,0,0.04); }

/* =========================================
   📜 RANK LIST (4th to Infinity)
   ========================================= */
.rank-list-wrapper {
    overflow: hidden;
    padding: 0 !important;
}

/* 📏 Grid Alignment Lock */
.list-header, .rank-row {
    display: grid;
    grid-template-columns: 55px 2.2fr 1fr 1fr 100px;
    align-items: center;
    gap: 12px;
}

.list-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-muted);
    font-weight: 800;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: rgba(0,0,0,0.12);
    font-family: 'Orbitron', sans-serif;
}

.rank-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 20px;
}

.rank-row {
    padding: 14px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
}
.rank-row:hover {
    background: var(--input-bg);
    border-color: rgba(var(--primary-rgb), 0.22);
    transform: translate3d(6px, 0, 0);
    box-shadow: var(--glass-shadow);
}

.col-rank { font-weight: 900; color: var(--text-muted); font-size: 1rem; font-family: 'Orbitron', sans-serif; }
.col-learner { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text-main); font-size: 0.95rem; }
.col-stats { text-align: center; color: var(--text-muted); font-size: 0.9rem; font-weight: 700; }
.col-score { text-align: right; color: var(--primary-color); font-weight: 900; font-size: 1.05rem; font-family: 'Orbitron', sans-serif; }

.list-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--card-border);
    background: var(--card-bg);
}

.loading-state { text-align: center; padding: 40px; color: var(--text-muted); }

/* =========================================
   🚀 STICKY USER BAR (DYNAMIC ISLAND STYLE)
   ========================================= */
.user-rank-sticky {
    position: fixed;
    bottom: calc(var(--bottom-nav-height, 75px) + 15px);
    left: 50%;
    transform: translate3d(-50%, 0, 0);
    width: 90%;
    max-width: 580px;
    padding: 14px 22px;
    border: 1.5px solid var(--primary-color);
    border-radius: 22px;
    z-index: 1000;
    box-shadow: 0 12px 30px rgba(var(--primary-rgb), 0.2), inset 0 2px 10px rgba(255, 255, 255, 0.08);
    background: rgba(var(--bg-rgb, 15, 23, 42), 0.88);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    will-change: transform;
}

[data-theme="light"] .user-rank-sticky {
    background: rgba(255, 255, 255, 0.92);
}

.user-rank-content {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.rank-num {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-color);
    width: 50px;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
}

.player-info { flex-grow: 1; }
.p-name { font-weight: 800; font-size: 1.1rem; color: var(--text-main); }
.rank-status { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; font-weight: 600; }
.p-score { font-weight: 900; color: #fbbf24; font-size: 1.35rem; text-shadow: 0 2px 10px rgba(251, 191, 36, 0.25); font-family: 'Orbitron', sans-serif; }

/* =========================================
   📱 MOBILE RESPONSIVENESS
   ========================================= */

@media (max-width: 768px) {
    .podium-section { gap: 8px; padding: 12px 0; }
    .podium-item { width: 33%; padding: 16px 6px; border-radius: 18px; }
    
    .podium-item.gold.main { transform: scale(1.08) translateY(-8px); }
    .podium-item:hover { transform: translateY(-3px); }
    .podium-item.gold.main:hover { transform: scale(1.08) translateY(-8px); }

    .podium-item .avatar-circle { width: 50px; height: 50px; margin-bottom: 12px; }
    .podium-item.gold.main .avatar-circle { width: 62px; height: 62px; }
    
    .crown { font-size: 1.4rem; top: -18px; }
    .rank-badge { width: 22px; height: 22px; font-size: 0.75rem; bottom: -4px; right: -4px; }

    .podium-info h4 { font-size: 0.82rem; }
    .podium-info p { font-size: 0.95rem; margin-bottom: 4px; }
    
    .podium-stats { flex-direction: column; gap: 3px; padding: 5px; font-size: 0.68rem; }
    
    /* Rank List Resizing */
    .list-header, .rank-row { grid-template-columns: 42px 1fr 80px; gap: 8px; }
    .hide-on-mobile { display: none !important; }
    
    .col-rank { font-size: 0.9rem; }
    .col-learner { font-size: 0.88rem; }
    .col-score { font-size: 0.92rem; }
    .list-avatar { width: 32px; height: 32px; }
    
    .list-header { padding: 14px 18px; }
    .rank-list { padding: 8px 12px; }
    .rank-row { padding: 12px 14px; border-radius: 14px; }
    .rank-row:hover { transform: translateX(3px); }
    
    /* Sticky Bar Resizing */
    .user-rank-sticky { width: 92%; padding: 10px 16px; border-radius: 18px; }
    .rank-num { font-size: 1.5rem; width: 38px; }
    .p-name { font-size: 0.98rem; }
    .p-score { font-size: 1.15rem; }
}

@media (max-width: 400px) {
    .crown { font-size: 1.1rem; top: -14px; }
    .podium-item .avatar-circle { width: 42px; height: 42px; }
    .podium-item.gold.main .avatar-circle { width: 52px; height: 52px; }
    .podium-info h4 { font-size: 0.72rem; }
}

/* =========================================
   🌓 LIGHT THEME OVERRIDES FOR LEADERBOARD
   ========================================= */
[data-theme="light"] .list-header {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .rank-row {
    background: rgba(0, 0, 0, 0.015);
    border-color: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .rank-row:hover {
    background: rgba(0, 0, 0, 0.035);
    border-color: rgba(0, 0, 0, 0.06);
}