/* ============================================
   GAMIFICATION STYLES - CHATFLY 2026
   ============================================ */

/* Compact Gold Balance (Sidebar) */
.gold-balance-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.gold-balance-compact .gold-amount {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.gold-balance-compact .gold-icon {
    font-size: 1.2rem;
}

.gold-balance-compact .gold-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.gold-balance-compact .gold-rate {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.gold-balance-compact .collect-btn {
    padding: 4px 8px;
    font-size: 0.8rem;
    background: var(--brand-color);
    animation: pulse 2s infinite;
}

.gold-balance-compact .btn-sm {
    padding: 4px 8px;
    font-size: 0.9rem;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Storage Bar (used in modal) */
.storage-bar {
    height: 8px;
    background: var(--bg-tertiary, #2a2a2a);
    border-radius: 4px;
    overflow: hidden;
}

.storage-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-color), #fbbf24);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.storage-fill.full {
    background: linear-gradient(90deg, #fbbf24, #22c55e);
    animation: glow 1s infinite alternate;
}

@keyframes glow {
    from { box-shadow: 0 0 5px #fbbf24; }
    to { box-shadow: 0 0 15px #22c55e; }
}

/* Gamification Header */
.gamification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, rgba(255, 0, 110, 0.1), rgba(138, 43, 226, 0.1));
    border-radius: 16px;
    margin-bottom: 16px;
}

.user-level {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 24px;
    font-weight: 700;
}

.level-icon {
    font-size: 32px;
}

.user-points {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.points-value {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #ff006e, #8a2be2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.points-label {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

/* Level Progress Bar */
.level-progress {
    margin-bottom: 20px;
}

.progress-bar {
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff006e, #8a2be2);
    border-radius: 12px;
    transition: width 0.6s var(--spring-medium);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.5);
}

.progress-text {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

/* Badge Grid */
.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.badge-item {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s var(--spring-medium);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.badge-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.badge-item:hover {
    transform: translateY(-4px) scale(1.05);
    border-color: var(--color-primary);
}

.badge-item:hover::before {
    opacity: 1;
}

/* Badge Tiers */
.badge-item.bronze {
    border-color: #cd7f32;
}

.badge-item.bronze:hover {
    border-color: #cd7f32;
    box-shadow: 0 4px 20px rgba(205, 127, 50, 0.4);
}

.badge-item.silver {
    border-color: #c0c0c0;
}

.badge-item.silver:hover {
    border-color: #c0c0c0;
    box-shadow: 0 4px 20px rgba(192, 192, 192, 0.4);
}

.badge-item.gold {
    border-color: #ffd700;
}

.badge-item.gold:hover {
    border-color: #ffd700;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
}

.badge-item.platinum {
    border-color: #e5e4e2;
    background: linear-gradient(135deg, rgba(229, 228, 226, 0.1), rgba(138, 43, 226, 0.1));
}

.badge-item.platinum:hover {
    border-color: #e5e4e2;
    box-shadow: 0 4px 20px rgba(229, 228, 226, 0.4);
}

.badge-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.badge-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Badge Notification (Earned) */
.badge-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    animation: slideInRight 0.5s var(--spring-medium), fadeOut 0.5s ease 4.5s forwards;
    pointer-events: none;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.badge-earned {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-primary);
    border: 3px solid #ffd700;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.3);
    min-width: 300px;
}

.badge-notification.mission-complete .badge-earned {
    border-color: #8a2be2;
    box-shadow: 0 10px 40px rgba(138, 43, 226, 0.3);
}

.badge-notification.level-up .badge-earned {
    border-color: #ff006e;
    box-shadow: 0 10px 40px rgba(255, 0, 110, 0.3);
}

.badge-earned .badge-icon {
    font-size: 60px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.badge-info {
    flex: 1;
}

.badge-info .badge-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.badge-info .badge-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.badge-info .badge-points {
    font-size: 16px;
    font-weight: 600;
    color: #ffd700;
}

/* Daily Missions */
#dailyMissions h3 {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
}

.missions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mission-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 16px;
    border: 2px solid var(--border-color);
    transition: all 0.3s var(--spring-medium);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.mission-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--color-primary);
    transform: scaleY(0);
    transition: transform 0.3s var(--spring-medium);
}

.mission-card:hover {
    transform: translateX(4px);
    border-color: var(--color-primary);
}

.mission-card:hover::before {
    transform: scaleY(1);
}

/* Mission Difficulty Colors */
.mission-card.easy {
    border-left: 4px solid #4ade80;
}

.mission-card.medium {
    border-left: 4px solid #fbbf24;
}

.mission-card.hard {
    border-left: 4px solid #f87171;
}

/* Completed Mission */
.mission-card.completed {
    opacity: 0.6;
    background: var(--bg-tertiary);
}

.mission-card.completed::after {
    content: '✓';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    color: #4ade80;
}

.mission-icon {
    font-size: 40px;
}

.mission-info {
    flex: 1;
}

.mission-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.mission-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.mission-reward {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
}

/* Leaderboard */
.leaderboard {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
}

.leaderboard h3 {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.leaderboard-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.leaderboard-rank {
    font-size: 24px;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
}

/* Top 3 ranks */
.leaderboard-item:nth-child(1) .leaderboard-rank {
    color: #ffd700;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
    color: #c0c0c0;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
    color: #cd7f32;
}

.leaderboard-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-size: 16px;
    font-weight: 600;
}

.leaderboard-level {
    font-size: 12px;
    color: var(--text-secondary);
}

.leaderboard-points {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-primary);
}

/* Badge Modal */
.badge-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.badge-modal.active {
    opacity: 1;
    pointer-events: all;
}

.badge-modal-content {
    background: var(--bg-primary);
    border-radius: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 32px;
    transform: scale(0.9);
    transition: transform 0.3s var(--spring-medium);
}

.badge-modal.active .badge-modal-content {
    transform: scale(1);
}

.badge-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.badge-modal-header h2 {
    font-size: 28px;
}

.badge-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.badge-modal-close:hover {
    color: var(--text-primary);
}

.badge-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.badge-category-btn {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.badge-category-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.badge-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gamification-header {
        flex-direction: column;
        gap: 12px;
    }

    .badge-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .badge-notification {
        left: 20px;
        right: 20px;
    }

    .badge-earned {
        min-width: auto;
    }

    .mission-card {
        flex-direction: column;
        text-align: center;
    }
}

/* Performance Optimizations */
.badge-item,
.mission-card,
.leaderboard-item {
    will-change: transform;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .badge-notification,
    .badge-earned .badge-icon {
        animation: none !important;
    }
}

/* ============================================
   GOLD MINE - Passive Income System
   ============================================ */

.gold-mine-panel {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(245, 158, 11, 0.05));
    border: 2px solid rgba(251, 191, 36, 0.3);
    border-radius: 16px;
    padding: 20px;
    margin-top: 16px;
}

.mine-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.mine-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mine-production {
    font-size: 1rem;
    font-weight: 600;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
}

.mine-storage {
    margin-bottom: 16px;
}

.storage-bar {
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.storage-fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    border-radius: 12px;
    transition: width 0.5s ease;
    position: relative;
}

.storage-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.storage-fill.full {
    background: linear-gradient(90deg, #10b981, #059669);
    animation: pulse-glow 1s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); }
    50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.8); }
}

