/* ============================================================
   Gamified Leaderboard + Honor Board (Arabic RTL)
   ============================================================ */

:root {
    --lb-diamond-1: #67e8f9;
    --lb-diamond-2: #22d3ee;
    --lb-diamond-3: #0891b2;
    --lb-gold-1: #fde68a;
    --lb-gold-2: #f59e0b;
    --lb-gold-3: #b45309;
    --lb-silver-1: #f1f5f9;
    --lb-silver-2: #cbd5e1;
    --lb-silver-3: #64748b;
    --lb-card-radius: 18px;
}

/* ---------------------------------------------------- page shell ---- */

.lb-page {
    flex-shrink: 0;
    padding-top: 110px;
    padding-bottom: 60px;
    min-height: 75vh;
}

.lb-page .page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    margin-bottom: 18px;
}

.lb-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    background: var(--card-bg, #fff);
    border-radius: var(--lb-card-radius);
    padding: 14px 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
    margin-bottom: 20px;
}

.lb-toolbar .lb-toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.lb-toolbar label {
    font-weight: 700;
    font-size: .9rem;
    margin: 0;
    white-space: nowrap;
}

.lb-toolbar .form-select,
.lb-toolbar .form-control {
    min-width: 150px;
    border-radius: 12px;
}

.lb-spacer {
    flex: 1;
}

/* --------------------------------------------------------- badges ---- */

.lb-tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 4px 12px;
    font-weight: 800;
    font-size: .78rem;
    line-height: 1.4;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.lb-tier-badge::after {
    content: "";
    position: absolute;
    top: 0;
    left: -80%;
    width: 60%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .75), transparent);
    transform: skewX(-20deg);
    animation: lbShine 2.8s ease-in-out infinite;
}

@keyframes lbShine {
    0% { left: -80%; }
    55%, 100% { left: 130%; }
}

.lb-tier-diamond {
    background: linear-gradient(135deg, var(--lb-diamond-1), var(--lb-diamond-2) 55%, var(--lb-diamond-3));
    color: #062a33;
    box-shadow: 0 2px 10px rgba(34, 211, 238, .45);
}

.lb-tier-gold {
    background: linear-gradient(135deg, var(--lb-gold-1), var(--lb-gold-2) 55%, var(--lb-gold-3));
    color: #3b2502;
    box-shadow: 0 2px 10px rgba(245, 158, 11, .45);
}

.lb-tier-silver {
    background: linear-gradient(135deg, var(--lb-silver-1), var(--lb-silver-2) 55%, var(--lb-silver-3));
    color: #1e293b;
    box-shadow: 0 2px 10px rgba(148, 163, 184, .4);
}

.lb-tier-none {
    background: #eef2f7;
    color: #94a3b8;
}

html[data-theme="dark"] .lb-tier-none {
    background: #1f2733;
    color: #64748b;
}

/* ----------------------------------------------------- my stats card -- */

.lb-me-card {
    position: sticky;
    top: 86px;
    z-index: 30;
    border: 2px solid transparent;
    border-radius: var(--lb-card-radius);
    background: linear-gradient(var(--card-bg, #fff), var(--card-bg, #fff)) padding-box,
                linear-gradient(120deg, var(--lb-diamond-2), var(--lb-gold-2), var(--lb-silver-2)) border-box;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .10);
    padding: 16px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.lb-me-card .lb-avatar {
    width: 54px;
    height: 54px;
    font-size: 1.4rem;
}

.lb-me-card .lb-me-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 160px;
}

.lb-me-card .lb-me-name {
    font-weight: 800;
    font-size: 1.05rem;
}

.lb-me-card .lb-me-rank {
    font-size: .85rem;
    color: var(--text-muted, #6b7280);
}

.lb-me-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-inline-start: auto;
}

.lb-me-stat {
    background: var(--card-bg-alt, rgba(0, 0, 0, .04));
    border-radius: 12px;
    padding: 8px 14px;
    text-align: center;
    min-width: 92px;
}

.lb-me-stat .lb-me-stat-value {
    font-weight: 900;
    font-size: 1.15rem;
    line-height: 1.2;
}

.lb-me-stat .lb-me-stat-label {
    font-size: .72rem;
    color: var(--text-muted, #6b7280);
}

.lb-up {
    color: #16a34a;
    font-weight: 800;
}

.lb-down {
    color: #dc2626;
    font-weight: 800;
}

/* ---------------------------------------------------------- podium ---- */

.lb-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 14px;
    margin: 26px 0 30px;
    flex-wrap: wrap;
}

.lb-podium-card {
    position: relative;
    width: 210px;
    border-radius: 20px;
    padding: 22px 14px 18px;
    text-align: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .12);
    overflow: hidden;
    transition: transform .25s ease;
}

