/* ========================================= */
/* GAMIFICATION MODALS & UI STYLES          */
/* Created: 2025-11-05                      */
/* ========================================= */

/* Ranking Modal Tabs */
.ranking-tabs {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    padding: 0 20px;
}

.ranking-tab {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.ranking-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.ranking-tab.active {
    background: rgba(66, 165, 245, 0.2);
    border-color: rgba(66, 165, 245, 0.5);
}

.ranking-tab .tab-icon {
    font-size: 18px;
}

.ranking-tab-content {
    display: none;
}

.ranking-tab-content.active {
    display: block;
}

/* Stats Container */
.stats-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Stats Tab needs padding to match leaderboard tab (which has ranking-coming-soon with padding) */
#statsTab {
    padding: 0;
}

.stats-header {
    text-align: center;
    margin-bottom: 30px;
}

.stats-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.stats-title {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-grid .stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
}

.stats-grid .stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.stats-grid .stat-card .stat-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.stats-grid .stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    margin: 8px 0;
}

.stats-grid .stat-card .stat-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.9;
}

.stats-grid .stat-card .stat-sublabel {
    font-size: 12px;
    opacity: 0.6;
}

.stats-grid .stat-card.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

.stat-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: rgba(66, 165, 245, 0.8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.stats-footer {
    text-align: center;
    margin-top: 20px;
}

.stats-tip {
    font-size: 14px;
    opacity: 0.7;
    font-style: italic;
}

/* No Stats / Error States */
.no-stats, .error-stats {
    text-align: center;
    padding: 60px 20px;
}

.no-stats-hint {
    font-size: 14px;
    opacity: 0.6;
    margin-top: 8px;
}

/* Celebration Modal (Duolingo-style) */
.celebration-modal {
    z-index: 10000;
    display: none;
}

.celebration-modal.active {
    display: flex !important;
}

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
}

.celebration-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #FFFFFF;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    color: #333;
}

.celebration-modal.active .celebration-content {
    animation: celebrationPopIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes celebrationPopIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Celebration Star */
.celebration-star {
    position: relative;
    margin: 20px auto 30px;
    /* 3D perspective for pirouette effect */
    perspective: 1000px;
}

.celebration-star .star-icon {
    font-size: 80px;
    animation: starPulse 2s ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.celebration-star .streak-number {
    font-size: 160px;
    font-weight: bold;
    margin: 20px 0;
    background: linear-gradient(135deg, #FF6B00 0%, #FF0844 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255,107,0,0.5);
    transition: all 0.3s ease;
    /* Enable 3D transformations for pirouette effect */
    transform-style: preserve-3d;
}

@keyframes growFromDot {
    0% {
        transform: scale(0.05) rotateY(0deg);
        opacity: 0.3;
        border-radius: 50%;
    }
    50% {
        transform: scale(1.2) rotateY(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotateY(360deg);
        opacity: 1;
        border-radius: 0%;
    }
}

.celebration-star .streak-label {
    font-size: 18px;
    opacity: 0.8;
    font-weight: 500;
    color: #333;
}

/* Multiplier Animation */
.multiplier-animation {
    margin: 30px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
}

.multiplier-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.multiplier-text .base-points {
    color: rgba(255, 255, 255, 0.7);
}

.multiplier-text .multiply-symbol {
    color: rgba(255, 193, 7, 0.8);
    font-size: 28px;
}

.multiplier-text .multiplier-value {
    color: #FFD700;
    font-weight: 700;
}

.equals-symbol {
    font-size: 20px;
    opacity: 0.5;
    margin: 8px 0;
}

.total-points {
    font-size: 36px;
    font-weight: 700;
    color: #4CAF50;
}

/* Total Score */
.total-score {
    margin: 30px 0;
    padding: 20px;
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid rgba(76, 175, 80, 0.3);
    border-radius: 16px;
}

.total-label {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 8px;
}

.total-value {
    font-size: 42px;
    font-weight: 700;
    color: #4CAF50;
}

/* Shield Earned */
.shield-earned {
    margin-top: 30px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.2) 0%, rgba(3, 169, 244, 0.2) 100%);
    border: 2px solid rgba(33, 150, 243, 0.5);
    border-radius: 16px;
    animation: shieldGlow 2s ease-in-out infinite;
}

@keyframes shieldGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(33, 150, 243, 0.3); }
    50% { box-shadow: 0 0 40px rgba(33, 150, 243, 0.6); }
}

.shield-earned .shield-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.shield-earned .shield-text {
    font-size: 20px;
    font-weight: 700;
    color: #2196F3;
    margin-bottom: 8px;
}

.shield-earned .shield-description {
    font-size: 14px;
    opacity: 0.8;
}

/* Celebration Close Button */
.celebration-close-btn {
    margin-top: 30px;
    padding: 16px 40px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.celebration-close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(76, 175, 80, 0.4);
}

/* Animation Classes */
.pulse-animation {
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.fade-in-animation {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.glow-animation {
    animation: glow 1.5s ease-in-out;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.3); }
    50% { box-shadow: 0 0 40px rgba(76, 175, 80, 0.8); }
}

