/**
 * Gamification CSS - Matematikapp Fas 3.1
 * XP, Levels, Achievements, Streaks, Animations
 */

/* ========================================================================
   PLAYER STATS BAR (XP, Level, Streak)
   ======================================================================== */

.player-stats {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

.player-stats-grid {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 20px;
    align-items: center;
}

.player-level {
    display: flex;
    align-items: center;
    gap: 12px;
}

.level-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 25px;
    font-size: 1.1em;
    font-weight: 700;
    backdrop-filter: blur(10px);
}

.xp-progress {
    flex: 1;
}

.xp-bar-container {
    background: rgba(255, 255, 255, 0.2);
    height: 12px;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
}

.xp-bar-fill {
    background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%);
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(67, 233, 123, 0.5);
}

.xp-text {
    font-size: 0.85em;
    opacity: 0.9;
    margin-top: 3px;
}

.streak-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

.streak-flame {
    font-size: 1.3em;
    animation: flameFlicker 1s ease-in-out infinite;
}

@keyframes flameFlicker {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.coins-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

.coin-icon {
    font-size: 1.2em;
}

/* ========================================================================
   ACHIEVEMENTS
   ======================================================================== */

.achievements-section {
    background: white;
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-top: 0;
    margin-bottom: 15px;
}

.achievements-section h3 {
    margin-bottom: 12px;
    font-size: 1.2em;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    margin-top: 0;
}

.achievement-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
}

.achievement-card.unlocked {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-color: #ffa726;
    box-shadow: 0 3px 10px rgba(255, 167, 38, 0.3);
}

.achievement-card:hover {
    transform: translateY(-3px);
}

.achievement-icon {
    font-size: 3em;
    margin-bottom: 10px;
    filter: grayscale(100%);
    opacity: 0.3;
}

.achievement-card.unlocked .achievement-icon {
    filter: grayscale(0%);
    opacity: 1;
    animation: achievementUnlock 0.6s ease;
}

@keyframes achievementUnlock {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.achievement-name {
    font-size: 0.95em;
    font-weight: 600;
    color: #2c3e50;
}

.achievement-card.unlocked .achievement-name {
    color: #f57c00;
}

.achievement-date {
    font-size: 0.7em;
    color: #666;
    margin-top: 4px;
}

/* ========================================================================
   TOAST NOTIFICATIONS
   ======================================================================== */

.achievement-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ffa726 0%, #ff6f00 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(255, 167, 38, 0.5);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.achievement-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.achievement-icon {
    font-size: 2em;
}

.achievement-content {
    flex: 1;
}

.achievement-title {
    font-size: 0.85em;
    opacity: 0.9;
    margin-bottom: 3px;
}

.achievement-name {
    font-size: 1.1em;
    font-weight: 700;
}

/* ========================================================================
   LEVEL UP POPUP
   ======================================================================== */

.level-up-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    text-align: center;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.level-up-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.level-up-icon {
    font-size: 5em;
    margin-bottom: 15px;
    animation: starPulse 1s ease-in-out infinite;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2) rotate(10deg); }
}

.level-up-title {
    font-size: 2em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.level-up-level {
    font-size: 3em;
    font-weight: 900;
    color: #667eea;
    margin-bottom: 15px;
}

.level-up-message {
    font-size: 1.1em;
    color: #666;
}

/* ========================================================================
   XP NOTIFICATION
   ======================================================================== */

.xp-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -200%);
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 1.2em;
    box-shadow: 0 5px 20px rgba(67, 233, 123, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: all 0.5s ease;
}

.xp-notification.show {
    opacity: 1;
    transform: translate(-50%, -300%);
}

.xp-amount {
    font-size: 1.3em;
}

.xp-reason {
    font-size: 0.8em;
    opacity: 0.9;
    margin-left: 10px;
}

/* ========================================================================
   STREAK POPUP
   ======================================================================== */

.streak-popup {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.8em;
    font-weight: 700;
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.5);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.streak-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ========================================================================
   CORRECT ANSWER CELEBRATION
   ======================================================================== */

.feedback-box.success {
    animation: correctPulse 0.5s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 5px 30px rgba(76, 175, 80, 0.5); }
    100% { transform: scale(1); }
}

/* ========================================================================
   PROGRESS BAR ANIMATIONS
   ======================================================================== */

.progress-bar-shimmer {
    position: relative;
    overflow: hidden;
}

.progress-bar-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */

@media (max-width: 768px) {
    .player-stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .level-up-popup {
        padding: 30px 20px;
        width: 90%;
        max-width: 400px;
    }

    .achievement-toast {
        right: 10px;
        left: 10px;
        max-width: 90%;
    }
}
