/* SPA Transitions CSS para APREMAT */

/* Contenedor principal con transiciones */
main, .main-content {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    will-change: opacity, transform;
}

/* Estado de transición */
.spa-transitioning main,
.spa-transitioning .main-content {
    opacity: 0;
    transform: translateY(20px);
}

/* Indicador de progreso SPA */
.spa-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #06b6d4);
    z-index: 10000;
    transition: width 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

.spa-progress-bar.active {
    opacity: 1;
    visibility: visible;
    width: 100%;
    animation: spa-progress 1.5s ease-in-out;
}

@keyframes spa-progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Enlaces activos */
a.active,
a.current-page {
    position: relative;
    color: #3b82f6 !important;
    font-weight: 600;
}

a.active::after,
a.current-page::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #3b82f6;
    border-radius: 1px;
    animation: link-underline 0.3s ease;
}

@keyframes link-underline {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

/* Transiciones suaves para elementos de página */
.page-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.page-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Animaciones de entrada escalonadas */
.page-section:nth-child(1) { transition-delay: 0.1s; }
.page-section:nth-child(2) { transition-delay: 0.2s; }
.page-section:nth-child(3) { transition-delay: 0.3s; }
.page-section:nth-child(4) { transition-delay: 0.4s; }
.page-section:nth-child(5) { transition-delay: 0.5s; }

/* Efectos de hover mejorados para enlaces */
a[href] {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

a[href]:hover {
    transform: translateY(-1px);
    color: #3b82f6 !important;
}

a[href]:hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
    animation: link-shine 0.6s ease;
}

@keyframes link-shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Loading states */
.spa-loading {
    position: relative;
    overflow: hidden;
}

.spa-loading::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: loading-shimmer 1.5s infinite;
}

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

/* Optimizaciones para móviles */
@media (max-width: 768px) {
    .spa-progress-bar {
        height: 2px;
    }
    
    .page-section {
        transform: translateY(20px);
    }
    
    a[href]:hover {
        transform: none; /* Desactivar transform en móvil */
    }
}

/* Reducir animaciones para usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
    main, .main-content,
    .page-section,
    a[href],
    .spa-progress-bar {
        transition: none;
        animation: none;
    }
    
    .spa-transitioning main,
    .spa-transitioning .main-content {
        opacity: 1;
        transform: none;
    }
}

/* Modo oscuro */
@media (prefers-color-scheme: dark) {
    .spa-progress-bar {
        background: linear-gradient(90deg, #60a5fa, #a78bfa, #22d3ee);
    }
    
    a.active,
    a.current-page {
        color: #60a5fa !important;
    }
    
    a.active::after,
    a.current-page::after {
        background: #60a5fa;
    }
}

/* Estados de error */
.spa-error {
    opacity: 0.5;
    filter: grayscale(50%);
    pointer-events: none;
}

/* Indicador de preload */
a[href].preloading {
    position: relative;
}

a[href].preloading::before {
    content: '🔄';
    position: absolute;
    top: -20px;
    right: -20px;
    font-size: 12px;
    opacity: 0.7;
    animation: preload-spin 1s linear infinite;
}

@keyframes preload-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Transiciones para elementos específicos */
.hero-section {
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.services-grid,
.products-grid {
    transition: opacity 0.6s ease, transform 0.6s ease;
}

/* Optimización de rendimiento */
.spa-optimized {
    contain: layout style paint;
    will-change: auto;
}

/* Estados de navegación */
.navigation-loading {
    cursor: wait;
    pointer-events: none;
}

.navigation-ready {
    cursor: pointer;
    pointer-events: auto;
}
