/* ============================================================================
   ADVANCED IMAGE LOADING ANIMATIONS
   ============================================================================ */

/* Base Loading Container */
.loading-container {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
}

.image-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.image-loader.hiding {
    opacity: 0;
    transform: scale(0.95);
}

.lazy-image {
    opacity: 0;
    transition: opacity 0.5s ease;
    position: relative;
    z-index: 1;
}

.lazy-image.loaded {
    opacity: 1;
}

/* ============================================================================
   SHIMMER LOADING ANIMATION
   ============================================================================ */
.shimmer-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

.shimmer-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.8rem;
}

.shimmer-box {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.shimmer-box.main {
    flex: 1;
    min-height: 120px;
}

.shimmer-lines {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shimmer-line {
    height: 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.shimmer-line.short {
    width: 60%;
}

.shimmer-box::before,
.shimmer-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shimmer-wave 2s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes shimmer-wave {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ============================================================================
   PULSE LOADING ANIMATION
   ============================================================================ */
.pulse-loader {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.pulse-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-circle {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: pulse-beat 2s infinite;
    position: relative;
    z-index: 2;
}

.pulse-waves {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.wave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-wave 2s infinite;
}

.wave:nth-child(2) { animation-delay: 0.5s; }
.wave:nth-child(3) { animation-delay: 1s; }

@keyframes pulse-beat {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes pulse-wave {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

/* ============================================================================
   SKELETON LOADING ANIMATION
   ============================================================================ */
.skeleton-loader {
    background: #f8f9fa;
}

.skeleton-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
}

.skeleton-image {
    flex: 1;
    min-height: 120px;
    background: #e9ecef;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.skeleton-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.skeleton-line {
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.skeleton-line.short {
    width: 65%;
}

.skeleton-image::before,
.skeleton-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: skeleton-wave 2.5s infinite;
}

@keyframes skeleton-wave {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ============================================================================
   IMAGE TYPE SPECIFIC STYLES
   ============================================================================ */

/* Category Image Loading */
.category-image-container {
    width: 100%;
    height: 330px;
    border-radius: 16px 16px 0 0;
}

.category-image-container .image-loader {
    border-radius: 16px 16px 0 0;
}

/* Item Image Loading */
.item-image-container {
    width: 100%;
    height: 300px;
    border-radius: 16px 16px 0 0;
}

.item-image-container .image-loader {
    border-radius: 16px 16px 0 0;
}

/* Logo Image Loading */
.logo-image-container {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    margin: 0 auto;
}

.logo-image-container .image-loader {
    border-radius: 50%;
}

.logo-image-container .pulse-circle {
    width: 40px;
    height: 40px;
}

/* ============================================================================
   ERROR STATES
   ============================================================================ */
.image-error {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    opacity: 0.7;
    border-radius: 16px;
}

.image-placeholder {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    opacity: 0.9;
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */
@media (max-width: 768px) {
    .category-image-container {
        height: 250px;
    }
    
    .item-image-container {
        height: 220px;
    }
    
    .logo-image-container {
        width: 150px;
        height: 150px;
    }
    
    .shimmer-content,
    .skeleton-content {
        padding: 0.8rem;
        gap: 0.6rem;
    }
    
    .pulse-circle {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .category-image-container,
    .item-image-container {
        height: 200px;
    }
    
    .logo-image-container {
        width: 120px;
        height: 120px;
    }
    
    .pulse-circle {
        width: 40px;
        height: 40px;
    }
}

/* ============================================================================
   PERFORMANCE OPTIMIZATIONS
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
    .shimmer-loader,
    .shimmer-box::before,
    .shimmer-line::before,
    .skeleton-image::before,
    .skeleton-line::before,
    .pulse-circle,
    .wave {
        animation: none;
    }
    
    .pulse-loader {
        background: var(--primary-color);
    }
    
    .pulse-content::after {
        content: '⏳';
        font-size: 2rem;
        color: white;
    }
}

/* ===== ENHANCED IMAGE LOADING WITH CENTERED 3D LOGO ===== */

.image-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: inherit;
}

/* ===== SHIMMER LOADING (Categories) ===== */
.shimmer-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 50%, #f3f4f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.shimmer-loader.hiding {
    opacity: 0;
    transform: scale(0.95);
}

.shimmer-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.1) 25%, 
        rgba(255, 255, 255, 0.2) 50%, 
        rgba(255, 255, 255, 0.1) 75%);
    background-size: 200% 100%;
    animation: shimmerBg 2s infinite;
}

@keyframes shimmerBg {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ===== PULSE LOADING (Items) ===== */
.pulse-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 50%, #f3f4f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.pulse-loader.hiding {
    opacity: 0;
    transform: scale(0.95);
}

.pulse-waves-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.pulse-wave-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulseWaveBg 3s infinite;
}

.pulse-wave-bg:nth-child(2) { animation-delay: 0.8s; }
.pulse-wave-bg:nth-child(3) { animation-delay: 1.6s; }

@keyframes pulseWaveBg {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* ===== CENTERED 3D LOGO (Same as main loading) ===== */
.loading-logo-container {
    position: relative;
    z-index: 4;
    perspective: 1000px;
}

.loading-logo-3d {
    width: 80px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    animation: logoFlip3d 2s infinite ease-in-out;
}

.loading-logo-face {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.3),
        0 4px 12px rgba(255, 255, 255, 0.2) inset;
}

.loading-logo-face.front {
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.25), 
        rgba(255, 255, 255, 0.1));
    transform: translateZ(15px);
}

.loading-logo-face.back {
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.15), 
        rgba(255, 255, 255, 0.05));
    transform: rotateY(180deg) translateZ(15px);
}

