/* Leaderboard Specific Styles */
:root {
    --gold: #FFD700;
    --silver: #C0C0C0;
    --bronze: #CD7F32;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

.leaderboard-hero {
    background: radial-gradient(circle at top right, #1F8FFF 0%, #0D0D0D 100%);
    padding: 100px 0 120px;
    position: relative;
    overflow: hidden;
    color: white;
    text-align: center;
}

.leaderboard-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://www.transparenttextures.com/patterns/carbon-fibre.png');
    opacity: 0.1;
    z-index: 1;
}

.leaderboard-bg-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.hero-title {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 20px;
    background: linear-gradient(to bottom, #fff 40%, #ccc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.hero-subtitle {
    font-size: 1.25rem;
    color: #ffffff !important;
    font-weight: 400;
    max-width: 700px;
    margin: 0 auto 50px;
    opacity: 1 !important;
}

/* Podium Styles */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 30px;
    margin-top: 50px;
    padding-bottom: 50px;
}

.podium-item {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 35px 25px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Ensure items flow from top */
}

.podium-item:hover {
    transform: translateY(-15px);
    box-shadow: 0 20px 50px rgba(31, 143, 255, 0.3);
}

.podium-rank {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -55px auto 20px;
    font-weight: 800;
    font-size: 1.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.rank-1 {
    grid-area: rank1;
    min-height: 420px;
    /* Use min-height to prevent clipping */
    order: 2;
    z-index: 2;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.2);
}

.rank-2 {
    grid-area: rank2;
    min-height: 340px;
    order: 1;
    border: 1px solid rgba(192, 192, 192, 0.3);
    box-shadow: 0 0 30px rgba(192, 192, 192, 0.1);
}

.rank-3 {
    grid-area: rank3;
    min-height: 310px;
    order: 3;
    border: 1px solid rgba(205, 127, 50, 0.3);
    box-shadow: 0 0 30px rgba(205, 127, 50, 0.1);
}

.rank-1 .podium-rank {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #333;
}

.rank-2 .podium-rank {
    background: linear-gradient(135deg, #E0E0E0, #B0B0B0);
    color: #333;
}

.rank-3 .podium-rank {
    background: linear-gradient(135deg, #CD7F32, #8B4513);
    color: white;
}

.student-img-container {
    width: 110px;
    height: 110px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border-radius: 50%;
    margin: 0 auto 18px;
    overflow: hidden;
    border: 3px solid var(--glass-border);
    position: relative;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.rank-1 .student-img-container {
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3), inset 0 0 15px rgba(255, 215, 0, 0.2);
}

.rank-2 .student-img-container {
    border-color: #C0C0C0;
    box-shadow: 0 0 15px rgba(192, 192, 192, 0.2);
}

.rank-3 .student-img-container {
    border-color: #CD7F32;
    box-shadow: 0 0 15px rgba(205, 127, 50, 0.2);
}

.student-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rank-1 .student-name,
.rank-2 .student-name,
.rank-3 .student-name {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 12px;
    /* Increased margin to prevent overlap */
    width: 100%;
    color: white;
    /* Force white to override blue from style.css */
    overflow: visible;
    /* Allow natural wrap if needed or height */
    white-space: normal;
    line-height: 1.2;
    z-index: 10;
    position: relative;
}

.rank-1 .student-dept,
.rank-2 .student-dept,
.rank-3 .student-dept {
    font-size: 0.85rem;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px 18px;
    border-radius: 50px;
    margin: 0 auto 20px;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    letter-spacing: 0.5px;
    position: relative;
    z-index: 5;
}

.rank-1 .student-score,
.rank-2 .student-score,
.rank-3 .student-score {
    font-size: 2.2rem !important;
    font-weight: 950 !important;
    background: linear-gradient(to bottom, #fff 30%, #1F8FFF 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    display: flex !important;
    align-items: baseline !important;
    justify-content: center !important;
    gap: 5px !important;
    padding: 0 !important;
    /* Reset padding from style.css */
    margin: 0 !important;
    animation: none !important;
    /* Force reset pulse from style.css */
    border-radius: 0;
    box-shadow: none !important;
}

.xp-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1F8FFF;
    -webkit-text-fill-color: #1F8FFF;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.xp-symbol {
    font-size: 0.8rem;
    font-weight: 800;
    color: #1F8FFF;
    margin-left: 4px;
    opacity: 0.8;
}

/* List Styles (4-10) - Enhanced for Desktop & Mobile Stability */
.leaderboard-list-section {
    padding: 80px 0;
    background: #F8FAFD;
}

.leaderboard-table-container {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    margin-top: -80px;
    position: relative;
    z-index: 10;
}

.header-row,
.ranking-card {
    display: grid;
    grid-template-columns: 80px 80px 1fr 140px;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #eee;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
}

.header-row {
    font-weight: 700;
    font-size: 0.95rem;
    padding: 15px 30px;
}

.ranking-card {
    background: white;
}

.ranking-card:last-child {
    border-bottom: none;
}

.ranking-card:hover {
    background: #f9f9f9;
    transform: translateX(10px);
}

.row-rank,
.card-rank {
    font-weight: 800;
    font-size: 1.2rem;
    color: #999;
}

.card-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f0f0f0;
}

.header-info {
    grid-column: 2 / 4;
}

.card-info {
    min-width: 0;
    padding-right: 20px;
}

.card-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 2px;
}

.card-dept {
    color: #666;
    font-size: 0.9rem;
}

.card-score {
    font-weight: 800;
    font-size: 1.3rem;
    color: #1F8FFF;
    text-align: right;
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 4px;
}

.card-score .xp-symbol {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Dark Mode Integration */
body.dark-mode .leaderboard-list-section {
    background: #1a1a1a;
}

body.dark-mode .leaderboard-table-container {
    background: #2d2d2d;
    border: 1px solid #404040;
    color: white;
}

body.dark-mode .leaderboard-row {
    border-color: #404040;
}

body.dark-mode .leaderboard-row:hover {
    background: #353535;
}

body.dark-mode .row-dept {
    color: #bbb;
}

/* Responsive Staggered Grid Layout for Mobile */
@media (max-width: 991px) {
    .podium-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "rank1 rank1"
            "rank2 rank3";
        gap: 15px;
        padding: 40px 10px 20px;
        margin-top: 0;
        align-items: stretch;
    }

    .podium-item {
        width: auto;
        min-width: 0;
        padding: 20px 10px;
        border-radius: 20px;
    }

    .rank-1 {
        grid-area: rank1;
        height: auto !important;
        margin-bottom: 5px;
        background: rgba(255, 255, 255, 0.2);
        border-width: 2px;
        position: relative;
    }

    /* Winner's Halo Effect */
    .rank-1::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 150px;
        height: 150px;
        background: radial-gradient(circle, rgba(255, 215, 0, 0.2) 0%, transparent 70%);
        z-index: -1;
        pointer-events: none;
    }

    .rank-2 {
        grid-area: rank2;
        height: auto !important;
    }

    .rank-3 {
        grid-area: rank3;
        height: auto !important;
    }

    .student-img-container {
        width: 70px;
        height: 70px;
        aspect-ratio: 1 / 1;
        flex-shrink: 0;
        margin-bottom: 12px;
    }

    .rank-1 .student-img-container {
        width: 90px;
        height: 90px;
    }

    .student-name {
        font-size: 1rem;
        margin-bottom: 8px;
        /* Increased for mobile stability */
    }

    .rank-1 .student-name {
        font-size: 1.25rem;
    }

    .student-dept {
        font-size: 0.7rem;
        padding: 4px 12px;
        margin-bottom: 12px;
    }

    .student-score {
        font-size: 1.2rem;
    }

    .rank-1 .student-score {
        font-size: 1.6rem;
    }

    .podium-rank {
        width: 35px;
        height: 35px;
        font-size: 1rem;
        margin: -38px auto 10px;
    }
}

