/* Image optimization for mobile devices */

/* General image rules */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Override for content images that should be full width */
.content img {
    width: 100% !important;
    max-width: none !important;
}

/* Додаткові стилі для ідеального центрування */
.content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.content img {
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Full width images that break out of container */
.content img[width="1200"] {
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    display: block;
    margin: 0.75rem auto !important;
    position: relative;
    left: 50% !important;
    right: 50% !important;
    transform: translateX(-50%) !important;
    text-align: center;
}

.content img[width="1300"] {
    width: 100% !important;
    max-width: 100% !important;
    height: auto;
    display: block;
    margin: 0.75rem auto !important;
    position: relative;
    left: 50% !important;
    right: 50% !important;
    transform: translateX(-50%) !important;
    text-align: center;
}

.content img[width="1500"] {
    width: 100vw !important;
    max-width: none !important;
    margin-left: calc(-50vw + 50%) !important;
    margin-right: calc(-50vw + 50%) !important;
    position: relative;
    left: 50%;
    right: 50%;
    transform: translateX(-50%);
}

/* Full width container for images */
.full-width-container {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0;
}

.full-width-container img {
    width: 100% !important;
    max-width: none !important;
    height: auto;
    display: block;
}

/* Hero section background images */
.hero-section[style*="background-image"] {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: scroll !important;
}

/* Mobile hero section */
@media (max-width: 768px) {
    .hero-section {
        min-height: 60vh !important;
        background-size: cover !important;
        background-position: center !important;
    }
    
    .hero-section[style*="background-image"] {
        background-size: cover !important;
        background-position: center !important;
        background-attachment: scroll !important;
    }
    
    /* Hero overlay for better text readability */
    .hero-overlay {
        background-color: rgba(0, 0, 0, 0.4) !important;
    }
}

/* Extra small devices */
@media (max-width: 576px) {
    .hero-section {
        min-height: 50vh !important;
    }
    
    .hero-overlay {
        background-color: rgba(0, 0, 0, 0.5) !important;
    }
}

/* Landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        min-height: 40vh !important;
    }
}

/* News card images */
.news-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

@media (max-width: 768px) {
    .news-card img {
        height: 150px !important;
    }
}

@media (max-width: 576px) {
    .news-card img {
        height: 120px !important;
    }
}

/* Feature card images */
.feature-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

@media (max-width: 768px) {
    .feature-card img {
        height: 120px !important;
    }
}

@media (max-width: 576px) {
    .feature-card img {
        height: 100px !important;
    }
}

/* Team member images */
.team-member img,
.card .card-img-top[style*="max-height"] {
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 8px 8px 0 0;
    max-height: 400px !important;
}

/* Team member card specific styles */
.card .card-img-top {
    width: 100% !important;
    height: auto !important;
    object-fit: cover !important;
    border-radius: 8px 8px 0 0;
    max-height: 400px !important;
    transition: transform 0.3s ease;
}

/* Protect team member images from JavaScript resizing */
.card .card-img-top[style*="max-height"] {
    height: auto !important;
    max-height: inherit !important;
}

/* Override any JavaScript height settings for team member images */
.card .card-img-top[style*="max-height"] {
    height: auto !important;
}

/* Force natural height for team member images */
.card .card-img-top[style*="max-height"] {
    height: auto !important;
    width: 100% !important;
    object-fit: cover !important;
}

/* Additional protection for team member images */
.card .card-img-top[style*="max-height"] {
    height: auto !important;
    max-height: none !important;
}

/* Override any inline styles for team member images */
.card .card-img-top[style*="max-height"] {
    height: auto !important;
    width: 100% !important;
    object-fit: cover !important;
    max-height: 400px !important;
}

.card:hover .card-img-top {
    transform: scale(1.02);
}

@media (max-width: 768px) {
    .team-member img,
    .card .card-img-top[style*="max-height"] {
        max-height: 350px !important;
    }
    
    .card .card-img-top {
        max-height: 350px !important;
    }
}

@media (max-width: 576px) {
    .team-member img,
    .card .card-img-top[style*="max-height"] {
        max-height: 300px !important;
    }
    
    .card .card-img-top {
        max-height: 300px !important;
    }
}

/* General card images */
.card-img-top {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    max-height: 400px;
}

@media (max-width: 768px) {
    .card-img-top {
        max-height: 350px !important;
    }
}

@media (max-width: 576px) {
    .card-img-top {
        max-height: 300px !important;
    }
}

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

@media (max-width: 768px) {
    .logo img {
        max-height: 50px !important;
    }
}

@media (max-width: 576px) {
    .logo img {
        max-height: 40px !important;
    }
}

/* Icon images */
.icon img {
    max-width: 40px;
    height: auto;
}

@media (max-width: 768px) {
    .icon img {
        max-width: 35px !important;
    }
}

@media (max-width: 576px) {
    .icon img {
        max-width: 30px !important;
    }
}

/* Background images optimization */
[style*="background-image"] {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: scroll !important;
}

/* Lazy loading for images */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Image hover effects */
.card img {
    transition: transform 0.3s ease;
}

.card:hover img {
    transform: scale(1.05);
}

/* Image loading placeholder */
.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;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .hero-section[style*="background-image"] {
        background-image: none !important;
        background-color: #f8f9fa !important;
    }
    
    img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }
}
