/* Dynamic Background Styles */
.has-dynamic-background {
    position: relative;
    transition: background-image 0.5s ease-in-out;
}

.has-dynamic-background.dynamic-bg-loaded {
    animation: fadeInBackground 0.8s ease-in-out;
}

@keyframes fadeInBackground {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Overlay styles */
.has-dynamic-background::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.has-dynamic-background > * {
    position: relative;
    z-index: 2;
}

/* Optional refresh button styles */
.dynamic-bg-refresh {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.has-dynamic-background:hover .dynamic-bg-refresh {
    opacity: 1;
    pointer-events: auto;
}

.dynamic-bg-refresh:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .has-dynamic-background {
        background-attachment: scroll !important;
    }
    
    .dynamic-bg-refresh {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 767px) {
    .has-dynamic-background {
        background-attachment: scroll !important;
        background-position: center center !important;
    }
    
    .dynamic-bg-refresh {
        top: 5px;
        right: 5px;
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Loading state */
.has-dynamic-background.loading {
    background-color: #f0f0f0;
}

.has-dynamic-background.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 5;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Performance optimizations for mobile */
@media (max-width: 767px) {
    .has-dynamic-background {
        will-change: background-image;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
}