/* Profile Image Styles - Enhanced Loading and Error Handling */

/* ======================================
   PROFILE IMAGE CONTAINER
   ====================================== */

.profile-picture-container {
    position: relative;
    display: inline-block;
    overflow: hidden;
}

.profile-picture-container img {
    transition: all 0.3s ease;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ======================================
   LOADING STATES
   ====================================== */

.img-loading {
    background: linear-gradient(90deg, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    opacity: 0.8;
}

.img-loaded {
    opacity: 1;
    transform: scale(1);
}

.img-error {
    opacity: 0.7;
    filter: grayscale(20%);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ======================================
   PLACEHOLDER STYLES
   ====================================== */

.profile-picture-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    border-radius: inherit;
    z-index: 1;
}

.placeholder-content {
    text-align: center;
    padding: 20px;
}

.placeholder-content svg {
    margin-bottom: 8px;
    opacity: 0.6;
}

.placeholder-text {
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.8;
}

/* ======================================
   IMPROVED DEFAULT PROFILE PICTURE
   ====================================== */

.profile-picture-container img[src*="default_profile_picture.svg"] {
    background: linear-gradient(135deg, #0F75BD 0%, #1E88E5 100%);
    padding: 20px;
    opacity: 0.9;
}

.profile-picture-container img[src*="default_profile_picture.svg"]:hover {
    transform: scale(1.05);
    opacity: 1;
}

/* ======================================
   ENHANCED IMAGE SIZES
   ====================================== */

.img-xxlg {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #dee2e6;
    transition: all 0.3s ease;
}

.img-xxlg:hover {
    border-color: #0F75BD;
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(15, 117, 189, 0.3);
}

.img-xlg {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #dee2e6;
}

.img-lg {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #dee2e6;
}

.img-md {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #dee2e6;
}

.img-sm {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #dee2e6;
}

.img-xs {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #dee2e6;
}

/* ======================================
   LOADING RING ANIMATION
   ====================================== */

.profile-picture-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0F75BD;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.profile-picture-container.loading::after {
    opacity: 1;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ======================================
   ERROR STATE STYLING
   ====================================== */

.profile-picture-container.error {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.profile-picture-container.error::before {
    content: '⚠️';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    z-index: 3;
    opacity: 0.7;
}

.profile-picture-container.error img {
    opacity: 0.3;
}

/* ======================================
   RESPONSIVE ADJUSTMENTS
   ====================================== */

@media (max-width: 768px) {
    .img-xxlg {
        width: 180px;
        height: 180px;
        border-width: 2px;
    }
    
    .img-xlg {
        width: 140px;
        height: 140px;
    }
    
    .profile-picture-container::after {
        width: 30px;
        height: 30px;
        margin-top: -15px;
        margin-left: -15px;
        border-width: 2px;
    }
}

@media (max-width: 480px) {
    .img-xxlg {
        width: 150px;
        height: 150px;
    }
    
    .img-xlg {
        width: 120px;
        height: 120px;
    }
    
    .placeholder-content {
        padding: 15px;
    }
    
    .placeholder-content svg {
        width: 30px;
        height: 30px;
    }
    
    .placeholder-text {
        font-size: 0.75rem;
    }
}

/* ======================================
   ACCESSIBILITY IMPROVEMENTS
   ====================================== */

.profile-picture-container img:focus {
    outline: 3px solid #0F75BD;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .profile-picture-container img,
    .img-loading,
    .profile-picture-container::after {
        animation: none;
        transition: none;
    }
}

/* ======================================
   DARK MODE SUPPORT
   ====================================== */

@media (prefers-color-scheme: dark) {
    .profile-picture-placeholder {
        background: linear-gradient(135deg, #343a40 0%, #495057 100%);
        color: #adb5bd;
    }
    
    .profile-picture-container img[src*="default_profile_picture.svg"] {
        background: linear-gradient(135deg, #0F75BD 0%, #1E88E5 100%);
    }
    
    .img-xxlg,
    .img-xlg,
    .img-lg,
    .img-md,
    .img-sm,
    .img-xs {
        border-color: #495057;
    }
    
    .img-xxlg:hover {
        border-color: #0F75BD;
        box-shadow: 0 4px 16px rgba(15, 117, 189, 0.4);
    }
    
    .profile-picture-container.error {
        background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    }
    
    .profile-picture-container::after {
        border-color: #495057;
        border-top-color: #0F75BD;
    }
}

/* ======================================
   HIGH CONTRAST MODE
   ====================================== */

@media (prefers-contrast: high) {
    .img-xxlg,
    .img-xlg,
    .img-lg,
    .img-md,
    .img-sm,
    .img-xs {
        border-width: 3px;
        border-color: #000000;
    }
    
    .profile-picture-container img:focus {
        outline-width: 4px;
        outline-color: #000000;
    }
}

/* ======================================
   PRINT STYLES
   ====================================== */

@media print {
    .profile-picture-container::after,
    .profile-picture-placeholder {
        display: none;
    }
    
    .img-loading {
        background: none;
        animation: none;
    }
}