/* ═══════════════════════════════════════════════════════════════════════
   AVATAR PICKER SYSTEM
   ═══════════════════════════════════════════════════════════════════ */

/* Avatar Picker Modal */
.avatar-picker-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.avatar-picker-modal.active {
    display: flex;
}

.avatar-picker-content {
    background: rgba(26, 26, 26, 0.98);
    border: 2px solid var(--primary-gold, #ffd700);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.avatar-picker-header {
    padding: 2rem;
    border-bottom: 1px solid rgba(255, 215, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: rgba(26, 26, 26, 0.98);
    z-index: 1;
}

.avatar-picker-header h2 {
    color: var(--primary-gold, #ffd700);
    font-size: 1.5rem;
    margin: 0;
}

.avatar-picker-close {
    background: none;
    border: none;
    color: var(--primary-gold, #ffd700);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.avatar-picker-close:hover {
    background: rgba(255, 215, 0, 0.1);
    transform: rotate(90deg);
}

.avatar-picker-body {
    padding: 2rem;
}

/* Upload Section */
.avatar-upload-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 215, 0, 0.05);
    border: 2px dashed rgba(255, 215, 0, 0.3);
    border-radius: 12px;
    text-align: center;
}

.avatar-upload-section h3 {
    color: var(--primary-gold, #ffd700);
    font-size: 1.1rem;
    margin: 0 0 1rem 0;
}

.avatar-upload-btn {
    background: var(--primary-gold, #ffd700);
    color: var(--primary-black, #000);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.avatar-upload-btn:hover {
    background: #ffed4e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

#avatar-file-input {
    display: none;
}

/* Avatar Grid */
.avatar-selection-section {
    margin-top: 2rem;
}

.avatar-selection-section h3 {
    color: rgba(255, 215, 0, 0.8);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 0 0 1rem 0;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
}

.avatar-option {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.05);
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-option:hover {
    border-color: rgba(255, 215, 0, 0.5);
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: var(--primary-gold, #ffd700);
    border-width: 4px;
    box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.2);
}

.avatar-option.selected::after {
    content: '✓';
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary-gold, #ffd700);
    color: var(--primary-black, #000);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

/* Avatar Preview */
.avatar-preview-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(255, 215, 0, 0.05);
    border-radius: 12px;
    text-align: center;
}

.avatar-preview-section h3 {
    color: rgba(255, 215, 0, 0.8);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 0 0 1rem 0;
}

.avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    border: 4px solid var(--primary-gold, #ffd700);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-save-avatar,
.btn-cancel-avatar {
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-save-avatar {
    background: var(--primary-gold, #ffd700);
    color: var(--primary-black, #000);
}

.btn-save-avatar:hover {
    background: #ffed4e;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.btn-cancel-avatar {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-cancel-avatar:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Change Avatar Button in Menu */
.change-avatar-btn {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-gold, #ffd700);
    color: var(--primary-black, #000);
    border: 2px solid rgba(10, 10, 10, 0.95);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.change-avatar-btn:hover {
    background: #ffed4e;
    transform: scale(1.1);
}

.user-avatar {
    position: relative;
    cursor: pointer;
}

.user-avatar:hover .change-avatar-btn {
    transform: scale(1.15);
}

/* Responsive */
@media (max-width: 768px) {
    .avatar-picker-content {
        max-width: 90vw;
        max-height: 90vh;
    }
    
    .avatar-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 0.75rem;
    }
    
    .avatar-picker-header h2 {
        font-size: 1.25rem;
    }
    
    .avatar-preview {
        width: 100px;
        height: 100px;
    }
}

/* Loading State */
.avatar-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--primary-gold, #ffd700);
}

.avatar-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 215, 0, 0.2);
    border-top-color: var(--primary-gold, #ffd700);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
