/* ===== FASTTRACK IMAGE OPTIMIZATION & LAZY LOADING STYLES ===== */
/* Enterprise-grade image optimization with performance focus */

/* Base lazy loading styles */
.lazy-image {
    transition: opacity 0.3s ease, filter 0.3s ease;
    opacity: 0.1;
    filter: blur(5px);
}

.lazy-image.lazy-loading {
    opacity: 0.5;
    filter: blur(2px);
    background: linear-gradient(
        90deg,
        rgba(59, 130, 246, 0.1) 25%,
        rgba(59, 130, 246, 0.3) 50%,
        rgba(59, 130, 246, 0.1) 75%
    );
    background-size: 200% 100%;
    animation: imageShimmer 1.5s infinite;
}

.lazy-image.lazy-loaded {
    opacity: 1;
    filter: none;
    background: none;
    animation: none;
}

.lazy-image.image-error {
    opacity: 1;
    filter: none;
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
}

.lazy-image.image-error::after {
    content: '🖼️ Image loading...';
    text-align: center;
}

/* Background lazy loading styles */
.lazy-bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.3s ease, opacity 0.3s ease;
    opacity: 0.1;
}

.lazy-bg.lazy-loading {
    opacity: 0.5;
    background: linear-gradient(
        45deg,
        rgba(59, 130, 246, 0.1) 25%,
        transparent 25%,
        transparent 50%,
        rgba(59, 130, 246, 0.1) 50%,
        rgba(59, 130, 246, 0.1) 75%,
        transparent 75%,
        transparent
    );
    background-size: 40px 40px;
    animation: bgShimmer 2s linear infinite;
}

.lazy-bg.lazy-loaded {
    opacity: 1;
    background: none;
    animation: none;
}

/* Shimmer loading animations */
@keyframes imageShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes bgShimmer {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 40px 40px;
    }
}

/* Progressive image loading */
.progressive-image {
    position: relative;
    overflow: hidden;
}

.progressive-image .placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 0.875rem;
    z-index: 1;
}

.progressive-image .main-image {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.progressive-image .main-image.loaded + .placeholder {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Responsive image containers */
.image-container {
    position: relative;
    overflow: hidden;
    background: #f9fafb;
}

.image-container--hero {
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.image-container--card {
    aspect-ratio: 4 / 3;
    border-radius: 8px;
}

.image-container--thumbnail {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
}

.image-container--banner {
    aspect-ratio: 21 / 9;
    border-radius: 12px;
}

/* WebP support detection styles */
.webp .image-fallback {
    display: none;
}

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

/* Performance-optimized image grid */
.image-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.image-grid--masonry {
    columns: 3;
    column-gap: 1rem;
}

.image-grid--masonry .image-item {
    break-inside: avoid;
    margin-bottom: 1rem;
}

/* Critical images (no lazy loading) */
.critical-image {
    opacity: 1;
    filter: none;
}

/* Print optimization */
@media print {
    .lazy-image:not(.lazy-loaded) {
        opacity: 1 !important;
        filter: none !important;
    }
    
    .lazy-bg:not(.lazy-loaded) {
        opacity: 1 !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .lazy-image.lazy-loading {
        border: 2px solid currentColor;
        background: none;
    }
    
    .image-error {
        background: transparent !important;
        border: 2px solid currentColor !important;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .lazy-image,
    .lazy-bg,
    .progressive-image .placeholder {
        transition: none !important;
        animation: none !important;
    }
    
    .lazy-image.lazy-loading {
        animation: none;
        background: #f3f4f6;
    }
    
    .lazy-bg.lazy-loading {
        animation: none;
        background: #f3f4f6;
    }
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .image-container--hero {
        aspect-ratio: 4 / 3;
        border-radius: 12px;
    }
    
    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .image-grid--masonry {
        columns: 2;
    }
    
    /* Reduce animation complexity on mobile */
    .lazy-image.lazy-loading {
        background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
        background-size: 100% 100%;
        animation: none;
    }
}

@media (max-width: 480px) {
    .image-grid {
        grid-template-columns: 1fr;
    }
    
    .image-grid--masonry {
        columns: 1;
    }
    
    .image-container--hero {
        aspect-ratio: 3 / 2;
        border-radius: 8px;
    }
}

/* Loading performance indicators */
.image-performance-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10000;
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-performance-indicator.visible {
    opacity: 1;
}

/* Image optimization badges */
.image-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(16, 185, 129, 0.9);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    z-index: 10;
}

.image-badge--webp {
    background: rgba(59, 130, 246, 0.9);
}

.image-badge--optimized {
    background: rgba(16, 185, 129, 0.9);
}

.image-badge--error {
    background: rgba(239, 68, 68, 0.9);
}

/* Accessibility enhancements */
.lazy-image:focus,
.image-container:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Medical industry specific image styles */
.medical-image {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
}

.medical-image--certificate {
    border: 2px solid #10b981;
    background: linear-gradient(135deg, #f0fdf4, #f9fafb);
}

.medical-image--compliance {
    border: 2px solid #3b82f6;
    background: linear-gradient(135deg, #eff6ff, #f9fafb);
}

/* Hero section image enhancements */
.hero-image-container {
    position: relative;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.hero-image-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(16, 185, 129, 0.1));
    z-index: 1;
}

.hero-image-container .lazy-image {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: cover;
}