/* ========================================
   LOADING ANIMATIONS - PredicateCh AI
   ======================================== */

/* Overlay de carga global */
.ai-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.ai-loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Contenedor principal */
.ai-loading-container {
    text-align: center;
    padding: 3rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
    border-radius: 24px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Spinner Premium */
.ai-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    position: relative;
}

.ai-spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.ai-spinner-ring:nth-child(1) {
    animation-delay: -0.45s;
    border-top-color: #a855f7;
}

.ai-spinner-ring:nth-child(2) {
    animation-delay: -0.3s;
    border-top-color: #ec4899;
}

.ai-spinner-ring:nth-child(3) {
    animation-delay: -0.15s;
    border-top-color: #f59e0b;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Icono de IA animado */
.ai-icon-animated {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.6));
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Texto de carga */
.ai-loading-text {
    color: #e2e8f0;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    animation: fadeInOut 1.5s ease-in-out infinite;
}

@keyframes fadeInOut {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.ai-loading-subtext {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Puntos animados */
.ai-loading-dots {
    display: inline-flex;
    gap: 0.3rem;
    margin-left: 0.3rem;
}

.ai-loading-dots span {
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.ai-loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dotBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Barra de progreso */
.ai-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1.5rem;
}

.ai-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    background-size: 200% 100%;
    animation: progressSlide 1.5s ease-in-out infinite;
    border-radius: 2px;
}

@keyframes progressSlide {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Variante inline (para usar dentro de cards) */
.ai-loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 12px;
    border: 1px dashed rgba(99, 102, 241, 0.3);
}

.ai-loading-inline .ai-spinner {
    width: 40px;
    height: 40px;
    margin: 0;
}

.ai-loading-inline .ai-spinner-ring {
    border-width: 3px;
}

.ai-loading-inline .ai-loading-text {
    margin: 0;
    font-size: 1rem;
}

/* Skeleton Loading (para contenido) */
.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%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-paragraph {
    height: 0.8rem;
    margin-bottom: 0.5rem;
}

.skeleton-paragraph:last-child {
    width: 80%;
}

/* Responsive */
@media (max-width: 768px) {
    .ai-loading-container {
        max-width: 90%;
        padding: 2rem;
    }

    .ai-spinner {
        width: 60px;
        height: 60px;
    }

    .ai-icon-animated {
        font-size: 2.5rem;
    }

    .ai-loading-text {
        font-size: 1rem;
    }
}