/* ============================================
   ACHIEVEMENTS & PROFILE STYLES
   ============================================ */

/* Profile Modal */
#profile-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.profile-modal-content {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    padding: 30px;
    position: relative;
}

.profile-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ecf0f1;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.profile-modal-close:hover {
    background: #bdc3c7;
    transform: rotate(90deg);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    flex-wrap: wrap;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    flex: 1;
}

.profile-info h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-info h2 .country-badge {
    display: inline-block;
    font-size: 24px;
}

.primary-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
}

.primary-badge.common { background: #95a5a6; }
.primary-badge.rare { background: #3498db; }
.primary-badge.epic { background: #9b59b6; }
.primary-badge.legendary { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }

.bio {
    margin: 8px 0;
    font-size: 14px;
    opacity: 0.9;
}

.joined-date {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.7;
}

/* Profile Actions / Share Button */
.btn-share {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 15px;
    font-size: 0.85em;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-share:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

/* Share Notification */
.share-notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    z-index: 10000;
    transition: bottom 0.3s ease;
}

.share-notification.show {
    bottom: 30px;
}

/* Featured Badges */
.featured-badges {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

.featured-badges h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
}

.badge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.badge-item {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    background: white;
    border: 2px solid #ddd;
    transition: all 0.3s ease;
}

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

.badge-item.common { border-color: #95a5a6; }
.badge-item.rare { border-color: #3498db; }
.badge-item.epic { border-color: #9b59b6; }
.badge-item.legendary { border-color: #f5576c; }

.badge-icon {
    font-size: 32px;
    display: block;
    margin-bottom: 8px;
}

.badge-name {
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
}

/* Profile Tabs */
.profile-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: #2c3e50;
}

.tab-btn.active {
    color: #2c3e50;
    border-bottom-color: #2c3e50;
}

.tab-content {
    display: none;
    padding: 20px 0;
}

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

/* Achievement Filters */
.achievement-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.achievement-filter {
    padding: 8px 16px;
    background: #ecf0f1;
    border: 2px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    transition: all 0.3s ease;
}

.achievement-filter:hover {
    background: #bdc3c7;
}

.achievement-filter.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Achievement Cards */
#achievements-list {
    display: block;
    margin-bottom: 20px;
}

.achievement-group {
    margin-bottom: 24px;
}

.achievement-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 12px 0;
}

.achievement-group-header h3 {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
}

.achievement-group-count {
    background: #ecf0f1;
    color: #2c3e50;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
}

.achievement-group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.achievement-card {
    padding: 16px;
    border-radius: 12px;
    background: white;
    border: 3px solid #ddd;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding-right: 50px; /* Make room for actions button */
}

.achievement-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.achievement-card.locked {
    opacity: 0.55;
    filter: grayscale(1);
    background: #f8f9fa;
    border-color: #dee2e6;
    border-style: dashed;
}

.achievement-card.locked:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.achievement-card.common { border-color: #95a5a6; }
.achievement-card.rare { 
    border-color: #3498db;
    box-shadow: 0 2px 12px rgba(52, 152, 219, 0.2);
}
.achievement-card.epic { 
    border-color: #9b59b6;
    box-shadow: 0 2px 12px rgba(155, 89, 182, 0.25);
}
.achievement-card.legendary { 
    border-color: #f5576c;
    box-shadow: 0 2px 20px rgba(245, 87, 108, 0.35);
    background: linear-gradient(135deg, #ffffff 0%, #fff5f7 100%);
}

.achievement-icon {
    font-size: 48px;
    line-height: 1;
}

.achievement-info {
    flex: 1;
}

.achievement-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rarity-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rarity-badge.common {
    background: #95a5a6;
    color: white;
}

.rarity-badge.rare {
    background: #3498db;
    color: white;
}

.rarity-badge.epic {
    background: #9b59b6;
    color: white;
}

.rarity-badge.legendary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    animation: legendary-pulse 2s ease-in-out infinite;
}

@keyframes legendary-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.achievement-info p {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #7f8c8d;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: #7f8c8d;
}

.unlock-date {
    font-size: 12px;
    color: #27ae60;
    font-weight: 600;
}

.achievement-actions {
    display: flex;
    gap: 4px;
    position: absolute;
    top: 12px;
    right: 12px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #ecf0f1;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: #667eea;
    transform: scale(1.1);
}

.achievements-count {
    text-align: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

#achievements-count {
    color: #667eea;
}

/* Stats Section */
.stats-section {
    margin-bottom: 30px;
}

.stats-section h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
}

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

.stat-item {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    text-align: center;
    color: white;
}

.stat-value {
    display: block;
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 8px;
}

.stat-label {
    display: block;
    font-size: 14px;
    opacity: 0.9;
}

/* Settings Panel */
.settings-panel {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin-bottom: 20px;
}

.settings-panel h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 18px;
}

.settings-description {
    margin: 0 0 20px 0;
    color: #7f8c8d;
    font-size: 14px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
}

.label-text {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.label-helper {
    display: block;
    font-size: 12px;
    color: #7f8c8d;
    font-weight: normal;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #dfe6e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.error-message {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    color: #c33;
    font-size: 14px;
    font-weight: 500;
}

.avatar-input-group {
    display: flex;
    gap: 10px;
}

.avatar-input-group input {
    flex: 1;
}

.avatar-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 2px solid #dfe6e9;
}

/* Modern Avatar Preview and Selector */
.avatar-preview-container {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

.avatar-preview-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.avatar-preview-large .emoji-display {
    font-size: 60px;
}

.avatar-preview-large .gradient-display {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.btn-change-avatar {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-change-avatar:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Avatar Modal */
.avatar-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.avatar-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.avatar-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid #e9ecef;
}

.avatar-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #2c3e50;
}

.avatar-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #95a5a6;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.avatar-modal-close:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.avatar-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.avatar-modal-preview {
    text-align: center;
    margin-bottom: 30px;
}

.avatar-preview-xl {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    margin-bottom: 12px;
}

.avatar-preview-xl .emoji-display {
    font-size: 90px;
}

.avatar-preview-xl .gradient-display {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.avatar-preview-label {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.avatar-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
}

.avatar-tab {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #7f8c8d;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.avatar-tab:hover {
    color: #667eea;
}

.avatar-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 15px;
}

.avatar-item {
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.2s;
    border: 3px solid transparent;
}

.avatar-item:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

.avatar-item.selected {
    border-color: #667eea;
    background: #f0f3ff;
}

.avatar-item-inner {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.avatar-modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.emoji-display {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Twemoji Mozilla", system-ui, sans-serif;
}

.gradient-display {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.avatar-option {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    font-size: 32px;
}

.avatar-option:hover {
    transform: scale(1.1);
    border-color: #b2bec3;
}

.avatar-option.selected {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.emoji-avatar {
    background: #f8f9fa;
}

/* Gradient avatar styles */
.gradient-1 { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.gradient-2 { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.gradient-3 { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.gradient-4 { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.gradient-5 { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
.gradient-6 { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }

.char-counter {
    text-align: right;
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 4px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.checkbox-label:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-text strong {
    color: #2c3e50;
    font-size: 14px;
}

.checkbox-text small {
    color: #7f8c8d;
    font-size: 12px;
}

.settings-panel label {
    display: block;
    padding: 12px 0;
    cursor: pointer;
    font-size: 14px;
    color: #2c3e50;
}

.settings-panel input[type="checkbox"] {
    margin-right: 8px;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #ecf0f1;
    color: #2c3e50;
}

.btn-secondary:hover {
    background: #bdc3c7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .leaderboard-header {
        gap: 8px;
    }
    
    .btn-share {
        padding: 8px 12px;
        font-size: 0.9em;
        white-space: nowrap;
        min-width: fit-content;
    }
    
    .profile-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    /* Mobile-optimized profile tabs */
    .profile-tabs {
        gap: 4px;
        overflow-x: auto;
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .profile-tabs::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .tab-btn {
        padding: 10px 16px;
        font-size: 14px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    #achievements-list {
        grid-template-columns: 1fr;
    }
    
    .badge-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Achievement Unlock Notification */
.achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 350px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideIn 0.5s ease;
    z-index: 2000;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.achievement-notification.legendary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.notification-header {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    opacity: 0.8;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-icon {
    font-size: 48px;
}

.notification-info h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
}

.notification-info p {
    margin: 0;
    font-size: 13px;
    opacity: 0.8;
}
