/**
 * Wallpaper Optimization CSS
 * Ensures maximum quality for wallpaper backgrounds
 */

/* High quality wallpaper backgrounds */
body[style*="background-image"] {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: fixed !important;
    
    /* GPU acceleration for smooth rendering */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    
    /* High quality rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: high-quality;
    
    /* Prevent compression artifacts */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Remove any overlay when opacity is 0 - Multiple patterns to catch all cases */
body[style*="rgba(0, 0, 0, 0)"],
body[style*="rgba(0,0,0,0)"],
body[style*="rgba(0, 0, 0, 0.0)"],
body[style*="rgba(0,0,0,0.0)"] {
    background-image: var(--wallpaper-url) !important;
}

/* Force no overlay for zero opacity backgrounds */
body[style*="background-image: url("][style*="0)"] {
    background-blend-mode: normal !important;
    mix-blend-mode: normal !important;
}

/* Additional safeguard for opacity 0 scenarios */
body.auth-layout[style*="background-image"] {
    position: relative;
}

body.auth-layout[style*="background-image"]:before {
    content: none !important;
    display: none !important;
}

body.auth-layout[style*="background-image"]:after {
    content: none !important;
    display: none !important;
}

/* Ensure no additional filters or effects are applied */
body[style*="background-image"] * {
    backdrop-filter: none !important;
    filter: none !important;
}

/* Force high quality for specific wallpaper containers */
.wallpaper-container,
.register-wallpaper,
.partner-register-wallpaper {
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-attachment: fixed !important;
    
    /* High quality rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: high-quality;
}

/* Prevent any JavaScript or CSS from degrading wallpaper quality */
[data-wallpaper="true"] {
    image-rendering: high-quality !important;
    background-size: cover !important;
    transform: translateZ(0) !important;
}

/* Mobile optimization for wallpapers */
@media (max-width: 768px) {
    body[style*="background-image"] {
        background-attachment: scroll !important; /* Better performance on mobile */
        background-size: cover !important;
    }
}

/* High DPI/Retina display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body[style*="background-image"] {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: optimize-contrast;
        image-rendering: auto;
    }
}

/* Prevent layout shifts that could affect wallpaper quality */
html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Ensure glass effects don't interfere with wallpaper quality */
.glass-effect {
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    /* But don't apply any filters to the background wallpaper itself */
}

/* Remove any potential compression from CSS filters */
body[style*="background-image"]:before,
body[style*="background-image"]:after {
    content: none !important;
    display: none !important;
}

/* Specific register page wallpaper optimizations */
body.register-page[style*="background-image"] {
    background-position: center top !important;
    background-size: cover !important;
}

body.partner-register-page[style*="background-image"] {
    background-position: center !important;
    background-size: cover !important;
}

/* Ensure no gradient overlay persists when opacity is 0 */
body[style*="linear-gradient(rgba(0, 0, 0, 0)"] {
    background-image: url() !important; /* Force recalculation */
}

/* Force proper background handling for auth pages */
.auth-wallpaper-container {
    min-height: 100vh;
    background-attachment: fixed !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
}

/* Mobile-specific wallpaper adjustments */
@media (max-width: 768px) {
    body.register-page[style*="background-image"],
    body.partner-register-page[style*="background-image"] {
        background-attachment: scroll !important;
        background-position: center top !important;
        background-size: cover !important;
    }
}

/* Prevent any layout shifts on wallpaper pages */
body[style*="background-image"] #app {
    position: relative;
    z-index: 1;
}