/* ==========================================================================
   KhoTruyen Member Leaderboard Stylesheet (v3.4.18)
   Matching KhoTruyen Apple UI Aesthetics (Light & Dark Compatible)
   ========================================================================== */

/* 1. Page Header & Hero */
.user-lb-hero-card {
    background: var(--c-canvas);
    border: 1px solid var(--c-hairline);
    border-radius: 20px;
    padding: 24px 28px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}

.user-lb-hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(180deg, #f59e0b 0%, #ff7a00 100%);
    border-radius: 20px 0 0 20px;
}

.user-lb-hero-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

/* Search input group */
.user-lb-search-wrap {
    display: flex;
    align-items: center;
    background: var(--c-chip);
    border: 1px solid var(--c-hairline);
    border-radius: 9999px;
    padding: 3px 4px 3px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    max-width: 320px;
    width: 100%;
}

.user-lb-search-wrap:focus-within {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px var(--c-primary-tint);
}

.user-lb-search-input {
    border: none;
    background: transparent;
    color: var(--c-ink);
    font-size: 13.5px;
    outline: none;
    width: 100%;
}

.user-lb-search-input::placeholder {
    color: var(--c-ink-48);
}

.user-lb-search-btn {
    background: var(--c-primary);
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.user-lb-search-btn:hover {
    opacity: 0.9;
}

/* 2. Podium Top 3 Cards */
.user-podium-card {
    background: var(--c-canvas);
    border: 1px solid var(--c-hairline);
    border-radius: 20px;
    padding: 28px 16px 20px;
    text-align: center;
    position: relative;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.user-podium-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

/* Rank Specific Overrides */
.user-podium-card.rank-1-card {
    border: 2px solid #f59e0b !important;
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.04) 0%, var(--c-canvas) 100%);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.15);
    transform: scale(1.04);
    z-index: 2;
}

.user-podium-card.rank-1-card:hover {
    transform: scale(1.06) translateY(-4px);
    box-shadow: 0 14px 36px rgba(245, 158, 11, 0.22);
}

.user-podium-card.rank-2-card {
    border-color: #94a3b8;
}

.user-podium-card.rank-3-card {
    border-color: #d97706;
}

