/* ========================================
   WEBP OPTIMIZATIONS
   Estilos específicos para otimizações WebP
   ======================================== */

/* Hero slides com background WebP */
.hero-slide {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 1s ease-in-out;
}

/* Carregamento progressivo de imagens */
.hero-slide[data-bg-src] {
    background-color: #004574; /* Cor de fallback */
    background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4));
}

/* Estados de carregamento de imagem */
img {
    transition: opacity 0.3s ease;
}

img[loading="lazy"] {
    opacity: 0;
}

img.loaded,
img.webp-loaded,
img.image-loaded {
    opacity: 1;
}

/* Picture elements responsivos */
picture {
    display: block;
    width: 100%;
}

picture img {
    width: 100%;
    height: auto;
    display: block;
}

/* Otimizações específicas para WebP */
.webp .hero-slide[data-bg-webp] {
    /* JavaScript irá aplicar a imagem WebP via CSS */
}

.no-webp .hero-slide[data-bg-src] {
    /* JavaScript irá aplicar a imagem original via CSS */
}

/* Placeholder para imagens carregando */
.image-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Otimizações para diferentes tipos de imagem */
.team-photo,
.gallery-image,
.service-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Fallback para browsers sem suporte a WebP */
.no-webp picture source[type="image/webp"] {
    display: none;
}

/* Indicadores visuais para debug */
.webp-supported::after {
    content: "WebP ✓";
    position: fixed;
    top: 10px;
    right: 10px;
    background: green;
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    z-index: 9999;
    display: none;
}

.no-webp::after {
    content: "WebP ✗";
    position: fixed;
    top: 10px;
    right: 10px;
    background: orange;
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 12px;
    z-index: 9999;
    display: none;
}

/* Mostra indicadores apenas em modo debug */
body[class*="debug"] .webp-supported::after,
body[class*="debug"] .no-webp::after {
    display: block;
}

/* Otimizações para mobile */
@media (max-width: 768px) {
    /* Reduz qualidade de imagem em conexões lentas */
    @media (prefers-reduced-data: reduce) {
        picture source[type="image/webp"],
        img[src*=".webp"] {
            display: none;
        }
    }
    
    /* Otimiza carregamento em dispositivos com pouca memória */
    @media (max-device-memory: 1) {
        .hero-slide {
            background-attachment: scroll;
            background-size: cover;
        }
    }
}

/* Otimizações para telas de alta densidade */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .team-photo,
    .main-logo {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Animações suaves para carregamento de imagem */
@keyframes fadeInImage {
    from {
        opacity: 0;
        transform: scale(1.05);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-loaded,
.webp-loaded {
    animation: fadeInImage 0.5s ease-out;
}

/* Estilos para diferentes estados de carregamento */
.loading-image {
    filter: blur(5px);
    transform: scale(1.05);
    transition: all 0.3s ease;
}

.loading-image.loaded {
    filter: none;
    transform: scale(1);
}

/* Otimizações para impressão */
@media print {
    picture source[type="image/webp"] {
        display: none;
    }
    
    .hero-slide {
        background-image: none !important;
        background-color: #f5f5f5;
    }
}