.loading-logo-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 50%;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

/* 3D Flip Animation (Same as main loading) */
@keyframes logoFlip3d {
    0% {
        transform: rotateY(0deg) rotateX(0deg);
    }
    25% {
        transform: rotateY(90deg) rotateX(10deg);
    }
    50% {
        transform: rotateY(180deg) rotateX(0deg);
    }
    75% {
        transform: rotateY(270deg) rotateX(-10deg);
    }
    100% {
        transform: rotateY(360deg) rotateX(0deg);
    }
}

/* Enhanced glow effect around logo */
.loading-logo-3d::before {
    content: '';
    position: absolute;
    top: -15px;
    left: -15px;
    right: -15px;
    bottom: -15px;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 0.15) 0%, 
        transparent 70%);
    border-radius: 50%;
    animation: logoGlow 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes logoGlow {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* ===== IMAGE STATES ===== */
.lazy-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.lazy-img.loaded {
    opacity: 1;
}

/* ===== ERROR STATES ===== */
.image-error {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    opacity: 0.8;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .loading-logo-3d {
        width: 70px;
        height: 70px;
    }
    
    .loading-logo-face {
        width: 70px;
        height: 70px;
        font-size: 1.8rem;
    }
    
    .loading-logo-img {
        width: 50px;
        height: 50px;
    }
    
    .pulse-wave-bg {
        width: 80px;
        height: 80px;
    }
}

@media (max-width: 480px) {
    .loading-logo-3d {
        width: 60px;
        height: 60px;
    }
    
    .loading-logo-face {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .loading-logo-img {
        width: 40px;
        height: 40px;
    }
    
    .pulse-wave-bg {
        width: 70px;
        height: 70px;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    .shimmer-background,
    .loading-logo-3d,
    .loading-logo-3d::before,
    .pulse-wave-bg {
        animation: none;
    }
    
    .loading-logo-container::after {
        content: '⏳';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 2rem;
        color: white;
    }
}

/* ===== PERFORMANCE OPTIMIZATION ===== */
.loading-logo-3d,
.loading-logo-face {
    will-change: transform;
}

.shimmer-background,
.pulse-wave-bg {
    will-change: background-position, transform;
}