.lb-podium-card:hover {
    transform: translateY(-6px);
}

.lb-podium-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(160deg, rgba(255, 255, 255, .35), transparent 45%);
    pointer-events: none;
}

.lb-podium-card.lb-podium-1 {
    background: linear-gradient(150deg, var(--lb-gold-1), var(--lb-gold-2) 60%, var(--lb-gold-3));
    color: #3b2502;
    width: 240px;
    padding-top: 30px;
    animation: lbGlowGold 2.4s ease-in-out infinite;
}

.lb-podium-2 {
    background: linear-gradient(150deg, var(--lb-silver-1), var(--lb-silver-2) 60%, var(--lb-silver-3));
    color: #1e293b;
}

.lb-podium-3 {
    background: linear-gradient(150deg, #fed7aa, #f97316 60%, #9a3412);
    color: #431407;
}

@keyframes lbGlowGold {
    0%, 100% { box-shadow: 0 12px 30px rgba(245, 158, 11, .35); }
    50% { box-shadow: 0 12px 42px rgba(245, 158, 11, .65); }
}

.lb-podium-card .lb-podium-pos {
    font-size: 1.6rem;
    font-weight: 900;
    line-height: 1;
}

.lb-podium-card .lb-avatar {
    width: 66px;
    height: 66px;
    font-size: 1.7rem;
    margin: 8px auto;
    border: 3px solid rgba(255, 255, 255, .8);
}

.lb-podium-card .lb-podium-name {
    font-weight: 800;
    font-size: .98rem;
    word-break: break-word;
}

.lb-podium-card .lb-podium-score {
    font-weight: 900;
    font-size: 1.2rem;
    margin-top: 4px;
}

.lb-podium-card .lb-tier-badge {
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, .55);
}

/* -------------------------------------------------------- avatars ----- */

.lb-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    flex-shrink: 0;
    text-transform: uppercase;
}

/* ------------------------------------------------------ board table ---- */

.lb-board {
    border-radius: var(--lb-card-radius);
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .07);
    background: var(--card-bg, #fff);
}

.lb-table {
    margin: 0;
    vertical-align: middle;
}

.lb-table thead th {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    font-weight: 700;
    border: 0;
    padding: 14px 12px;
    white-space: nowrap;
    font-size: .88rem;
}

.lb-table tbody td {
    padding: 11px 12px;
    border-color: rgba(0, 0, 0, .06);
    vertical-align: middle;
}

.lb-table tbody tr {
    transition: background .15s ease;
}

.lb-table tbody tr:hover {
    background: rgba(99, 102, 241, .07);
}

.lb-table tbody tr.lb-row-me {
    background: rgba(245, 158, 11, .14);
    font-weight: 700;
}

.lb-table tbody tr.lb-row-me:hover {
    background: rgba(245, 158, 11, .22);
}

.lb-table tbody tr.lb-row-sep td {
    background: transparent;
    border-top: 2px dashed rgba(99, 102, 241, .35);
    padding-top: 10px;
    padding-bottom: 10px;
}

.lb-table tbody tr.lb-row-sep:hover {
    background: transparent;
}

.lb-rank-cell {
    font-weight: 900;
    font-size: 1rem;
    width: 56px;
    text-align: center;
}

