/* ==========================================================================
   AMPHYX - SYSTÈME DE CHARGEMENT & GESTION DES ERREURS RÉSEAU
   1. Preloader de démarrage officiel Amphyx
   2. Barre de progression supérieure de navigation entre pages
   3. Notification & Bandeau de déconnexion réseau / Mode Hors-ligne
   4. État de chargement sur les formulaires et boutons d'action
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. PRELOADER INITIAL DU SITE
   -------------------------------------------------------------------------- */
#campusx-preloader {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    z-index: 9999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#campusx-preloader.fade-out {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.campusx-preloader-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(12, 46, 96, 0.04) 0%, rgba(238, 57, 15, 0.03) 50%, rgba(255, 255, 255, 0) 75%);
    pointer-events: none;
}

.campusx-preloader-center {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px;
    z-index: 2;
}

.campusx-preloader-logo-ring {
    position: relative;
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(12, 46, 96, 0.12);
    margin-bottom: 18px;
    animation: campusxPulseRing 2.2s ease-in-out infinite;
}

.campusx-preloader-logo-ring::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px dashed rgba(238, 57, 15, 0.35);
    animation: campusxSpin 8s linear infinite;
}

.campusx-preloader-logo-ring img {
    height: 48px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(12, 46, 96, 0.15));
}

.campusx-preloader-brand {
    font-family: 'Outfit', sans-serif;
    font-size: 26px;
    font-weight: 900;
    color: #0c2e60;
    letter-spacing: -0.5px;
    margin: 0 0 4px 0;
    line-height: 1.1;
}

.campusx-preloader-brand span {
    color: #ee390f;
}

.campusx-preloader-tagline {
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 22px;
}

.campusx-preloader-progress-track {
    width: 200px;
    height: 5px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.campusx-preloader-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 45%;
    border-radius: 10px;
    background: linear-gradient(90deg, #0c2e60 0%, #ee390f 50%, #f9b700 100%);
    box-shadow: 0 0 10px rgba(238, 57, 15, 0.4);
    animation: campusxProgressGlide 1.3s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.campusx-preloader-caption {
    margin-top: 14px;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes campusxPulseRing {
    0% {
        transform: scale(1);
        box-shadow: 0 10px 25px rgba(12, 46, 96, 0.12), 0 0 0 0 rgba(238, 57, 15, 0.25);
    }
    50% {
        transform: scale(1.04);
        box-shadow: 0 14px 30px rgba(12, 46, 96, 0.18), 0 0 0 10px rgba(238, 57, 15, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 10px 25px rgba(12, 46, 96, 0.12), 0 0 0 0 rgba(238, 57, 15, 0);
    }
}

@keyframes campusxSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes campusxProgressGlide {
    0% {
        left: -45%;
        width: 35%;
    }
    50% {
        width: 60%;
    }
    100% {
        left: 100%;
        width: 35%;
    }
}

/* --------------------------------------------------------------------------
   2. BARRE DE NAVIGATION SUPÉRIEURE (TRANSITION DE PAGE STYLE YOUTUBE/GITHUB)
   -------------------------------------------------------------------------- */
#campusx-page-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3.5px;
    width: 0%;
    z-index: 99999999;
    background: linear-gradient(90deg, #ee390f 0%, #f9b700 65%, #0c2e60 100%);
    box-shadow: 0 0 10px rgba(238, 57, 15, 0.8), 0 0 5px rgba(249, 183, 0, 0.6);
    pointer-events: none;
    opacity: 0;
    transition: width 0.22s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.25s ease-out;
}

#campusx-page-progress.is-active {
    opacity: 1 !important;
}

#campusx-page-progress.is-done {
    width: 100% !important;
    opacity: 0 !important;
    transition: width 0.12s ease-out, opacity 0.25s 0.1s ease-out;
}

/* --------------------------------------------------------------------------
   3. GESTION DES ERREURS RÉSEAU & TOAST HORS-LIGNE
   -------------------------------------------------------------------------- */
#campusx-network-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 440px;
    max-width: calc(100vw - 32px);
    z-index: 999999;
    transform: translateY(120px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s, visibility 0.35s;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 20px 45px rgba(12, 46, 96, 0.18), 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1.5px solid #e2e8f0;
}

#campusx-network-toast.show {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
}

#campusx-network-toast.is-offline {
    border-color: #fca5a5;
}

#campusx-network-toast.is-online {
    border-color: #86efac;
}

.campusx-toast-strip {
    height: 5px;
    width: 100%;
}

.is-offline .campusx-toast-strip {
    background: linear-gradient(90deg, #ef4444 0%, #f97316 100%);
}

.is-online .campusx-toast-strip {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
}

.campusx-toast-body {
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.campusx-toast-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
}

.is-offline .campusx-toast-icon-wrap {
    background: #fee2e2;
    color: #dc2626;
}

.is-online .campusx-toast-icon-wrap {
    background: #dcfce7;
    color: #16a34a;
}

.campusx-toast-content {
    flex: 1;
}

.campusx-toast-title {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: #0c2e60;
    margin: 0 0 4px 0;
    line-height: 1.25;
}

.campusx-toast-desc {
    font-size: 13.5px;
    color: #475569;
    line-height: 1.45;
    margin: 0 0 12px 0;
}

.campusx-toast-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.campusx-toast-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.campusx-toast-btn-primary {
    background: #0c2e60;
    color: #ffffff !important;
}

.campusx-toast-btn-primary:hover {
    background: #164385;
    transform: translateY(-1px);
}

.campusx-toast-btn-outline {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155 !important;
}

.campusx-toast-btn-outline:hover {
    background: #e2e8f0;
}

.campusx-toast-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    line-height: 1;
    margin-left: auto;
    border-radius: 6px;
    transition: color 0.2s;
}

.campusx-toast-close:hover {
    color: #0f172a;
    background: #f1f5f9;
}

/* --------------------------------------------------------------------------
   4. TOAST FLOTTANT D'ERREUR REQUÊTE RÉSEAU (AJAX / FETCH ERROR)
   -------------------------------------------------------------------------- */
#campusx-ajax-error-toast {
    position: fixed;
    top: 85px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    z-index: 999999;
    background: #ffffff;
    border-left: 5px solid #ef4444;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(12, 46, 96, 0.15);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    pointer-events: none;
}

#campusx-ajax-error-toast.show {
    transform: translateX(0) !important;
    opacity: 1 !important;
    pointer-events: all !important;
}

/* --------------------------------------------------------------------------
   5. ÉTATS DE CHARGEMENT SUR LES BOUTONS
   -------------------------------------------------------------------------- */
.btn.is-loading,
button[type="submit"].is-loading {
    position: relative;
    pointer-events: none !important;
    color: transparent !important;
}

.btn.is-loading::after,
button[type="submit"].is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-top: -9px;
    margin-left: -9px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: campusxSpin 0.75s linear infinite;
}

.btn-outline-primary.is-loading::after,
.btn-outline-secondary.is-loading::after,
.btn-light.is-loading::after {
    border-color: rgba(12, 46, 96, 0.2);
    border-top-color: #0c2e60;
}

/* Version mobile */
@media (max-width: 575.98px) {
    #campusx-network-toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
        width: auto;
    }
    #campusx-ajax-error-toast {
        left: 12px;
        right: 12px;
        top: 75px;
        width: auto;
        max-width: none;
    }
}
