/* Avatar Styles for Profile and User Cards */

/* ===== Avatar Container ===== */
.avatar-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}

.avatar-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--border-color);
    background: var(--bg-secondary);
    transition: all 0.3s ease;
}

.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: white;
    border: 4px solid var(--border-color);
    user-select: none;
}

/* ===== Edit Button Overlay ===== */
.avatar-edit-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #6366f1;
    color: white;
    border: 3px solid var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.avatar-edit-btn:hover {
    background: #4f46e5;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.avatar-edit-btn i {
    pointer-events: none;
}

/* ===== Avatar Upload Modal ===== */
.avatar-upload-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    /* ✅ iOS Safari fix: prevent blocking clicks when hidden */
    pointer-events: none;
}

.avatar-upload-modal.active {
    display: flex;
    /* ✅ Re-enable pointer events when modal is active */
    pointer-events: auto;
}

.avatar-upload-content {
    background: var(--bg-primary);
    border-radius: 24px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.avatar-upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.avatar-upload-header h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.avatar-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
}

.avatar-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: rotate(90deg);
}

/* ===== Preview Area ===== */
.avatar-preview-area {
    margin-bottom: 24px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 16px;
    text-align: center;
}

.avatar-preview-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--border-color);
    margin: 0 auto;
    display: block;
    background: var(--bg-tertiary);
}

.avatar-preview-placeholder {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    border: 2px dashed var(--border-color);
}

.avatar-preview-placeholder i {
    font-size: 48px;
    color: var(--text-tertiary);
}

.avatar-preview-placeholder p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
}

/* ===== Upload Controls ===== */
.avatar-upload-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.avatar-file-input-wrapper {
    position: relative;
}

.avatar-file-input {
    display: none;
}

.avatar-file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-weight: 600;
}

.avatar-file-label:hover {
    background: var(--bg-tertiary);
    border-color: #6366f1;
}

.avatar-file-label i {
    font-size: 20px;
    color: #6366f1;
}

/* ===== Upload Progress ===== */
.avatar-upload-progress {
    display: none;
    margin-top: 16px;
}

.avatar-upload-progress.active {
    display: block;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

/* ===== Action Buttons ===== */
.avatar-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.avatar-actions button {
    flex: 1;
    padding: 14px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.avatar-upload-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.avatar-upload-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.avatar-upload-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.avatar-cancel-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.avatar-cancel-btn:hover {
    background: var(--bg-tertiary);
}

.avatar-remove-btn {
    background: #ef4444;
    color: white;
}

.avatar-remove-btn:hover {
    background: #dc2626;
}

/* ===== Small Avatar Variants (for cards, lists) ===== */
.avatar-small {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
}

.avatar-placeholder-small {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    border: 2px solid var(--border-color);
}

.avatar-tiny {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
}

.avatar-placeholder-tiny {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    border: 2px solid var(--border-color);
}

/* ===== Dark Theme Adjustments ===== */
[data-theme="dark"] .avatar-image,
[data-theme="dark"] .avatar-placeholder {
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .avatar-edit-btn {
    border-color: var(--bg-primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.5);
}

[data-theme="dark"] .avatar-modal-close {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .avatar-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .avatar-upload-content {
        padding: 24px;
        width: 95%;
    }
    
    .avatar-preview-image,
    .avatar-preview-placeholder {
        width: 150px;
        height: 150px;
    }
    
    .avatar-actions {
        flex-direction: column;
    }
    
    .avatar-actions button {
        width: 100%;
    }
}

/* ===== Loading State ===== */
.avatar-loading {
    position: relative;
    overflow: hidden;
}

.avatar-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    to {
        left: 100%;
    }
}

[data-theme="dark"] .avatar-loading::after {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}