.lb-rank-1 { color: #d97706; }
.lb-rank-2 { color: #64748b; }
.lb-rank-3 { color: #c2410c; }

.lb-student-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 170px;
}

.lb-score-cell {
    font-weight: 900;
    font-size: 1.02rem;
    color: #4f46e5;
    white-space: nowrap;
}

.lb-sub-pct {
    font-size: .78rem;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
}

.lb-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lb-chip {
    font-size: .72rem;
    border-radius: 8px;
    padding: 3px 8px;
    background: var(--card-bg-alt, rgba(0, 0, 0, .05));
    color: var(--text-muted, #4b5563);
    white-space: nowrap;
}

.lb-chip b {
    color: inherit;
}

/* --------------------------------------------------------- tabs ------- */

.lb-tabs .nav-link {
    border-radius: 12px 12px 0 0;
    font-weight: 700;
    color: var(--text-muted, #6b7280);
}

.lb-tabs .nav-link.active {
    color: #4f46e5;
}

/* --------------------------------------------- honor board (public) ---- */

.hb-hero {
    text-align: center;
    padding: 30px 16px 6px;
}

.hb-hero h1 {
    font-weight: 900;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    background: linear-gradient(120deg, #f59e0b, #fbbf24 35%, #e5e7eb 60%, #22d3ee);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hb-hero p {
    color: var(--text-muted, #6b7280);
    margin-bottom: 0;
}

.hb-grade-section {
    margin-top: 34px;
}

.hb-grade-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    font-size: 1.25rem;
    margin-bottom: 16px;
}

.hb-grade-title::after {
    content: "";
    flex: 1;
    height: 2px;
    background: linear-gradient(to left, rgba(99, 102, 241, .5), transparent);
}

.hb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: 16px;
}

.hb-card {
    position: relative;
    border-radius: 20px;
    padding: 20px 14px 16px;
    text-align: center;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .12);
    transition: transform .25s ease;
}

.hb-card:hover {
    transform: translateY(-6px) scale(1.02);
}

.hb-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: -90%;
    width: 55%;
    height: 100%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
    transform: skewX(-20deg);
    animation: lbShine 3.4s ease-in-out infinite;
}

.hb-card-diamond {
    background: linear-gradient(155deg, #ecfeff, var(--lb-diamond-1) 45%, var(--lb-diamond-3));
    color: #062a33;
}

.hb-card-gold {
    background: linear-gradient(155deg, #fffbeb, var(--lb-gold-1) 45%, var(--lb-gold-3));
    color: #3b2502;
}

.hb-card-silver {
    background: linear-gradient(155deg, #f8fafc, var(--lb-silver-1) 45%, var(--lb-silver-3));
    color: #1e293b;
}

.hb-card-none {
    background: linear-gradient(155deg, #f9fafb, #e5e7eb 60%, #cbd5e1);
    color: #334155;
}

.hb-card .lb-avatar {
    width: 68px;
    height: 68px;
    font-size: 1.8rem;
    margin: 0 auto 8px;
    border: 3px solid rgba(255, 255, 255, .85);
}

.hb-card .hb-name {
    font-weight: 900;
    font-size: 1.02rem;
    word-break: break-word;
}

.hb-card .hb-score {
    font-weight: 900;
    font-size: 1.35rem;
    margin-top: 6px;
}

.hb-card .hb-rank {
    position: absolute;
    top: 10px;
    inset-inline-end: 12px;
    font-weight: 900;
    font-size: 1rem;
    opacity: .75;
}

.hb-card .lb-tier-badge {
    margin-top: 8px;
    background: rgba(255, 255, 255, .65);
    border: 1px solid rgba(255, 255, 255, .9);
}

/* --------------------------------------------------------- dark ------ */

html[data-theme="dark"] {
    --card-bg: #171b3a;
    --card-bg-alt: rgba(255, 255, 255, .07);
    --text-muted: #9aa3c0;
}

html[data-theme="dark"] .lb-table tbody td {
    border-color: rgba(255, 255, 255, .08);
}

html[data-theme="dark"] .lb-table thead th {
    background: linear-gradient(135deg, #312e81, #5b21b6);
}

html[data-theme="dark"] .lb-table tbody tr:hover {
    background: rgba(129, 140, 248, .14);
}

html[data-theme="dark"] .lb-table tbody tr.lb-row-me {
    background: rgba(245, 158, 11, .16);
}

html[data-theme="dark"] .lb-score-cell {
    color: #a5b4fc;
}

html[data-theme="dark"] .lb-tabs .nav-link.active {
    color: #a5b4fc;
}

html[data-theme="dark"] .lb-tier-diamond,
html[data-theme="dark"] .lb-tier-gold,
html[data-theme="dark"] .lb-tier-silver {
    color: #0f172a;
}

html[data-theme="dark"] .hb-card-none {
    background: linear-gradient(155deg, #1f2733, #2a3346 60%, #3b465e);
    color: #cbd5e1;
}

html[data-theme="dark"] .lb-toolbar {
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}

/* --------------------------------------------------------- misc ------- */

.lb-empty {
    text-align: center;
    padding: 46px 16px;
    color: var(--text-muted, #6b7280);
}

.lb-empty .material-symbols-outlined {
    font-size: 54px;
    opacity: .5;
}

@media (max-width: 768px) {
    .lb-me-card {
        top: 76px;
        padding: 12px;
    }

    .lb-me-stats {
        margin-inline-start: 0;
        width: 100%;
    }

    .lb-me-stat {
        flex: 1;
        min-width: 76px;
        padding: 6px 8px;
    }

    .lb-podium-card,
    .lb-podium-card.lb-podium-1 {
        width: 100%;
        max-width: 320px;
    }

    .lb-toolbar {
        padding: 10px;
    }

    .lb-toolbar .form-select {
        min-width: 120px;
    }

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