/**
* LOADING ENHANCEMENTS
* Premium loading states and skeletons
* 2025/2026 Loading UX Best Practices
*/

/* ============================================
  SKELETON LOADERS
  ============================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(0, 0, 0, 0.05) 25%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

body.dark-mode .skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
}

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

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1rem;
}

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

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

.skeleton-card {
    padding: 20px;
    border-radius: 12px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
}

body.dark-mode .skeleton-card {
    background: var(--dark-background-color);
    border-color: var(--dark-border-color);
}

/* ============================================
  PROGRESS INDICATORS
  ============================================ */
.progress-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(102, 126, 234, 0.1);
    z-index: 10000;
    overflow: hidden;
}

.progress-indicator-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

/* ============================================
  SPINNER VARIANTS
  ============================================ */
.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

.spinner-primary {
    border-top-color: #667eea;
}

.spinner-success {
    border-top-color: #10b981;
}

.spinner-error {
    border-top-color: #ef4444;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
  DOTS LOADER
  ============================================ */
.dots-loader {
    display: inline-flex;
    gap: 8px;
}

.dots-loader span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

/* ============================================
  PULSE LOADER
  ============================================ */
.pulse-loader {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #667eea;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* ============================================
  RIPPLE LOADER
  ============================================ */
.ripple-loader {
    position: relative;
    width: 40px;
    height: 40px;
}

.ripple-loader span {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid #667eea;
    border-radius: 50%;
    animation: ripple 1.5s ease-out infinite;
}

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

@keyframes ripple {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* ============================================
  PAGE LOADER
  ============================================ */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.dark-mode .page-loader {
    background: rgba(0, 0, 0, 0.95);
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.page-loader-content {
    text-align: center;
}

.page-loader-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    animation: fadeInScale 0.5s ease;
}

.page-loader-text {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-top: 20px;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
  BUTTON LOADING STATE
  ============================================ */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================
  LAZY LOAD PLACEHOLDER
  ============================================ */
.lazy-load-placeholder {
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

body.dark-mode .lazy-load-placeholder {
    background: var(--dark-background-color);
    border-color: var(--dark-border-color);
}

/* ============================================
  RESPONSIVE DESIGN
  ============================================ */
@media (max-width: 768px) {
    .page-loader-logo {
        width: 60px;
        height: 60px;
    }

    .page-loader-text {
        font-size: 1rem;
    }
}

/* ============================================
  ACCESSIBILITY
  ============================================ */
@media (prefers-reduced-motion: reduce) {
    .skeleton,
    .spinner,
    .dots-loader span,
    .pulse-loader,
    .ripple-loader span,
    .btn-loading::after {
        animation: none;
    }

    .skeleton {
        background: rgba(0, 0, 0, 0.1);
    }
}


/* Focus styles for accessibility - Auto-added */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}