/* ========================================= */
/* THEME-SPECIFIC GAMIFICATION STYLES        */
/* ========================================= */

/* MINIMAL THEME */
[data-theme="minimal"] .ranking-tab.active {
    background: linear-gradient(135deg, rgba(66, 165, 245, 0.2) 0%, rgba(0, 188, 212, 0.2) 100%);
    border-color: rgba(66, 165, 245, 0.5);
    color: #42a5f5;
}

[data-theme="minimal"] .stats-grid .stat-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="minimal"] .stats-grid .stat-card:hover {
    border-color: rgba(66, 165, 245, 0.3);
    background: rgba(255, 255, 255, 1);
}

[data-theme="minimal"] .stats-grid .stat-card .stat-value {
    color: #1a1a2e;
}

[data-theme="minimal"] .stats-grid .stat-card .stat-label {
    color: rgba(26, 26, 46, 0.8);
}

[data-theme="minimal"] .stats-grid .stat-card .stat-sublabel {
    color: rgba(26, 26, 46, 0.6);
}

[data-theme="minimal"] .celebration-content {
    background: linear-gradient(135deg, rgba(245, 245, 250, 0.98) 0%, rgba(230, 230, 240, 0.98) 100%);
    color: #1a1a2e;
}

[data-theme="minimal"] .celebration-star .streak-label,
[data-theme="minimal"] .multiplier-text .base-points,
[data-theme="minimal"] .total-label {
    color: rgba(26, 26, 46, 0.7);
}

/* NEON THEME */
[data-theme="neon"] .ranking-tab {
    color: white;
}

[data-theme="neon"] .ranking-tab.active {
    background: rgba(0, 255, 136, 0.2);
    border-color: #00FF88;
    color: #00FF88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

[data-theme="neon"] .stats-grid .stat-card {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(0, 255, 136, 0.3);
}

[data-theme="neon"] .stats-grid .stat-card:hover {
    border-color: #00FF88;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.3);
}

[data-theme="neon"] .stats-grid .stat-card .stat-value {
    color: #00FF88;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

[data-theme="neon"] .stats-grid .stat-card .stat-label {
    color: white;
    opacity: 1;
}

[data-theme="neon"] .stats-grid .stat-card .stat-sublabel {
    color: rgba(255, 255, 255, 0.8);
    opacity: 1;
}

[data-theme="neon"] .celebration-content {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95) 0%, rgba(10, 0, 20, 0.95) 100%);
    border-color: rgba(0, 255, 136, 0.3);
}

[data-theme="neon"] .shield-earned {
    background: rgba(0, 255, 136, 0.1);
    border-color: #00FF88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

/* RAINBOW THEME */
[data-theme="rainbow"] .ranking-tab.active {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.3) 0%, rgba(255, 193, 7, 0.3) 100%);
    border-color: rgba(255, 107, 157, 0.5);
    color: #FF6B9D;
}

[data-theme="rainbow"] .stats-grid .stat-card {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.1) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: rgba(255, 107, 157, 0.3);
}

[data-theme="rainbow"] .stats-grid .stat-card:hover {
    border-color: rgba(255, 107, 157, 0.5);
    box-shadow: 0 8px 24px rgba(255, 107, 157, 0.3);
}

[data-theme="rainbow"] .stats-grid .stat-card .stat-label {
    opacity: 1;
    color: rgba(255, 255, 255, 0.95);
}

[data-theme="rainbow"] .stats-grid .stat-card .stat-sublabel {
    opacity: 1;
    color: rgba(255, 255, 255, 0.8);
}

[data-theme="rainbow"] .celebration-content {
    background: linear-gradient(135deg, rgba(138, 43, 226, 0.95) 0%, rgba(255, 20, 147, 0.95) 100%);
    border-color: rgba(255, 107, 157, 0.5);
}

[data-theme="rainbow"] .shield-earned {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.2) 0%, rgba(255, 193, 7, 0.2) 100%);
    border-color: rgba(255, 107, 157, 0.5);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stats-grid .stat-card {
        padding: 16px 12px;
        aspect-ratio: 1 / 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .stats-grid .stat-card .stat-icon {
        font-size: 28px;
        margin-bottom: 8px;
    }

    .stats-grid .stat-card .stat-value {
        font-size: 24px;
        margin: 4px 0;
    }

    .stats-grid .stat-card .stat-label {
        font-size: 12px;
        text-align: center;
        line-height: 1.2;
    }

    .stats-footer {
        margin-top: 12px;
    }

    .stats-tip {
        font-size: 13px;
        margin: 0;
        padding: 8px 12px;
    }


    /* Taby zawsze obok siebie - nie zmieniamy flex-direction */

    .celebration-content {
        padding: 30px 20px;
        max-width: 95%;
    }

    .celebration-star .star-icon {
        font-size: 60px;
    }

    .celebration-star .streak-number {
        font-size: 144px;
    }

    .multiplier-text {
        font-size: 18px;
    }

    .total-value {
        font-size: 32px;
    }
}