.storage-text {
    text-align: center;
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.mine-collect-btn {
    width: 100%;
    margin-bottom: 16px;
    font-size: 1rem;
    padding: 14px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border: none;
    color: #1a1a1a;
    font-weight: 700;
}

.mine-collect-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(251, 191, 36, 0.4);
}

.mine-collect-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.mine-upgrades {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upgrade-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.upgrade-card:hover {
    border-color: rgba(251, 191, 36, 0.5);
    background: rgba(251, 191, 36, 0.05);
}

.upgrade-icon {
    font-size: 2rem;
    line-height: 1;
}

.upgrade-info {
    flex: 1;
}

.upgrade-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.upgrade-level {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.upgrade-btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    white-space: nowrap;
    border-color: #fbbf24;
    color: #fbbf24;
}

.upgrade-btn:hover {
    background: #fbbf24;
    color: #1a1a1a;
}

.max-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mine-stats {
    margin-top: 12px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Gold Economy Display */
.user-gold {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(251, 191, 36, 0.15);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.user-gold .gold-icon {
    font-size: 1.25rem;
}

.user-gold .gold-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fbbf24;
}

.user-gold .gold-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 480px) {
    .upgrade-card {
        flex-wrap: wrap;
    }

    .upgrade-btn {
        width: 100%;
        margin-top: 8px;
    }
}
