/* Skeleton Loader Styles for CLS Optimization */

/* Base skeleton animation */
@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }

    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 0%, #e0e0e0 50%, #f0f0f0 100%);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

.skeleton-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    min-height: 400px;
}

.skeleton-product-image {
    width: 100%;
    height: 250px;
    aspect-ratio: 1/1;
    margin-bottom: 15px;
}

.skeleton-product-title {
    width: 80%;
    height: 20px;
    margin-bottom: 10px;
}

.skeleton-product-price {
    width: 40%;
    height: 24px;
    margin-bottom: 10px;
}

.skeleton-product-button {
    width: 100%;
    height: 40px;
    margin-top: 10px;
}

/* Banner Skeleton */
.skeleton-banner {
    width: 100%;
    height: 400px;
    aspect-ratio: 16/5;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .skeleton-banner {
        height: 250px;
        aspect-ratio: 16/9;
    }
}

/* Product List Skeleton */
.skeleton-product-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
}

.skeleton-product-list-item {
    display: flex;
    gap: 15px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    min-height: 150px;
}

.skeleton-product-list-image {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.skeleton-product-list-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.skeleton-text-line {
    height: 16px;
    border-radius: 4px;
}

.skeleton-text-line.short {
    width: 60%;
}

.skeleton-text-line.medium {
    width: 80%;
}

.skeleton-text-line.long {
    width: 95%;
}

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

.skeleton-category-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.skeleton-category-image {
    width: 100%;
    height: 200px;
    aspect-ratio: 1/1;
}

.skeleton-category-title {
    width: 70%;
    height: 18px;
    margin: 15px;
}

/* Hide skeleton when content loads */
.skeleton-container.loaded {
    display: none;
}

/* Make sure the skeleton spans the full width when injected into a CSS grid
   container (e.g. the product list grid), instead of collapsing into a
   single grid column */
.productlist-product_list_container .skeleton-container {
    grid-column: 1 / -1;
}

/* Category header icon row skeleton (e.g. subcategory carousel) */
.skeleton-icon-row {
    display: flex;
    gap: 15px;
    width: 100%;
    overflow: hidden;
}

.skeleton-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 calc(100% / 7 - 13px);
}

.skeleton-icon-image {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    margin-bottom: 10px;
}

.skeleton-icon-label {
    width: 70%;
    height: 12px;
}

@media (max-width: 850px) {
    .skeleton-icon-item {
        flex: 0 0 calc(25% - 12px);
    }
}

@media (max-width: 650px) {
    .skeleton-icon-item {
        flex: 0 0 calc(33.33% - 12px);
    }
}

/* Side filter panel skeleton (price range + checkbox groups) */
.filter-skeleton-group {
    display: flex;
    flex-direction: column;
}

.filter-skeleton-group .filter {
    padding: 0.5rem 1rem 1rem 1rem;
}

.skeleton-filter-heading {
    width: 45%;
    height: 14px;
    margin-bottom: 10px;
}

.skeleton-filter-range {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    margin-bottom: 12px;
}

.skeleton-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.skeleton-checkbox {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border-radius: 3px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .skeleton-product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }

    .skeleton-product-card {
        min-height: 350px;
        padding: 10px;
    }

    .skeleton-product-image {
        height: 180px;
    }

    .skeleton-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }
}

/* Search Result Skeleton */
.skeleton-search-result {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.skeleton-search-image {
    width: 60px;
    height: 60px;
    display: inline-block;
    margin-right: 10px;
    vertical-align: middle;
}

.skeleton-search-text {
    display: inline-block;
    width: calc(100% - 80px);
    vertical-align: middle;
}

/* Widget Skeleton */
.skeleton-widget {
    min-height: 200px;
    width: 100%;
    border-radius: 8px;
    margin: 20px 0;
}

/* Utility classes */
.skeleton-circle {
    border-radius: 50%;
}

.skeleton-rounded {
    border-radius: 8px;
}

.skeleton-square {
    border-radius: 0;
}