/**
 * Matoo AJAX Navigation Styles
 * Loader e transizioni per navigazione AJAX
 *
 * @package Matoo_Marketplace
 * @since 4.3.0
 */

/* ============================================
   PROGRESS BAR (top of page)
   ============================================ */
.matoo-ajax-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 99999;
    pointer-events: none;
}

.matoo-ajax-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4f46e5, #7c3aed, #4f46e5);
    background-size: 200% 100%;
    animation: matoo-progress-grow 1.5s ease-out forwards,
               matoo-progress-shimmer 1s linear infinite;
    box-shadow: 0 0 10px rgba(79, 70, 229, 0.7);
}

@keyframes matoo-progress-grow {
    0% { width: 0%; }
    20% { width: 30%; }
    50% { width: 60%; }
    80% { width: 85%; }
    100% { width: 92%; }
}

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

.matoo-ajax-progress-bar.complete {
    width: 100% !important;
    animation: none;
    transition: width 0.2s ease-out, opacity 0.3s ease-out 0.2s;
    opacity: 0;
}

/* ============================================
   LOADING STATE
   ============================================ */
.matoo-ajax-loading {
    cursor: progress;
}

.matoo-ajax-loading #main {
    position: relative;
    min-height: 400px;
}

/* Overlay sul contenuto */
.matoo-ajax-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    min-height: 400px;
    gap: 16px;
}

/* Spinner grande */
.matoo-ajax-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: matoo-spin 0.7s linear infinite;
}

/* Testo loading */
.matoo-ajax-loader-text {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

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

/* ============================================
   LINK ATTIVO NELLA SIDEBAR
   ============================================ */
.matoo-sidebar-link-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.matoo-sidebar-link-loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: matoo-spin 0.6s linear infinite;
}

/* ============================================
   TRANSIZIONE CONTENUTO
   ============================================ */
#main {
    transition: opacity 0.2s ease-out;
}

#main.matoo-fade-out {
    opacity: 0.4;
}

#main.matoo-fade-in {
    opacity: 1;
}

/* ============================================
   DARK MODE
   ============================================ */
@media (prefers-color-scheme: dark) {
    .matoo-ajax-loader {
        background: rgba(17, 24, 39, 0.9);
    }
    
    .matoo-ajax-spinner {
        border-color: #374151;
        border-top-color: #818cf8;
    }
    
    .matoo-ajax-loader-text {
        color: #9ca3af;
    }
}