/* 🎮 GAMIFICATION STYLES */
/* Color Psychology for Learning:
 * Blue (#4A90E2): Focus & concentration
 * Green (#28A745): Reduces eye strain, promotes balance
 * Purple (#6F42C1): Memory retention & creativity
 * Orange (#FD7E14): Motivation & engagement
 * Teal (#17A2B8): Clear thinking & information processing
 */

/* === GAMIFIED HEADER === */
.gamified-header {
    text-align: center;
    margin-bottom: 15px;  /* Reduced from 30px */
    position: relative;
}

.user-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;  /* Reduced from 20px */
    margin-bottom: 10px;  /* Reduced from 15px */
    flex-wrap: wrap;
}

/* Level Badge */
.level-badge {
    background: linear-gradient(135deg, #FD7E14, #F39C12);
    border-radius: 20px;
    padding: 5px 12px;  /* Reduced from 8px 15px */
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 3px 10px rgba(253, 126, 20, 0.25);
    border: 1.5px solid #E67E22;
    font-weight: bold;
    color: #FFFFFF;
    font-size: 14px;  /* Slightly smaller */
}

.level-icon {
    font-size: 16px;  /* Reduced from 18px */
    animation: sparkle 2s infinite;
}

/* XP Bar */
.xp-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.xp-bar {
    width: 180px;  /* Reduced from 200px */
    height: 16px;  /* Reduced from 20px */
    background: linear-gradient(145deg, #e8e8e8, #f5f5f5);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.15);
    border: 1.5px solid #ddd;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #4A90E2, #2E86AB);
    border-radius: 25px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.xp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: xp-shine 3s infinite;
}

.xp-text {
    font-size: 11px;  /* Reduced from 12px */
    font-weight: 600;
    color: #555;
}

/* Streak Display */
.streak-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.streak-flame {
    font-size: 20px;  /* Reduced from 24px */
    filter: drop-shadow(0 0 6px rgba(255, 69, 0, 0.5));
    animation: fire-dance 2s infinite;
}

.streak-count {
    font-weight: bold;
    color: #FD7E14;
    font-size: 14px;  /* Reduced from 16px */
}

/* === ACHIEVEMENTS BAR === */
.achievements-bar {
    background: linear-gradient(135deg, #6F42C1 0%, #9B59B6 100%);
    padding: 10px 15px;  /* Reduced vertical padding */
    border-radius: 12px;
    margin-bottom: 15px;  /* Reduced from 20px */
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(111, 66, 193, 0.25);
    flex-wrap: wrap;
    gap: 8px;
}

.recent-achievements {
    display: flex;
    align-items: center;
    gap: 10px;
}

.achievement-title {
    font-weight: bold;
    font-size: 13px;  /* Reduced from 14px */
}

.motivational-message {
    font-style: italic;
    opacity: 0.9;
    font-size: 13px;  /* Reduced from 14px */
}

/* === DAILY CHALLENGES SIDEBAR === */
.daily-challenges-sidebar {
    position: fixed;
    right: -400px; /* Further off-screen */
    top: 80px;
    bottom: 30px;
    width: 320px;
    overflow-y: auto;
    background: linear-gradient(145deg, #17A2B8, #20C997);
    border-radius: 20px 0 0 20px;
    padding: 20px;
    color: white;
    z-index: 996;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 25px rgba(0, 0, 0, 0.3);
    display: none; /* Hidden by default */
}

.daily-challenges-sidebar.open {
    right: 0;
    box-shadow: -15px 0 35px rgba(0, 0, 0, 0.4);
}

/* Floating toggle button - always visible */
.challenges-float-toggle {
    position: fixed;
    right: 20px;
    bottom: 130px;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    z-index: 997;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: pulse-trophy 3s infinite;
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

@keyframes pulse-trophy {
    0%, 100% { transform: scale(1); box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 8px 20px rgba(255, 215, 0, 0.5); }
}

.challenges-float-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.6);
}

.challenges-float-toggle.hidden {
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none;
}

.challenges-float-toggle i {
    font-size: 22px;
}

.challenges-float-toggle span {
    display: none;
}

/* Notification badge for challenges */
.challenges-float-toggle::after {
    content: '3';
    position: absolute;
    top: -3px;
    right: -3px;
    background: #FD7E14;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

.challenges-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.challenges-header h3 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.challenges-toggle {
    cursor: pointer;
    padding: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.challenges-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(180deg);
    border-color: rgba(255, 255, 255, 0.5);
}

.challenges-toggle i {
    font-size: 14px;
    color: white;
}

.challenge-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    border-left: 4px solid #ffd700;
    transition: all 0.3s ease;
}

.challenge-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(-5px);
    box-shadow: -4px 0 10px rgba(255, 215, 0, 0.3);
}

.challenge-item.completed {
    opacity: 0.7;
    border-left-color: #4ade80;
}

.challenge-progress {
    margin-top: 8px;
}

.challenge-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.challenge-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.challenge-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.challenge-description {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.challenge-progress {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.challenge-xp {
    color: #ffd700;
    font-weight: bold;
}

/* === ENHANCED PROGRESS BAR === */
.progress-sparkles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    border-radius: 25px;
}

.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    animation: sparkle-float 2s infinite;
}

/* === CONFETTI CANVAS === */
.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 10000;
}

/* === XP GAIN POPUP === */
.xp-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #8b4513;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
    z-index: 9999;
    pointer-events: none;
}

.xp-popup.show {
    animation: xp-gain-float 2s ease-out forwards;
}

/* === ACHIEVEMENT NOTIFICATION === */
.achievement-notification {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    transition: top 0.5s ease;
}

