/* Image Optimization and Lazy Loading Styles */

/* Responsive Image Container */
.responsive-image {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
}

.responsive-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s ease;
}

/* Lazy Loading States */
.lazy-image {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.lazy-image.loaded {
    opacity: 1;
}

.lazy-image.loading {
    opacity: 0.5;
}

/* Loading Placeholder */
.image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-shimmer 2s infinite;
    color: #999;
    font-size: 0.875rem;
    min-height: 200px;
}

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

/* Error State */
.image-error {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    color: #6c757d;
    font-size: 0.875rem;
    min-height: 200px;
}

.image-error::before {
    content: "⚠️ ";
    margin-right: 0.5rem;
}

/* WebP Support Detection */
.webp .webp-image {
    display: block;
}

.webp .fallback-image {
    display: none;
}

.no-webp .webp-image {
    display: none;
}

.no-webp .fallback-image {
    display: block;
}

/* Progressive Image Enhancement */
.progressive-image {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.progressive-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 25%,
        rgba(255,255,255,0.4) 50%,
        transparent 75%
    );
    background-size: 200% 100%;
    animation: loading-shimmer 1.5s infinite;
    z-index: 1;
}

.progressive-image.loaded::before {
    display: none;
}

/* Optimized Icon Display */
.icon-optimized {
    width: 24px;
    height: 24px;
    display: inline-block;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* High DPI Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .icon-optimized {
        background-image: var(--icon-2x);
    }
}

@media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi) {
    .icon-optimized {
        background-image: var(--icon-3x);
    }
}

/* Performance Optimizations */
.performance-image {
    content-visibility: auto;
    contain-intrinsic-size: 300px 200px;
}

/* Aspect Ratio Containers */
.aspect-ratio-16-9 {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    overflow: hidden;
}

.aspect-ratio-4-3 {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 */
    overflow: hidden;
}

.aspect-ratio-1-1 {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 1:1 */
    overflow: hidden;
}

.aspect-ratio-16-9 img,
.aspect-ratio-4-3 img,
.aspect-ratio-1-1 img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Optimized Dashboard Mockup Enhancement */
.dashboard-mockup {
    /* Add subtle optimizations to existing mockup */
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.dashboard-mockup .chart-bars {
    /* Optimize chart animation performance */
    transform: translateZ(0);
}

.dashboard-mockup .bar {
    /* Smooth bar animations */
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: height;
}

/* Fade-in animation for images */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.image-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

/* Print Optimizations */
@media print {
    .lazy-image,
    .progressive-image {
        opacity: 1 !important;
    }

    .image-placeholder,
    .loading-shimmer {
        display: none !important;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .lazy-image,
    .progressive-image,
    .image-fade-in {
        transition: none !important;
        animation: none !important;
    }

    .loading-shimmer {
        animation: none !important;
        background: #f0f0f0;
    }
}
