/* ==========================================================================
   Mobile Image Optimizations for SOMASUQ
   ========================================================================== */

/* Image Containers */
@media (max-width: 768px) {
    
    /* Responsive Images */
    .img-responsive {
        max-width: 100% !important;
        height: auto !important;
        border-radius: 8px !important;
        transition: all 0.3s ease !important;
    }
    
    .img-fluid {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Image Gallery Mobile */
    .image-gallery-mobile {
        position: relative !important;
        overflow: hidden !important;
        border-radius: 12px !important;
        background: #f8f9fa !important;
        margin-bottom: 1rem !important;
    }
    
    .image-gallery-container {
        position: relative !important;
        width: 100% !important;
        height: 250px !important;
        overflow: hidden !important;
    }
    
    .image-gallery-slide {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        opacity: 0 !important;
        transition: opacity 0.5s ease !important;
    }
    
    .image-gallery-slide.active {
        opacity: 1 !important;
    }
    
    .image-gallery-slide img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
    }
    
    /* Gallery Navigation */
    .image-gallery-nav {
        position: absolute !important;
        bottom: 15px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        display: flex !important;
        gap: 8px !important;
        z-index: 10 !important;
    }
    
    .image-gallery-dot {
        width: 10px !important;
        height: 10px !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.5) !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        border: 2px solid rgba(255, 255, 255, 0.8) !important;
    }
    
    .image-gallery-dot.active {
        background: white !important;
        transform: scale(1.2) !important;
    }
    
    /* Gallery Controls */
    .image-gallery-prev,
    .image-gallery-next {
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        background: rgba(0, 0, 0, 0.5) !important;
        color: white !important;
        border: none !important;
        width: 40px !important;
        height: 40px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 1.2rem !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        z-index: 10 !important;
        opacity: 0.8 !important;
    }
    
    .image-gallery-prev {
        left: 15px !important;
    }
    
    .image-gallery-next {
        right: 15px !important;
    }
    
    .image-gallery-prev:hover,
    .image-gallery-next:hover {
        opacity: 1 !important;
        transform: translateY(-50%) scale(1.1) !important;
    }
    
    /* Gallery Counter */
    .image-gallery-counter {
        position: absolute !important;
        top: 15px !important;
        right: 15px !important;
        background: rgba(0, 0, 0, 0.7) !important;
        color: white !important;
        padding: 0.25rem 0.75rem !important;
        border-radius: 15px !important;
        font-size: 0.8rem !important;
        font-weight: 500 !important;
        z-index: 10 !important;
    }
    
    /* Image Placeholder */
    .image-placeholder {
        width: 100% !important;
        height: 250px !important;
        background: linear-gradient(135deg, #f8f9fa, #e9ecef) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #6c757d !important;
        font-size: 3rem !important;
        border-radius: 12px !important;
        margin-bottom: 1rem !important;
    }
    
    .image-placeholder.small {
        height: 150px !important;
        font-size: 2rem !important;
    }
    
    .image-placeholder.large {
        height: 350px !important;
        font-size: 4rem !important;
    }
    
    /* Image Loading */
    .image-loading {
        position: relative !important;
        overflow: hidden !important;
    }
    
    .image-loading::before {
        content: '' !important;
        position: absolute !important;
        top: 0 !important;
        left: -100% !important;
        width: 100% !important;
        height: 100% !important;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent) !important;
        animation: loading-shimmer 1.5s infinite !important;
        z-index: 1 !important;
    }
    
    @keyframes loading-shimmer {
        0% { left: -100%; }
        100% { left: 100%; }
    }
    
    /* Image Error State */
    .image-error {
        width: 100% !important;
        height: 250px !important;
        background: #f8d7da !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        color: #721c24 !important;
        border-radius: 12px !important;
        margin-bottom: 1rem !important;
    }
    
    .image-error i {
        font-size: 2.5rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .image-error span {
        font-size: 0.9rem !important;
        text-align: center !important;
    }
    
    /* Avatar Images */
    .avatar-mobile {
        width: 50px !important;
        height: 50px !important;
        border-radius: 50% !important;
        object-fit: cover !important;
        border: 2px solid #e9ecef !important;
        background: #f8f9fa !important;
    }
    
    .avatar-mobile.small {
        width: 35px !important;
        height: 35px !important;
    }
    
    .avatar-mobile.large {
        width: 80px !important;
        height: 80px !important;
    }
    
    .avatar-mobile.xl {
        width: 120px !important;
        height: 120px !important;
    }
    
    /* Profile Image Upload */
    .profile-image-upload {
        position: relative !important;
        display: inline-block !important;
        margin-bottom: 1rem !important;
    }
    
    .profile-image-preview {
        width: 120px !important;
        height: 120px !important;
        border-radius: 50% !important;
        object-fit: cover !important;
        border: 4px solid #e9ecef !important;
        background: #f8f9fa !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #6c757d !important;
        font-size: 2rem !important;
    }
    
    .profile-image-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0, 0, 0, 0.5) !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
        cursor: pointer !important;
    }
    
    .profile-image-upload:hover .profile-image-overlay {
        opacity: 1 !important;
    }
    
    .profile-image-overlay i {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    .profile-image-input {
        position: absolute !important;
        opacity: 0 !important;
        width: 100% !important;
        height: 100% !important;
        cursor: pointer !important;
    }
    
    /* Image Grid */
    .image-grid-mobile {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.5rem !important;
        margin-bottom: 1rem !important;
    }
    
    .image-grid-mobile.three-cols {
        grid-template-columns: 1fr 1fr 1fr !important;
    }
    
    .image-grid-mobile.four-cols {
        grid-template-columns: 1fr 1fr !important;
    }
    
    .image-grid-item {
        position: relative !important;
        aspect-ratio: 1 !important;
        overflow: hidden !important;
        border-radius: 8px !important;
        background: #f8f9fa !important;
    }
    
    .image-grid-item img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        transition: transform 0.3s ease !important;
    }
    
    .image-grid-item:hover img {
        transform: scale(1.05) !important;
    }
    
    .image-grid-overlay {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0, 0, 0, 0.5) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
        color: white !important;
        font-size: 1.2rem !important;
        font-weight: 600 !important;
    }
    
    .image-grid-item:hover .image-grid-overlay {
        opacity: 1 !important;
    }
    
    /* Image Zoom */
    .image-zoom-container {
        position: relative !important;
        overflow: hidden !important;
        cursor: zoom-in !important;
    }
    
    .image-zoom-container.zoomed {
        cursor: zoom-out !important;
    }
    
    .image-zoom-container img {
        transition: transform 0.3s ease !important;
    }
    
    .image-zoom-container.zoomed img {
        transform: scale(2) !important;
    }
    
    /* Image Lightbox */
    .image-lightbox {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0, 0, 0, 0.9) !important;
        z-index: 9999 !important;
        display: none !important;
        align-items: center !important;
        justify-content: center !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: all 0.3s ease !important;
    }
    
    .image-lightbox.show {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .image-lightbox-content {
        position: relative !important;
        max-width: 90% !important;
        max-height: 90% !important;
    }
    
    .image-lightbox-content img {
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 8px !important;
    }
    
    .image-lightbox-close {
        position: absolute !important;
        top: -40px !important;
        right: 0 !important;
        background: none !important;
        border: none !important;
        color: white !important;
        font-size: 2rem !important;
        cursor: pointer !important;
        padding: 0.5rem !important;
        transition: all 0.3s ease !important;
    }
    
    .image-lightbox-close:hover {
        transform: scale(1.1) !important;
    }
    
    /* Image Lazy Loading */
    .image-lazy {
        opacity: 0 !important;
        transition: opacity 0.5s ease !important;
    }
    
    .image-lazy.loaded {
        opacity: 1 !important;
    }
    
    /* Image Filters */
    .image-filter-grayscale {
        filter: grayscale(100%) !important;
        transition: filter 0.3s ease !important;
    }
    
    .image-filter-grayscale:hover {
        filter: grayscale(0%) !important;
    }
    
    .image-filter-blur {
        filter: blur(2px) !important;
        transition: filter 0.3s ease !important;
    }
    
    .image-filter-blur:hover {
        filter: blur(0) !important;
    }
    
    .image-filter-sepia {
        filter: sepia(100%) !important;
        transition: filter 0.3s ease !important;
    }
    
    .image-filter-sepia:hover {
        filter: sepia(0%) !important;
    }
}

