/**
 * Skeleton Loader CSS
 * Modern skeleton screens for loading states
 */

/* Base Skeleton Animation */
@keyframes skeleton-loading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    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;
}

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

/* Skeleton Variants */
.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 100%;
}

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

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

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
    width: 70%;
}

.skeleton-heading {
    height: 32px;
    margin-bottom: 16px;
    width: 50%;
}

.skeleton-avatar {
    border-radius: 50%;
    height: 48px;
    width: 48px;
}

.skeleton-avatar-large {
    height: 80px;
    width: 80px;
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: 8px;
}

.skeleton-badge {
    height: 24px;
    width: 80px;
    border-radius: 12px;
}

.skeleton-image {
    height: 200px;
    width: 100%;
    border-radius: 12px;
}

.skeleton-card-image {
    height: 180px;
    width: 100%;
    border-radius: 12px 12px 0 0;
}

/* Service Card Skeleton */
.skeleton-service-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.skeleton-service-card .skeleton-badge {
    margin-bottom: 1rem;
}

.skeleton-service-card .skeleton-title {
    margin-bottom: 0.75rem;
}

.skeleton-service-card .skeleton-text {
    margin-bottom: 0.5rem;
}

.skeleton-service-card .skeleton-button {
    margin-top: 1rem;
}

/* Product Card Skeleton */
.skeleton-product-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.skeleton-product-card .skeleton-card-image {
    margin-bottom: 0;
}

.skeleton-product-card .skeleton-content {
    padding: 1.5rem;
}

.skeleton-product-card .skeleton-badge {
    margin-bottom: 1rem;
}

.skeleton-product-card .skeleton-title {
    margin-bottom: 0.75rem;
}

.skeleton-product-card .skeleton-text {
    margin-bottom: 0.5rem;
}

.skeleton-product-card .skeleton-price {
    height: 32px;
    width: 100px;
    margin: 1rem 0;
}

.skeleton-product-card .skeleton-buttons {
    display: flex;
    gap: 0.5rem;
}

.skeleton-product-card .skeleton-button {
    flex: 1;
}

/* Cart Item Skeleton */
.skeleton-cart-item {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.skeleton-cart-item .skeleton-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

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

.skeleton-cart-item .skeleton-title {
    width: 60%;
    margin-bottom: 0.5rem;
}

.skeleton-cart-item .skeleton-text {
    width: 40%;
}

.skeleton-cart-item .skeleton-price {
    height: 24px;
    width: 80px;
}

/* Table Skeleton */
.skeleton-table {
    width: 100%;
    border-collapse: collapse;
}

.skeleton-table tr {
    border-bottom: 1px solid #f0f0f0;
}

.skeleton-table td {
    padding: 1rem;
}

.skeleton-table .skeleton-text {
    width: 100%;
}

/* List Skeleton */
.skeleton-list-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
}

.skeleton-list-item .skeleton-avatar {
    margin-right: 1rem;
}

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

.skeleton-list-item .skeleton-title {
    width: 70%;
    margin-bottom: 0.5rem;
}

.skeleton-list-item .skeleton-text {
    width: 50%;
}

/* Grid Skeleton */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Responsive Skeleton Grid */
@media (max-width: 768px) {
    .skeleton-grid {
        grid-template-columns: 1fr;
    }
    
    .skeleton-service-card,
    .skeleton-product-card {
        margin-bottom: 1rem;
    }
}

/* Loading Container */
.loading-container {
    position: relative;
    min-height: 200px;
}

.loading-container.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* Fade In Animation for Loaded Content */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

.fade-in-fast {
    animation: fadeIn 0.2s ease-out;
}

/* Skeleton Pulse (Alternative Animation) */
.skeleton-pulse {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #16a34a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mini Loading Spinner */
.mini-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f0f0f0;
    border-top: 2px solid #16a34a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Skeleton Dark Mode (Optional) */
.dark-mode .skeleton {
    background: linear-gradient(
        90deg,
        #2d2d2d 0%,
        #3a3a3a 20%,
        #2d2d2d 40%,
        #2d2d2d 100%
    );
}

/* Smooth Transitions */
.smooth-transition {
    transition: all 0.3s ease;
}

/* Hide Content While Loading */
.hide-while-loading {
    display: none;
}

.loading-container.loading .hide-while-loading {
    display: none;
}

.loading-container:not(.loading) .show-while-loading {
    display: none;
}

/* Success Animation */
@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.success-animation {
    animation: successPulse 0.5s ease-out;
}

/* Error State */
.skeleton-error {
    background: #fee;
    color: #c33;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

/* Skeleton Specific Components */
.skeleton-category-badge {
    height: 32px;
    width: 120px;
    border-radius: 16px;
    display: inline-block;
    margin: 0.25rem;
}

.skeleton-price-tag {
    height: 40px;
    width: 100px;
    border-radius: 8px;
}

.skeleton-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

/* Staggered Animation */
.skeleton-stagger-1 { animation-delay: 0.1s; }
.skeleton-stagger-2 { animation-delay: 0.2s; }
.skeleton-stagger-3 { animation-delay: 0.3s; }
.skeleton-stagger-4 { animation-delay: 0.4s; }
.skeleton-stagger-5 { animation-delay: 0.5s; }
.skeleton-stagger-6 { animation-delay: 0.6s; }

/* Performance Optimization */
.skeleton,
.skeleton::after {
    will-change: transform;
}

/* Accessibility */
.skeleton[aria-busy="true"] {
    cursor: wait;
}

/* Print Styles */
@media print {
    .skeleton,
    .loading-overlay,
    .loading-spinner {
        display: none !important;
    }
}