.achievement-notification.show {
    top: 20px;
    animation: achievement-bounce 0.5s ease-out;
}

.achievement-icon {
    font-size: 32px;
    animation: achievement-glow 2s infinite;
}

.achievement-title {
    font-weight: bold;
    font-size: 16px;
}

.achievement-description {
    font-size: 14px;
    opacity: 0.9;
}

/* === LEVEL UP NOTIFICATION === */
.levelup-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: radial-gradient(circle, #ffd700, #ffa500);
    color: #8b4513;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    z-index: 10000;
    box-shadow: 0 15px 40px rgba(255, 215, 0, 0.6);
    border: 3px solid #fff;
}

.levelup-notification.show {
    animation: levelup-celebration 3s ease-out forwards;
}

.levelup-title {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.levelup-level {
    font-size: 24px;
    margin-bottom: 10px;
}

.levelup-sparkle {
    font-size: 30px;
    animation: sparkle 1s infinite;
}

/* === STUDY BUDDY MASCOT === */
.study-buddy {
    position: fixed;
    top: 20px;
    right: 20px; /* Positioned on top right */
    z-index: 900;
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align items to the right */
    gap: 10px;
    transition: right 0.3s ease;
}

.mascot-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.mascot-character {
    font-size: 48px;
    cursor: pointer;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    animation: mascot-bounce 3s infinite;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(74, 144, 226, 0.3);
    position: relative;
}

/* Mascot hover tooltip - name appears to the left */
.mascot-character::after {
    content: attr(data-mascot-name);
    position: absolute;
    top: 50%;
    right: 110%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    z-index: 10000;
}

.mascot-character:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(-5px);
}

/* Dark mode fix for mascot tooltip */
body.dark-mode .mascot-character::after {
    background: linear-gradient(135deg, #4a5cc5, #5a3d7a);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.mascot-character:hover {
    transform: scale(1.1);
    border-color: rgba(74, 144, 226, 0.6);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.mascot-selector {
    display: none;
    flex-direction: row;
    gap: 8px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(102, 126, 234, 0.3);
}

.mascot-selector.show {
    display: flex;
    animation: selector-fadeIn 0.3s ease;
}

.mascot-option {
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
}

.mascot-option:hover {
    transform: scale(1.2);
    background: rgba(102, 126, 234, 0.1);
    border-color: rgba(102, 126, 234, 0.3);
}

/* Tooltip for mascot options */
.mascot-option::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(33, 33, 33, 0.95);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mascot-option:hover::before {
    opacity: 1;
}

.mascot-option.active {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
}

.mascot-speech-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 20px;
    max-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.mascot-speech-bubble::after {
    content: '';
    position: absolute;
    top: -10px;
    right: 20px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid white;
}

.mascot-speech-bubble.show {
    opacity: 1;
    transform: translateY(0);
}

.speech-text {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
}

/* Dark mode fixes for mascot speech */
body.dark-mode .mascot-speech-bubble {
    background: #333;
    color: #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .mascot-speech-bubble::after {
    border-bottom-color: #333;
}

body.dark-mode .speech-text {
    color: #e0e0e0;
}

/* === ANIMATIONS === */
@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
}

@keyframes fire-dance {
    0%, 100% { transform: scaleY(1) rotate(-2deg); }
    25% { transform: scaleY(1.1) rotate(2deg); }
    50% { transform: scaleY(0.9) rotate(-1deg); }
    75% { transform: scaleY(1.05) rotate(1deg); }
}

@keyframes xp-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes xp-gain-float {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    80% { transform: translate(-50%, -80px) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -120px) scale(0.8); opacity: 0; }
}

@keyframes achievement-bounce {
    0% { transform: translateX(-50%) scale(0.8); }
    50% { transform: translateX(-50%) scale(1.1); }
    100% { transform: translateX(-50%) scale(1); }
}

@keyframes achievement-glow {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.6)); }
    50% { filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.9)); }
}

@keyframes levelup-celebration {
    0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(1.2) rotate(5deg); opacity: 1; }
    40% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
    60% { transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
    80% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
    90% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}

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

@keyframes selector-fadeIn {
    0% { opacity: 0; transform: translateY(-10px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes sparkle-float {
    0% { transform: translateY(0) scale(0); opacity: 0; }
    50% { transform: translateY(-20px) scale(1); opacity: 1; }
    100% { transform: translateY(-40px) scale(0); opacity: 0; }
}

@keyframes confetti-fall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .user-stats {
        gap: 15px;
    }
    
    .xp-bar {
        width: 150px;
    }
    
    .achievements-bar {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .daily-challenges-sidebar {
        width: 280px;
        right: -280px;
    }
    
    .daily-challenges-sidebar.open {
        right: 0;
    }
    
    .study-buddy {
        top: 15px;
        right: 15px;
    }
    
    .challenges-float-toggle {
        right: 15px;
        bottom: 120px;
    }
    
    .mascot-character {
        font-size: 40px;
    }
    
    .mascot-speech-bubble {
        max-width: 160px;
        padding: 10px 14px;
    }
}

/* === ENHANCED TASK MODULE STYLING === */
.task-module {
    position: relative;
    overflow: visible;
}

.task-module::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    border-radius: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.task-module:hover::before {
    opacity: 1;
}

/* Enhanced checkbox styling */
input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #667eea;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #28A745, #20C997);
    border-color: #28A745;
    transform: scale(1.1);
}

input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -2px;
    left: 2px;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

/* Fun hover effects */
.task-module:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Gamified buttons */
button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3), transparent);
    transition: all 0.5s ease;
    transform: translate(-50%, -50%);
}

button:hover::before {
    width: 300px;
    height: 300px;
}