/* Image Optimization and Fallbacks - Enhanced Version */

/* Default Image Placeholder for the Hero Section */
.hero-section {
    background-image: linear-gradient(135deg, #003366 0%, #001e3c 100%);
}

/* Lazy loading and performance optimization */
img {
    max-width: 100%;
    height: auto;
    min-height: 100px;
}

/* Critical images styling */
.logo-img {
    max-height: 60px;
    width: auto;
}

.hero-background {
    object-fit: cover;
    object-position: center;
}

/* Handle broken images with a nice fallback */
img::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f5f5f7;
}

img::after {
    content: "⚠️ Imagen no disponible";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1rem;
    color: #666;
    text-align: center;
    padding: 1rem;
    background: rgba(255,255,255,0.9);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Image fallback styles */
.placeholder-image {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    text-align: center;
    border-radius: 12px;
    min-height: 200px;
}

/* Progressive image enhancement */
.progressive-image {
    background: var(--light-gray);
    transition: opacity 0.3s ease;
}

.progressive-image[data-loaded="false"] {
    opacity: 0.8;
}

.progressive-image[data-loaded="true"] {
    opacity: 1;
}

/* Responsive image containers */
.image-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

.image-container::before {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    z-index: 1;
    pointer-events: none;
}

.image-container:hover::before {
    transform: translateX(100%);
}

/* Team images optimization */
.team-photo {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 50%;
    background: var(--light-gray);
    position: relative;
}

.team-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.team-photo:hover img {
    transform: scale(1.1);
}

/* About section image improvements */
.about-image img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    transition: transform 0.5s ease;
}

/* Error state for images */
img[data-error="true"] {
    background: var(--light-gray);
    border: 2px dashed var(--primary);
    color: var(--primary);
    font-size: 0.9rem;
    padding: 2rem;
    text-align: center;
}

/* Optimize for different screen densities */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    .high-res-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

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

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

/* Accessibility improvements */
img[alt=""],
img:not([alt]) {
    opacity: 0.8;
}

/* Dark mode support for images */
@media (prefers-color-scheme: dark) {
    img {
        filter: brightness(0.9) contrast(1.1);
    }
    
    .placeholder-image {
        background: linear-gradient(135deg, #2C3E50, #34495E);
    }
    
    img::before {
        background-color: #2C3E50;
    }
    
    img::after {
        color: #ECF0F1;
        background: rgba(44, 62, 80, 0.9);
    }
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    img,
    .progressive-image,
    .team-photo img,
    .about-image img {
        transition: none;
    }
    
    .image-container::before {
        animation: none;
        transform: none;
    }
}