@media (max-width: 576px) {
    .leaderboard-table-container {
        background: transparent;
        box-shadow: none;
        margin-top: -60px;
        padding: 0 15px;
    }

    /* Hide table header on mobile */
    .leaderboard-table-container>.leaderboard-row:first-child {
        display: none !important;
    }

    .ranking-card {
        display: flex;
        /* Flexbox for bulletproof mobile stability */
        flex-direction: row;
        align-items: center;
        gap: 15px;
        background: white;
        margin-bottom: 15px;
        border-radius: 20px;
        padding: 15px 20px;
        border: 1px solid rgba(0, 0, 0, 0.05);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.05);
        width: 100%;
    }

    body.dark-mode .ranking-card {
        background: #2d2d2d;
        border-color: #404040;
    }

    .card-rank {
        width: 35px;
        height: 35px;
        background: #f0f7ff;
        color: #1F8FFF;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    body.dark-mode .card-rank {
        background: #353535;
    }

    .card-avatar {
        width: 45px;
        height: 45px;
        border-radius: 12px;
        flex-shrink: 0;
    }

    .card-info {
        flex: 1;
        /* Takes up all remaining space */
        min-width: 0;
        /* Prevents text from pushing the score out */
        padding-right: 5px;
    }

    .card-name {
        font-size: 0.95rem;
        font-weight: 800;
        margin-bottom: 2px;
        white-space: normal;
        /* Allow full name to wrap */
        line-height: 1.3;
        display: block;
    }

    .card-dept {
        font-size: 0.75rem;
        opacity: 0.7;
        white-space: normal;
        /* Allow full department to wrap */
        line-height: 1.2;
        display: block;
    }

    .card-score {
        font-size: 1.15rem;
        font-weight: 900;
        flex-shrink: 0;
        /* Prevents score from getting squashed */
        min-width: 75px;
    }

    .xp-symbol {
        font-size: 0.7rem;
    }
}