/**
 * Skeleton Screen Loading Styles
 * Version: 1.0.0
 * Author: Kanews Theme
 */

/* Skeleton Base Styles */
.skeleton-loading {
    position: relative;
    overflow: hidden;
    background-color: #f0f0f0 !important;
}

.skeleton-loading::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.5) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: skeleton-shimmer 2s infinite;
    transform: translateX(-100%);
}

@keyframes skeleton-shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* Skeleton Elements */
.skeleton-text {
    display: inline-block;
    width: 100%;
    height: 1em;
    background-color: #e0e0e0;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-text::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.5) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: skeleton-shimmer 2s infinite;
    transform: translateX(-100%);
}

.skeleton-title {
    height: 1.5em;
    margin-bottom: 10px;
    width: 70%;
}

.skeleton-paragraph {
    margin-bottom: 8px;
}

.skeleton-paragraph:last-child {
    width: 80%;
}

.skeleton-image {
    background-color: #e0e0e0;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-image::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.5) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: skeleton-shimmer 2s infinite;
    transform: translateX(-100%);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e0e0e0;
    position: relative;
    overflow: hidden;
}

.skeleton-avatar::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.5) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: skeleton-shimmer 2s infinite;
    transform: translateX(-100%);
}

/* Skeleton Card */
.skeleton-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.skeleton-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.skeleton-card-header .skeleton-avatar {
    margin-right: 15px;
}

.skeleton-card-body .skeleton-image {
    width: 100%;
    height: 200px;
    margin-bottom: 15px;
}

/* Skeleton List */
.skeleton-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.skeleton-list-item {
    display: flex;
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
}

.skeleton-list-item:last-child {
    border-bottom: none;
}

.skeleton-list-item .skeleton-image {
    width: 80px;
    height: 80px;
    margin-right: 15px;
    flex-shrink: 0;
}

.skeleton-list-item-content {
    flex: 1;
}

/* Skeleton Grid */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.skeleton-grid-item {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.skeleton-grid-item .skeleton-image {
    width: 100%;
    height: 150px;
}

.skeleton-grid-item-content {
    padding: 15px;
}

/* Dark Mode Support */
body.dark-mode .skeleton-loading {
    background-color: #2a2a2a !important;
}

body.dark-mode .skeleton-text,
body.dark-mode .skeleton-image,
body.dark-mode .skeleton-avatar {
    background-color: #3a3a3a;
}

body.dark-mode .skeleton-card {
    background: #1a1a1a;
}

body.dark-mode .skeleton-list-item {
    border-bottom-color: #2a2a2a;
}

/* Fade In Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.skeleton-fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Hide Real Content While Loading */
.skeleton-container.loading > *:not(.skeleton-wrapper) {
    display: none;
}

.skeleton-container:not(.loading) > .skeleton-wrapper {
    display: none;
}

/* Hide infinite scroll loader by default - CRITICAL: Must be hidden initially */
.page-load-status,
.page-load-status *,
.loader-ellips,
.infinite-scroll-request {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    top: -9999px !important;
    left: -9999px !important;
}

/* Hide any kanews-loader that's not inside an active AJAX container */
.kanews-loader:not(.kanews-loader-active) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Show loader ONLY when infinite scroll is actively loading */
.infinite-scroll--loading .page-load-status,
.infinite-scroll--loading .infinite-scroll-request,
.infinite-scroll--loading .loader-ellips {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
}

/* Show loader when explicitly activated */
.page-load-status.infinite-scroll-request-active,
.page-load-status.infinite-scroll-request-active .infinite-scroll-request,
.page-load-status.infinite-scroll-request-active .loader-ellips {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
}

/* Responsive */
@media (max-width: 768px) {
    .skeleton-grid {
        grid-template-columns: 1fr;
    }

    .skeleton-list-item {
        flex-direction: column;
    }

    .skeleton-list-item .skeleton-image {
        width: 100%;
        height: 150px;
        margin-right: 0;
        margin-bottom: 10px;
    }
}