/* Ensure parent containers of skeleton loaders have relative positioning */
[loading-panel] {
    position: relative !important;
}

/* Widget Skeleton Loading Styles */
.widget-skeleton {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: #f8f9fa !important;
    border-radius: 8px;
    overflow: hidden !important;
    height: 100% !important;
    width: 100% !important;
    z-index: 999 !important;
}

.widget-skeleton::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-shimmer 2s infinite linear;
    z-index: 1;
}

@keyframes skeleton-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.widget-skeleton .skeleton-header {
    height: 40px !important;
    background: #e9ecef !important;
    margin: 16px !important;
    border-radius: 4px !important;
    animation: skeleton-pulse 1.5s ease-in-out infinite alternate !important;
    position: relative !important;
    z-index: 2 !important;
}

.widget-skeleton .skeleton-chart {
    height: 150px !important;
    background: #e9ecef !important;
    margin: 16px !important;
    border-radius: 4px !important;
    animation: skeleton-pulse 1.5s ease-in-out infinite alternate !important;
    animation-delay: 0.2s !important;
    position: relative !important;
    z-index: 2 !important;
    overflow: hidden !important;
}

/* Add wave effect to chart skeletons */
.widget-skeleton .skeleton-chart::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: skeleton-wave 2.5s infinite ease-in-out;
    animation-delay: 0.5s;
}

.widget-skeleton .skeleton-table-row {
    height: 24px !important;
    background: #e9ecef !important;
    margin: 8px 16px !important;
    border-radius: 4px !important;
    animation: skeleton-pulse 1.5s ease-in-out infinite alternate !important;
    position: relative !important;
    z-index: 2 !important;
}

.widget-skeleton .skeleton-table-row:nth-child(1) { animation-delay: 0.1s !important; }
.widget-skeleton .skeleton-table-row:nth-child(2) { animation-delay: 0.2s !important; }
.widget-skeleton .skeleton-table-row:nth-child(3) { animation-delay: 0.3s !important; }
.widget-skeleton .skeleton-table-row:nth-child(4) { animation-delay: 0.4s !important; }

.widget-skeleton .skeleton-snapshot {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding: 16px !important;
    position: relative !important;
    z-index: 2 !important;
}

.widget-skeleton .skeleton-snapshot-value {
    height: 48px !important;
    background: #e9ecef !important;
    border-radius: 4px !important;
    animation: skeleton-pulse 1.5s ease-in-out infinite alternate !important;
    position: relative !important;
    z-index: 2 !important;
    overflow: hidden !important;
}

/* Add subtle wave effect to snapshot values */
.widget-skeleton .skeleton-snapshot-value::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: skeleton-wave 3s infinite ease-in-out;
    animation-delay: 1s;
}

.widget-skeleton .skeleton-snapshot-label {
    height: 20px !important;
    background: #e9ecef !important;
    border-radius: 4px;
    width: 70%;
    animation: skeleton-pulse 1.5s ease-in-out infinite alternate;
    animation-delay: 0.2s;
    position: relative;
    z-index: 2;
}

@keyframes skeleton-pulse {
    0% {
        opacity: 1;
        background-color: #e9ecef;
    }
    50% {
        opacity: 0.6;
        background-color: #dee2e6;
    }
    100% {
        opacity: 0.4;
        background-color: #ced4da;
    }
}

/* Additional wave animation for more visual interest */
@keyframes skeleton-wave {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .widget-skeleton {
        min-height: 150px;
    }
    
    .skeleton-header {
        height: 32px;
        margin: 12px;
    }
    
    .skeleton-chart {
        height: 100px;
        margin: 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .widget-skeleton {
        background: #ffffff;
        border: 1px solid #666666;
    }
    
    .skeleton-header,
    .skeleton-chart,
    .skeleton-table-row,
    .skeleton-snapshot-value,
    .skeleton-snapshot-label {
        background: #cccccc;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .widget-skeleton::before,
    .skeleton-header,
    .skeleton-chart,
    .skeleton-table-row,
    .skeleton-snapshot-value,
    .skeleton-snapshot-label {
        animation: none;
    }
    
    .skeleton-header,
    .skeleton-chart,
    .skeleton-table-row,
    .skeleton-snapshot-value,
    .skeleton-snapshot-label {
        opacity: 0.7;
    }
}