/* Floating Rank Badges */
.podium-rank-badge {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 9999px;
    padding: 4px 14px;
    font-size: 13px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

.rank-1-badge {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #000000;
    padding: 5px 16px;
    font-size: 14px;
}

.rank-2-badge {
    background: linear-gradient(135deg, #cbd5e1, #64748b);
    color: #ffffff;
}

.rank-3-badge {
    background: linear-gradient(135deg, #f59e0b, #b45309);
    color: #ffffff;
}

/* Avatar Wrappers */
.podium-avatar-wrap {
    margin: 12px 0 14px;
    position: relative;
    display: inline-block;
}

.podium-avatar-img {
    border-radius: 50% !important;
    object-fit: cover !important;
    aspect-ratio: 1 / 1 !important;
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.rank-1-card .podium-avatar-img {
    width: 90px !important;
    height: 90px !important;
    min-width: 90px !important;
    min-height: 90px !important;
    aspect-ratio: 1 / 1 !important;
    border: 3px solid #f59e0b;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.35);
}

.rank-2-card .podium-avatar-img {
    width: 76px !important;
    height: 76px !important;
    min-width: 76px !important;
    min-height: 76px !important;
    aspect-ratio: 1 / 1 !important;
    border: 3px solid #94a3b8;
}

.rank-3-card .podium-avatar-img {
    width: 76px !important;
    height: 76px !important;
    min-width: 76px !important;
    min-height: 76px !important;
    aspect-ratio: 1 / 1 !important;
    border: 3px solid #d97706;
}

.podium-user-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--c-ink-heading);
    margin-bottom: 6px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.podium-user-name a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.podium-user-name a:hover {
    color: var(--c-primary);
}

.podium-realm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.podium-xp-score {
    font-size: 16px;
    font-weight: 800;
    color: #f59e0b;
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    margin-top: auto;
}

/* 3. Leaderboard Table */
.user-lb-table-card {
    background: var(--c-canvas);
    border: 1px solid var(--c-hairline);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.user-lb-table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.user-lb-table thead th {
    background: var(--c-chip);
    color: var(--c-ink-48);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 14px 16px;
    border-bottom: 1px solid var(--c-divider);
    white-space: nowrap;
}

.user-lb-table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--c-divider);
    font-size: 13.5px;
    color: var(--c-ink);
    background: transparent;
    transition: background-color 0.15s ease;
}

.user-lb-table tbody tr:last-child td {
    border-bottom: none;
}

.user-lb-table tbody tr:hover td {
    background: var(--c-chip);
}

/* Rank Number styling */
.lb-rank-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 800;
    background: var(--c-chip);
    color: var(--c-ink-48);
    border: 1px solid var(--c-hairline);
}

.lb-rank-pill.rank-1 {
    background: linear-gradient(135deg, #fbbf24, #d97706);
    color: #000;
    border-color: #f59e0b;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.lb-rank-pill.rank-2 {
    background: linear-gradient(135deg, #cbd5e1, #64748b);
    color: #fff;
    border-color: #94a3b8;
}

.lb-rank-pill.rank-3 {
    background: linear-gradient(135deg, #f59e0b, #b45309);
    color: #fff;
    border-color: #d97706;
}

/* Member Column */
.lb-member-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.lb-member-avatar {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0;
    border: 1px solid var(--c-hairline);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.lb-member-name {
    font-weight: 700;
    color: var(--c-ink-heading);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    transition: color 0.15s ease;
}

.lb-member-name:hover {
    color: var(--c-primary);
}

/* Level Badge */
.lb-level-badge {
    background: var(--c-chip);
    color: var(--c-ink);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 9999px;
    border: 1px solid var(--c-hairline);
    white-space: nowrap;
}

/* Realm Badge */
.lb-realm-badge {
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Interactions */
.lb-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
}

/* Total Points */
.lb-points-val {
    font-size: 14px;
    font-weight: 800;
    color: #f59e0b;
    white-space: nowrap;
}

/* 4. Dark Mode Styles */
.dark-mode .user-lb-hero-card,
[data-bs-theme="dark"] .user-lb-hero-card,
.dark-mode .user-podium-card,
[data-bs-theme="dark"] .user-podium-card,
.dark-mode .user-lb-table-card,
[data-bs-theme="dark"] .user-lb-table-card {
    background: var(--c-canvas);
    border-color: var(--c-hairline);
}

.dark-mode .user-podium-card.rank-1-card,
[data-bs-theme="dark"] .user-podium-card.rank-1-card {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, var(--c-canvas) 100%);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
}

.dark-mode .user-lb-table thead th,
[data-bs-theme="dark"] .user-lb-table thead th {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--c-divider);
}

.dark-mode .user-lb-table tbody td,
[data-bs-theme="dark"] .user-lb-table tbody td {
    border-color: var(--c-divider);
}

.dark-mode .user-lb-table tbody tr:hover td,
[data-bs-theme="dark"] .user-lb-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* 5. Responsive Styles */
@media (max-width: 991.98px) {
    .user-podium-wrap {
        margin-bottom: 24px;
    }
}

@media (max-width: 767.98px) {
    .user-lb-hero-card {
        padding: 18px 16px;
    }
    .user-lb-search-wrap {
        max-width: 100%;
    }
    
    /* Podium mobile */
    .user-podium-card {
        padding: 22px 10px 14px;
    }
    .user-podium-card.rank-1-card {
        transform: none !important;
    }
    .rank-1-card .podium-avatar-img {
        width: 68px !important;
        height: 68px !important;
        min-width: 68px !important;
        min-height: 68px !important;
        aspect-ratio: 1 / 1 !important;
    }
    .rank-2-card .podium-avatar-img,
    .rank-3-card .podium-avatar-img {
        width: 58px !important;
        height: 58px !important;
        min-width: 58px !important;
        min-height: 58px !important;
        aspect-ratio: 1 / 1 !important;
    }
    .podium-user-name {
        font-size: 13px;
    }
    .podium-realm-badge {
        font-size: 10px;
        padding: 2px 8px;
    }
    .podium-xp-score {
        font-size: 13px;
    }
    .podium-rank-badge {
        font-size: 11px;
        padding: 2px 10px;
        top: -12px;
    }

    /* Table mobile */
    .user-lb-table thead {
        display: none;
    }
    .user-lb-table tbody tr {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
        border-bottom: 1px solid var(--c-divider);
    }
    .user-lb-table tbody td {
        padding: 0;
        border: none;
    }
    .user-lb-table tbody td.col-rank {
        width: 36px;
        flex-shrink: 0;
    }
    .user-lb-table tbody td.col-member {
        flex: 1;
        min-width: 0;
        padding: 0 10px;
    }
    .user-lb-table tbody td.col-points {
        flex-shrink: 0;
        text-align: right;
    }
}
