/* Badges System Styles - Premium & Vibrant */
/* V2: AI Leaderboard Performance Badges */

/* Override profile card overflow so tooltips aren't clipped */
.profile-main-card {
    overflow: visible !important;
}
.profile-main-card .profile-cover {
    overflow: hidden;
    border-radius: 20px 20px 0 0;
}

#userBadgesContainer {
    padding: 20px 32px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.badge-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.badge-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badges-loading, .badges-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
    padding: 20px;
    font-style: italic;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: badgeSpin 1s linear infinite;
}

@keyframes badgeSpin {
    to { transform: rotate(360deg); }
}

.badge-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: flex-start;
}

.badge-item {
    position: relative;
    width: 110px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.badge-item.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.badge-icon-wrapper {
    width: 110px;
    height: 130px;
    border-radius: 22px;
    background: var(--badge-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45),
                inset 0 2px 8px rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    position: relative;
    overflow: hidden;
    z-index: 1;
    flex-shrink: 0;
    padding: 12px 8px 8px;
    gap: 8px;
}

.badge-icon-wrapper .badge-icon {
    width: 65%;
    height: auto;
    object-fit: contain;
    z-index: 2;
    flex: 0 0 auto;
}

/* Branded strip at the bottom of the badge tile */
.badge-brand-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    margin-bottom: 8px;
    padding: 6px 10px;
    z-index: 3;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    width: fit-content;
    max-width: 95%;
    justify-content: center;
    opacity: 0.9;
    transition: all 0.3s ease;
}

.badge-item:hover .badge-brand-strip {
    opacity: 1;
    background: rgba(0, 0, 0, 0.65);
    border-color: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.brand-strip-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.brand-strip-name {
    font-size: 9px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.03em;
}

.brand-strip-tagline {
    font-size: 5px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
    opacity: 0.8;
}

.badge-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    line-height: 1.2;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150%;
    height: 150%;
    background: radial-gradient(circle, var(--badge-color) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    opacity: 0.1;
    filter: blur(20px);
    pointer-events: none;
    z-index: 0;
    transition: opacity 0.4s ease;
}

.badge-shimmer {
    position: absolute;
    top: -150%;
    left: -150%;
    width: 400%;
    height: 400%;
    background: linear-gradient(
        45deg,
        transparent 0%,
        rgba(255, 255, 255, 0) 45%,
        rgba(255, 255, 255, 0.4) 50%,
        rgba(255, 255, 255, 0) 55%,
        transparent 100%
    );
    transform: rotate(25deg);
    transition: all 0.8s ease;
    pointer-events: none;
}

.badge-item:hover {
    transform: translateY(-8px) scale(1.05);
    z-index: 100;
}

.badge-item:hover .badge-shimmer {
    top: -100%;
    left: -100%;
}

.badge-item:hover .badge-glow {
    opacity: 0.4;
}

.badge-item:hover .badge-icon-wrapper {
    box-shadow: 0 15px 35px var(--badge-color);
    border-color: rgba(255, 255, 255, 0.5);
}

.badge-item:hover .badge-label {
    color: rgba(255, 255, 255, 0.9);
}

/* Tier Specifics */
.badge-tier-gold .badge-icon-wrapper {
    border: 1.5px solid rgba(255, 215, 0, 0.4);
}

.badge-tier-silver .badge-icon-wrapper {
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

.badge-tier-bronze .badge-icon-wrapper {
    border: 1.5px solid rgba(205, 127, 50, 0.4);
}

/* Gold shimmer auto-animation */
.badge-tier-gold .badge-shimmer {
    animation: goldShimmer 3s ease-in-out infinite;
}

@keyframes goldShimmer {
    0%, 100% { top: -150%; left: -150%; }
    50% { top: -80%; left: -80%; }
}

/* ════════════════════════════════════════════
   TOOLTIP — Desktop: centered below badge
   ════════════════════════════════════════════ */
.badge-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    width: 220px;
    background: rgba(10, 10, 18, 0.98);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 14px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 1000;
}

.badge-item:hover .badge-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
}

.badge-tooltip strong {
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
}

.badge-tier-tag {
    font-size: 0.6rem;
    font-weight: 900;
    text-transform: uppercase;
    color: var(--badge-color);
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
}

.badge-tooltip p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0;
}

/* Desktop arrow — centered, points upward */
.badge-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 7px;
    border-style: solid;
    border-color: transparent transparent rgba(10, 10, 18, 0.98) transparent;
}

/* ════════════════════════════════════════════
   MOBILE (≤640px): Directional tooltips
   Left badges → tooltip shifts RIGHT
   Right badges → tooltip shifts LEFT
   ════════════════════════════════════════════ */
