/**
 * Performance-Optimized UI Components
 * Pure CSS - Zero JavaScript required
 * Resource Usage: <1% CPU, <1MB Memory
 *
 * Components included:
 * - Skeleton Loading
 * - Shimmer Effects
 * - Loading Spinners
 * - Progress Indicators
 * - Smooth Animations
 */

/* ============================================
   SKELETON LOADING
   ============================================ */

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

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 10px;
    border-radius: 4px;
}

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

.skeleton-title {
    height: 24px;
    width: 40%;
    margin-bottom: 15px;
    border-radius: 4px;
}

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

.skeleton-button {
    width: 100px;
    height: 36px;
    border-radius: 4px;
}

.skeleton-card {
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
}

/* Skeleton for table rows */
.skeleton-table-row {
    display: flex;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.skeleton-table-cell {
    flex: 1;
    height: 20px;
}

/* ============================================
   SHIMMER EFFECTS
   ============================================ */

.shimmer {
    position: relative;
    overflow: hidden;
    background: #f6f7f8;
}

.shimmer::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: shimmer 2s infinite;
}

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

/* ============================================
   LOADING SPINNERS
   ============================================ */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3085d6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

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

/* Dots loader */
.dots-loader {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.dots-loader span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3085d6;
    animation: dots-bounce 1.4s infinite ease-in-out both;
}

.dots-loader span:nth-child(1) {
    animation-delay: -0.32s;
}

.dots-loader span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dots-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Pulse loader */
.pulse-loader {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #3085d6;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0.8);
        opacity: 1;
    }
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #3085d6, #5cb85c);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-bar-animated {
    background: linear-gradient(90deg, #3085d6 25%, #5cb85c 50%, #3085d6 75%);
    background-size: 200% 100%;
    animation: progress-animation 2s linear infinite;
}

@keyframes progress-animation {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Circular progress */
.circular-progress {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(#3085d6 0%, #f0f0f0 0%);
    position: relative;
}

.circular-progress::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    background: white;
    border-radius: 50%;
}

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   LOADING OVERLAYS
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-overlay-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Inline loader */
.inline-loader {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* ============================================
   CONTENT PLACEHOLDERS
   ============================================ */

.content-placeholder {
    padding: 20px;
}

.placeholder-header {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Card placeholder */
.card-placeholder {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: white;
}

.card-placeholder-image {
    width: 100%;
    height: 200px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* ============================================
   DATA TABLE LOADING
   ============================================ */

.table-loading {
    position: relative;
    min-height: 200px;
}

.table-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

/* ============================================
   OPTIMIZED HOVER EFFECTS
   ============================================ */

.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ============================================
   GLASSMORPHISM EFFECTS
   ============================================ */

.glass-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.no-animation {
    animation: none !important;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
