/* ===========================
   GAMIFICATION STYLES
   Стили для системы баллов и достижений
   =========================== */

/* XP Counter в навигации - компактная версия */
.xp-counter {
    position: fixed;
    top: 15px;
    left: 180px; /* Ближе к логотипу, дальше от навигации */
    z-index: 1000;
    width: fit-content; /* ✅ КРИТИЧНО: Ограничить ширину контента, не блокировать другие элементы */
    pointer-events: auto; /* ✅ Разрешить клики только на сам счётчик */
}

/* На мобильных устройствах - слева от иконки домика */
@media (max-width: 768px) {
    .xp-counter {
        top: 140px; /* Под адресной строкой, в ряду иконок */
        left: 10px; /* Максимально слева */
        width: fit-content; /* ✅ Ограничить ширину на мобильных тоже */
    }
}

.xp-display {
    display: flex;
    align-items: center;
    gap: 4px; /* Ещё компактнее */
    background: var(--card-bg);
    padding: 4px 10px; /* Уменьшен для компактности */
    border-radius: 16px; /* Меньше радиус */
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px; /* Уменьшен общий размер шрифта */
}

/* Ещё более компактный вид на мобильных */
@media (max-width: 768px) {
    .xp-display {
        gap: 3px;
        padding: 3px 8px;
        border-radius: 12px;
        font-size: 11px;
    }
}

.xp-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.level-badge {
    font-size: 16px; /* Компактный размер иконки */
}

.xp-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px; /* Компактный размер текста */
}

/* Супер-компактно на мобильных */
@media (max-width: 768px) {
    .level-badge {
        font-size: 14px;
    }
    
    .xp-value {
        font-size: 10px;
    }
}

/* Карточка прогресса профиля */
.gamification-progress-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.level-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.level-badge-large {
    font-size: 48px;
}

.level-text h3 {
    margin: 0;
    font-size: 24px;
    color: var(--text-primary);
}

.level-subtitle {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.xp-info {
    text-align: right;
}

.xp-current {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.xp-next {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.5s ease;
    border-radius: 6px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.max-level-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    border-radius: 12px;
    font-weight: 600;
}

/* Статистика активностей */
.gamification-stats-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gamification-stats-card h3 {
    margin: 0 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-4px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.stat-details {
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-xp {
    font-size: 12px;
    color: var(--success-color);
    font-weight: 600;
    margin-top: 4px;
}

/* Достижения */
.achievements-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.achievements-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.achievements-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.achievements-count {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

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

.achievement-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.achievement-badge:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.achievement-badge.unlocked {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.achievement-badge.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.achievement-icon {
    font-size: 32px;
}

.achievement-name {
    font-size: 12px;
    text-align: center;
    font-weight: 600;
}

.achievement-xp {
    font-size: 11px;
    opacity: 0.9;
}

.btn-view-all {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-view-all:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* XP Toast уведомление */
.xp-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

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

.xp-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    min-width: 280px;
}

.xp-toast-content.positive {
    border-left: 4px solid var(--success-color);
}

.xp-toast-content.negative {
    border-left: 4px solid var(--danger-color);
}

.xp-toast-icon {
    font-size: 32px;
}

.xp-toast-text {
    flex: 1;
}

.xp-toast-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.xp-toast-reason {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.xp-toast-progress {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Level Up Modal */
.level-up-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.level-up-modal.show {
    opacity: 1;
}

.level-up-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.level-up-content {
    position: relative;
    background: var(--card-bg);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: levelUpBounce 0.6s ease;
}

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

.level-up-animation {
    margin-bottom: 20px;
}

.level-up-badge {
    font-size: 80px;
    animation: levelUpRotate 1s ease;
}

@keyframes levelUpRotate {
    0% { transform: rotate(0deg) scale(0); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}

.level-up-title {
    font-size: 32px;
    margin: 0 0 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.level-up-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0 0 20px;
}

.level-up-bonus {
    background: var(--success-color);
    color: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
}

.btn-level-up-close {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-level-up-close:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Achievement Toast */
.achievement-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

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

.achievement-toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    min-width: 300px;
}

.achievement-toast-icon {
    font-size: 40px;
}

.achievement-toast-title {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 4px;
}

.achievement-toast-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.achievement-toast-xp {
    font-size: 13px;
    opacity: 0.9;
}

/* User Level Badge в карточках */
.user-level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-primary);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-left: 8px;
}

/* Mobile адаптация */
@media (max-width: 768px) {
    .xp-counter {
        top: 10px;
        right: 10px;
    }
    
    .xp-display {
        padding: 6px 12px;
    }
    
    .level-badge {
        font-size: 16px;
    }
    
    .xp-value {
        font-size: 12px;
    }
    
    .gamification-progress-card,
    .gamification-stats-card,
    .achievements-card {
        padding: 16px;
    }
    
    .level-badge-large {
        font-size: 36px;
    }
    
    .level-text h3 {
        font-size: 20px;
    }
    
    .xp-current {
        font-size: 22px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .achievements-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .xp-toast,
    .achievement-toast {
        right: 10px;
        left: 10px;
        top: 70px;
    }
    
    .xp-toast-content,
    .achievement-toast-content {
        min-width: auto;
    }
    
    .level-up-content {
        margin: 20px;
        padding: 24px;
    }
    
    .level-up-badge {
        font-size: 60px;
    }
    
    .level-up-title {
        font-size: 24px;
    }
}

/* Dark theme adjustments */
[data-theme="dark"] .gamification-progress-card,
[data-theme="dark"] .gamification-stats-card,
[data-theme="dark"] .achievements-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .xp-display {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Christmas theme adjustments */
[data-theme="christmas"] .progress-bar-fill {
    background: linear-gradient(90deg, #c41e3a, #165b33);
}

[data-theme="christmas"] .btn-level-up-close {
    background: linear-gradient(135deg, #c41e3a, #165b33);
}

/* ===========================
   GAMIFICATION MODAL
   Модальное окно прогресса и достижений
   =========================== */

.gamification-modal-content {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
}

.gamification-modal-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.level-badge-huge {
    font-size: 72px;
    line-height: 1;
}

.level-info-large h2 {
    margin: 0 0 8px;
    font-size: 32px;
    color: var(--text-primary);
}

.xp-display-large {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.xp-current-large {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-color);
}

.xp-next-large {
    font-size: 24px;
    color: var(--text-secondary);
}

.progress-section {
    margin-bottom: 32px;
}

.progress-bar-container-large {
    width: 100%;
    height: 16px;
    background: var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-info-large {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    color: var(--text-secondary);
}

.max-level-message-large {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
    border-radius: 16px;
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 32px;
}

.stats-section {
    margin-bottom: 32px;
}

.stats-section h3 {
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 20px;
}

.stats-grid-compact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    text-align: center;
}

.stat-compact i {
    font-size: 28px;
}

.stat-compact .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-compact .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.achievements-preview h3 {
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 20px;
}

/* Mobile адаптация для модала */
@media (max-width: 768px) {
    .gamification-modal-content {
        padding: 20px;
        max-height: 85vh;
    }
    
    .gamification-modal-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .level-badge-huge {
        font-size: 56px;
    }
    
    .level-info-large h2 {
        font-size: 24px;
    }
    
    .xp-current-large {
        font-size: 36px;
    }
    
    .xp-next-large {
        font-size: 18px;
    }
    
    .stats-grid-compact {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-compact {
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
    }
    
    .stat-compact i {
        font-size: 24px;
    }
}