/* Extra Small Devices */
@media (max-width: 575.98px) {
    
    .image-gallery-container {
        height: 200px !important;
    }
    
    .image-placeholder {
        height: 200px !important;
        font-size: 2.5rem !important;
    }
    
    .image-placeholder.small {
        height: 120px !important;
        font-size: 1.5rem !important;
    }
    
    .image-placeholder.large {
        height: 280px !important;
        font-size: 3.5rem !important;
    }
    
    .image-error {
        height: 200px !important;
    }
    
    .image-error i {
        font-size: 2rem !important;
    }
    
    .profile-image-preview {
        width: 100px !important;
        height: 100px !important;
        font-size: 1.5rem !important;
    }
    
    .avatar-mobile {
        width: 40px !important;
        height: 40px !important;
    }
    
    .avatar-mobile.small {
        width: 30px !important;
        height: 30px !important;
    }
    
    .avatar-mobile.large {
        width: 60px !important;
        height: 60px !important;
    }
    
    .avatar-mobile.xl {
        width: 100px !important;
        height: 100px !important;
    }
    
    .image-grid-mobile.four-cols {
        grid-template-columns: 1fr 1fr !important;
    }
    
    .image-gallery-prev,
    .image-gallery-next {
        width: 35px !important;
        height: 35px !important;
        font-size: 1rem !important;
    }
    
    .image-gallery-dot {
        width: 8px !important;
        height: 8px !important;
    }
}

/* Performance Optimizations */
@media (max-width: 768px) {
    
    /* GPU Acceleration */
    .image-gallery-slide,
    .image-grid-item img,
    .image-zoom-container img {
        transform: translateZ(0) !important;
        backface-visibility: hidden !important;
    }
    
    /* Reduce Motion for Accessibility */
    @media (prefers-reduced-motion: reduce) {
        .image-gallery-slide,
        .image-grid-item img,
        .image-zoom-container img,
        .image-lazy {
            transition: none !important;
            animation: none !important;
        }
    }
    
    /* High Contrast Mode */
    @media (prefers-contrast: high) {
        .image-placeholder,
        .image-error {
            border: 2px solid currentColor !important;
        }
        
        .avatar-mobile {
            border-width: 3px !important;
        }
    }
    
    /* Dark Mode */
    @media (prefers-color-scheme: dark) {
        .image-placeholder {
            background: linear-gradient(135deg, #2d3748, #4a5568) !important;
            color: #a0aec0 !important;
        }
        
        .image-error {
            background: #742a2a !important;
            color: #fed7d7 !important;
        }
        
        .avatar-mobile {
            border-color: #4a5568 !important;
            background: #2d3748 !important;
        }
        
        .profile-image-preview {
            border-color: #4a5568 !important;
            background: #2d3748 !important;
            color: #a0aec0 !important;
        }
        
        .image-grid-item {
            background: #2d3748 !important;
        }
    }
}