/**
 * Image Thumbnail System - Loading States & Effects
 * Supports lazy loading with blur effect and smooth transitions
 */

/* Main slideshow image blur effect during loading */
#main-device-image.blur-sm {
    filter: blur(8px);
    transition: filter 0.3s ease;
}

#main-device-image:not(.blur-sm) {
    filter: blur(0);
}

/* Loading spinner overlay */
#image-loading-spinner {
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#image-loading-spinner i {
    filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
}

/* Thumbnail container spacing for date labels */
.device-profile-thumbnail {
    margin-bottom: 1.5rem; /* Space for date label below */
}

/* Thumbnail image lazy loading state */
.device-profile-thumbnail img {
    transition: opacity 0.3s ease;
}

.device-profile-thumbnail img.loading {
    opacity: 0.5;
}

/* Thumbnail date label styling */
.device-profile-thumbnail .absolute.-bottom-5 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 4rem; /* 16 * 4 = 64px to match thumbnail width */
}

/* Hover effects for thumbnails */
.device-profile-thumbnail:hover {
    transform: translateY(-2px);
    transition: transform 0.2s ease;
}

/* Active thumbnail border animation */
.device-profile-thumbnail .border-blue-500 {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Upload date badge in main slideshow */
.absolute.top-3.left-3 {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Smooth fade-in for images */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#main-device-image {
    animation: fadeIn 0.3s ease-in;
}

/* Responsive adjustments for mobile */
@media (max-width: 768px) {
    .device-profile-thumbnail {
        margin-bottom: 1.25rem;
    }

    .device-profile-thumbnail .absolute.-bottom-5 {
        font-size: 0.65rem;
    }

    #image-loading-spinner i {
        font-size: 2.5rem;
    }
}

/* Dark mode optimizations */
.dark #image-loading-spinner i {
    filter: drop-shadow(0 0 10px rgba(96, 165, 250, 0.7));
}

.dark .device-profile-thumbnail .border-blue-500 {
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.3);
}

/* Preload spinner for thumbnail grid */
.device-profile-thumbnail.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top-color: rgb(59, 130, 246);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Fallback for browsers without backdrop-filter */
@supports not (backdrop-filter: blur(8px)) {
    .absolute.top-3.left-3 {
        background-color: rgba(0, 0, 0, 0.8);
    }
}
