/* Avatar System Styles */

/* Avatar Grid for selection in User Settings */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
    padding: 8px;
}

.avatar-option {
    position: relative;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s ease;
    background: var(--sage-200, #f5f5f5);
}

.avatar-option:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.avatar-option:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--brand-focus, #E5B7B2);
}

.avatar-option.selected {
    border-color: var(--brand-primary, #7A9A8A);
    /* Fallback for browsers without color-mix support */
    box-shadow: 0 0 0 3px rgba(122, 154, 138, 0.3);
}

@supports (box-shadow: 0 0 0 3px color-mix(in srgb, #7A9A8A 30%, transparent)) {
    .avatar-option.selected {
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary, #7A9A8A) 30%, transparent);
    }
}

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

.avatar-option .avatar-checkmark {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--brand-primary, #7A9A8A);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.avatar-option.selected .avatar-checkmark {
    display: flex;
}

/* Hidden radio inputs for accessibility */
.avatar-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    margin: 0;
}

/* Avatar type toggle */
.avatar-type-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.avatar-type-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid var(--brand-border, #ddd);
    background: #fff;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.avatar-type-btn:hover {
    background: var(--sage-200, #f5f5f5);
}

.avatar-type-btn.active {
    background: var(--brand-primary, #7A9A8A);
    color: #fff;
    border-color: var(--brand-primary, #7A9A8A);
}

/* Avatar preview section */
.avatar-preview-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--sage-200, #f5f5f5);
    border-radius: 12px;
    margin-bottom: 16px;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--brand-primary, #7A9A8A);
    flex-shrink: 0;
}

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

.avatar-preview-info {
    flex-grow: 1;
}

.avatar-preview-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.avatar-preview-name {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Profile image display throughout the site */
.profile-avatar {
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

/* Size variants */
.profile-avatar-xs {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
}

.profile-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.profile-avatar-md {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
}

.profile-avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 1.4rem;
}

.profile-avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 1.8rem;
}

/* Initials fallback styling */
.profile-avatar-initials {
    font-weight: 600;
    color: #fff;
}

/* Responsive adjustments */
@media (max-width: 560px) {
    .avatar-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .avatar-option {
        border-width: 2px;
    }
    
    .avatar-type-toggle {
        flex-direction: column;
    }
    
    .avatar-type-btn {
        width: 100%;
        text-align: center;
    }
    
    .avatar-preview-section {
        flex-direction: column;
        text-align: center;
    }
}

/* User avatar sizes for member selection and settings pages */
.user-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    flex-shrink: 0;
}

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

.user-avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    overflow: hidden;
    flex-shrink: 0;
}

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