/* Loading Fixes untuk mencegah masalah "mutar2" */

/* Improved loading spinner animation */
.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

/* Smooth spin animation without stuttering */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Prevent layout shift during loading */
.content-card {
    min-height: 200px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading skeleton untuk placeholder yang lebih baik */
.loading-skeleton {
    background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Global loading indicator styles */
#global-loading-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#global-loading-indicator i {
    margin-right: 8px;
}

/* Error state styles */
.error-state {
    text-align: center;
    padding: 2rem;
    color: #ef4444;
}

.error-state i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

/* Retry button styles */
.retry-button {
    margin-top: 1rem;
    padding: 8px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.retry-button:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.retry-button:active {
    transform: translateY(0);
}

/* Prevent infinite loading states */
.loading-container {
    position: relative;
    overflow: hidden;
}

.loading-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 1;
    pointer-events: none;
}

/* Image loading improvements */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loaded {
    opacity: 1;
}

/* Prevent layout shift for images */
.content-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-color: #374151;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
    
    #global-loading-indicator {
        top: 10px;
        right: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .content-card {
        min-height: 150px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .loading-skeleton {
        background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
    }
    
    .error-state {
        color: #f87171;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
        border-top-color: #3b82f6;
    }
    
    .loading-skeleton {
        animation: none;
        background: #374151;
    }
    
    .content-card {
        transition: none;
    }
}