@media (max-width: 640px) {
    #userBadgesContainer {
        padding: 16px 20px 20px;
    }

    .badge-grid {
        gap: 12px;
        justify-content: center;
    }

    .badge-item {
        width: 95px !important;
    }

    .badge-icon-wrapper {
        width: 95px !important;
        height: 112px !important;
        border-radius: 18px;
        padding: 8px 5px 6px;
        justify-content: center;
        gap: 6px;
    }

    .badge-icon-wrapper .badge-icon {
        width: 55%;
        max-height: 62%;
    }

    .badge-brand-strip {
        padding: 5px 8px;
        gap: 5px;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        width: fit-content;
        max-width: 95%;
        border-radius: 16px;
        margin-bottom: 6px;
        justify-content: center;
    }

    .brand-strip-icon {
        width: 14px;
        height: 14px;
        border-radius: 50%;
    }

    .brand-strip-name {
        font-size: 8px;
        margin-right: 0;
    }

    .brand-strip-tagline {
        font-size: 4.5px;
    }

    .badge-label {
        font-size: 0.6rem;
    }

    .badge-tooltip {
        width: 190px;
        padding: 12px;
    }

    .badge-tooltip strong {
        font-size: 0.82rem;
    }

    .badge-tooltip p {
        font-size: 0.75rem;
    }

    /* LEFT-SIDE BADGES: tooltip shifted to the right */
    .badge-item.tooltip-right .badge-tooltip {
        left: 0;
        transform: translateY(-6px);
    }
    .badge-item.tooltip-right:hover .badge-tooltip {
        transform: translateY(0);
    }
    .badge-item.tooltip-right .badge-tooltip::after {
        left: 28px;
        transform: none;
    }

    /* RIGHT-SIDE BADGES: tooltip shifted to the left */
    .badge-item.tooltip-left .badge-tooltip {
        left: auto;
        right: 0;
        transform: translateY(-6px);
    }
    .badge-item.tooltip-left:hover .badge-tooltip {
        transform: translateY(0);
    }
    .badge-item.tooltip-left .badge-tooltip::after {
        left: auto;
        right: 21px;
        transform: none;
    }
}

@media (max-width: 380px) {
    .badge-grid {
        gap: 8px;
    }

    .badge-item {
        width: 82px !important;
    }

    .badge-icon-wrapper {
        width: 82px !important;
        height: 98px !important;
        border-radius: 16px;
        padding: 6px 4px 5px;
        justify-content: center;
        gap: 4px;
    }

    .badge-icon-wrapper .badge-icon {
        width: 52%;
    }

    .badge-brand-strip {
        padding: 4px 6px;
        gap: 4px;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
        width: fit-content;
        max-width: 95%;
        border-radius: 12px;
        margin-bottom: 5px;
        justify-content: center;
    }

    .brand-strip-icon {
        width: 12px;
        height: 12px;
        border-radius: 50%;
    }

    .brand-strip-name {
        font-size: 7px;
    }

    .brand-strip-tagline {
        font-size: 4px;
    }

    .badge-label {
        font-size: 0.55rem;
    }

    .badge-tooltip {
        width: 170px;
    }
}

/* Badge Modal Styles */
.badge-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.badge-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.badge-modal-content {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    color: white;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 12px;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(255, 65, 108, 0.4);
    border: 2px solid #13131a;
}

.badge-modal-overlay.active .badge-modal-content {
    transform: scale(1) translateY(0);
}

.badge-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.badge-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.badge-modal-logo {
    width: 48px;
    height: 48px;
    margin-bottom: 24px;
    opacity: 0.8;
}

.badge-modal-icon-container {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--badge-gradient);
    box-shadow: 0 0 40px var(--badge-color), inset 0 0 20px rgba(255,255,255,0.3);
    animation: modalPulse 2s infinite alternate;
}

@keyframes modalPulse {
    0% { box-shadow: 0 0 30px var(--badge-color), inset 0 0 15px rgba(255,255,255,0.3); transform: scale(0.98); }
    100% { box-shadow: 0 0 60px var(--badge-color), inset 0 0 30px rgba(255,255,255,0.5); transform: scale(1.02); }
}

.badge-modal-icon {
    width: 120px;
    height: 120px;
    object-fit: contain;
    z-index: 2;
    animation: floatingIcon 3s ease-in-out infinite;
}

@keyframes floatingIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.badge-modal-sparkles {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(white 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.3;
    animation: sparkleMove 10s linear infinite;
    pointer-events: none;
    z-index: 1;
    border-radius: 50%;
}

@keyframes sparkleMove {
    from { background-position: 0 0; }
    to { background-position: 100px 100px; }
}

.badge-modal-title {
    font-size: 28px;
    font-weight: 800;
    color: white;
    margin: 0 0 12px;
    letter-spacing: -0.5px;
}

.badge-modal-desc {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin: 0 0 32px;
}

.badge-modal-share-title {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.badge-modal-share-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.badge-share-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
    text-decoration: none;
}

.badge-share-btn:hover {
    background: var(--badge-color);
    border-color: var(--badge-color);
    transform: translateY(-3px);
}
