/* ===================================
   LOADING ANIMATIONS - PUNTO 18
   Animaciones de carga personalizadas
   =================================== */

/* === LOADER PRINCIPAL === */
.app-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(26, 31, 58, 0.95) 0%, 
        rgba(99, 102, 241, 0.9) 50%, 
        rgba(6, 182, 212, 0.85) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: var(--z-modal);
    backdrop-filter: blur(10px);
    transition: opacity var(--transition-slow);
}

.loading-container {
    text-align: center;
    color: var(--white);
}

/* === SPINNER INNOVAI === */
.innovai-spinner {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto var(--spacing-xl);
}

.spinner-ring {
    position: absolute;
    border-radius: 50%;
    border: 3px solid transparent;
    animation: spin 2s linear infinite;
}

.ring-1 {
    width: 120px;
    height: 120px;
    border-top-color: var(--primary-cyan);
    border-right-color: var(--primary-cyan);
    animation-duration: 2s;
}

.ring-2 {
    width: 90px;
    height: 90px;
    top: 15px;
    left: 15px;
    border-top-color: var(--primary-purple);
    border-left-color: var(--primary-purple);
    animation-duration: 1.5s;
    animation-direction: reverse;
}

.ring-3 {
    width: 60px;
    height: 60px;
    top: 30px;
    left: 30px;
    border-top-color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
    animation-duration: 1s;
}

.spinner-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

.spinner-logo img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* === TEXTO DE CARGA === */
.loading-text h3 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    background: linear-gradient(45deg, var(--white), var(--primary-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-text p {
    font-size: var(--font-size-lg);
    opacity: 0.9;
    margin-bottom: var(--spacing-lg);
}

/* === PUNTOS ANIMADOS === */
.loading-dots {
    display: flex;
    justify-content: center;
    gap: var(--spacing-sm);
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--white);
    border-radius: 50%;
    animation: dot-bounce 1.4s ease-in-out infinite both;
}

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

/* === BOTONES CON LOADER === */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

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

.button-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-left: 30px;
    color: currentColor;
    font-size: var(--font-size-sm);
}

/* === PROGRESS BARS === */
.innovai-progress {
    width: 100%;
    margin: var(--spacing-md) 0;
}

.progress-track {
    position: relative;
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: var(--gradient-button);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    position: relative;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6));
    animation: progress-shine 2s infinite;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--gray-600);
}

.progress-percentage {
    font-weight: 600;
    color: var(--primary-purple);
}

/* === SKELETON LOADERS === */
.skeleton-loader {
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

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

.skeleton-header {
    height: 20px;
    background: var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    width: 60%;
}

.skeleton-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.skeleton-line {
    height: 16px;
    background: var(--gray-200);
    border-radius: var(--radius-sm);
    width: 100%;
}

.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }

.skeleton-avatar {
    width: 50px;
    height: 50px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    margin-bottom: var(--spacing-sm);
}

/* === MICRO LOADERS === */
.micro-loader {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.pulse-loader {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--primary-cyan);
    border-radius: 50%;
    animation: pulse-scale 1s ease-in-out infinite;
}

/* === ANIMACIONES === */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

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

@keyframes skeleton-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

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

/* === TEMA OSCURO === */
[data-theme="dark"] .app-loading {
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.95) 0%, 
        rgba(99, 102, 241, 0.9) 50%, 
        rgba(6, 182, 212, 0.85) 100%);
}

[data-theme="dark"] .skeleton-loader {
    background: var(--gray-800);
}

[data-theme="dark"] .skeleton-header,
[data-theme="dark"] .skeleton-line,
[data-theme="dark"] .skeleton-avatar {
    background: var(--gray-700);
}

[data-theme="dark"] .progress-track {
    background: var(--gray-700);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .innovai-spinner {
        width: 80px;
        height: 80px;
    }
    
    .ring-1 {
        width: 80px;
        height: 80px;
    }
    
    .ring-2 {
        width: 60px;
        height: 60px;
        top: 10px;
        left: 10px;
    }
    
    .ring-3 {
        width: 40px;
        height: 40px;
        top: 20px;
        left: 20px;
    }
    
    .spinner-logo {
        width: 30px;
        height: 30px;
    }
    
    .spinner-logo img {
        width: 20px;
        height: 20px;
    }
    
    .loading-text h3 {
        font-size: var(--font-size-xl);
    }
    
    .loading-text p {
        font-size: var(--font-size-base);
    }
}
