/* =============================
   GSWeb - Optimisations Performance CSS
   Chargement rapide & animations fluides
   ============================= */

/* ===== 1. OPTIMISATIONS GPU ===== */

/* Activer l'accélération matérielle pour les éléments animés */
.btn,
.navbar,
.gs-card,
.modal,
.dropdown-menu,
.table,
.form-control {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000px;
    perspective: 1000px;
}

/* ===== 2. ANIMATIONS PERFORMANTES ===== */

/* Animations fluides avec will-change (utiliser avec modération) */
.btn:hover,
.navbar-nav > li > a:hover,
.table > tbody > tr:hover {
    will-change: transform, box-shadow, background-color;
}

/* Désactiver will-change après animation */
.btn:not(:hover),
.navbar-nav > li > a:not(:hover),
.table > tbody > tr:not(:hover) {
    will-change: auto;
}

/* ===== 3. ANIMATIONS PRÉDÉFINIES ===== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Classes utilitaires d'animation */
.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-slideInRight {
    animation: slideInRight 0.3s ease-out;
}

.animate-slideInLeft {
    animation: slideInLeft 0.3s ease-out;
}

.animate-scaleIn {
    animation: scaleIn 0.2s ease-out;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* ===== 4. LOADING STATES ===== */

/* Skeleton loader pour chargement */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Spinner de chargement */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(37, 99, 235, 0.2);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* ===== 5. OPTIMISATION IMAGES ===== */

/* Lazy loading natif */
img[loading="lazy"] {
    content-visibility: auto;
}

/* Placeholder pendant chargement */
img:not([src]) {
    background: #f0f0f0;
    border-radius: 8px;
}

/* ===== 6. SCROLL PERFORMANT ===== */

/* Smooth scroll avec performance */
.smooth-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Optimisation pour listes longues */
.virtualized-list {
    contain: layout style paint;
    content-visibility: auto;
}

/* ===== 7. TRANSITIONS OPTIMISÉES ===== */

/* Transitions standards performantes */
.transition-fast {
    transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-base {
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-slow {
    transition: all 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Transitions spécifiques (plus performantes) */
.transition-colors {
    transition: color 150ms, background-color 150ms, border-color 150ms;
}

.transition-transform {
    transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-opacity {
    transition: opacity 200ms;
}

/* ===== 8. HOVER EFFECTS OPTIMISÉS ===== */

/* Effet de lift (elevation) */
.hover-lift {
    transition: transform 200ms, box-shadow 200ms;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.15);
}

/* Effet de glow */
.hover-glow {
    transition: box-shadow 200ms;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
}

/* Effet de scale */
.hover-scale {
    transition: transform 200ms;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* ===== 9. RESPONSIVE UTILITIES ===== */

/* Masquer sur mobile (économie de rendu) */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    /* Réduire animations sur mobile */
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Masquer sur desktop */
@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* ===== 10. PRINT OPTIMIZATION ===== */

@media print {
    /* Désactiver toutes les animations pour l'impression */
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        box-shadow: none !important;
    }
    
    /* Optimiser les couleurs d'impression */
    body {
        background: white !important;
        color: black !important;
    }
}

/* ===== 11. REDUCED MOTION ===== */

/* Respecter les préférences d'accessibilité */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== 12. FOCUS STATES OPTIMISÉS ===== */

/* Focus visible moderne */
.focus-ring:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 6px;
}

/* Supprimer outline par défaut mais garder accessibility */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* ===== 13. UTILITIES DE PERFORMANCE ===== */

/* Forcer le rendu GPU */
.gpu-accelerate {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimiser le contenu hors écran */
.offscreen-optimize {
    content-visibility: auto;
    contain-intrinsic-size: 500px;
}

/* Isoler les couches de peinture */
.isolate-layer {
    isolation: isolate;
    will-change: transform;
}

/* ===== 14. LOADING OVERLAY ===== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.loading-overlay.hidden {
    display: none;
}

/* ===== 15. TOAST NOTIFICATIONS ===== */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
    z-index: 1000;
    max-width: 400px;
}

.toast.success {
    border-left: 4px solid #16a34a;
}

.toast.error {
    border-left: 4px solid #dc2626;
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.toast.info {
    border-left: 4px solid #0ea5e9;
}

/* ===== 16. BADGES & LABELS ===== */

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-primary {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
}

.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-warning {
    background: #fef3c7;
    color: #b45309;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

/* ===== 17. UTILITIES SPACING ===== */

.m-0 { margin: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }
.mt-4 { margin-top: 32px !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }
.mb-4 { margin-bottom: 32px !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 8px !important; }
.p-2 { padding: 16px !important; }
.p-3 { padding: 24px !important; }
.p-4 { padding: 32px !important; }

/* ===== 18. TEXT UTILITIES ===== */

.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.font-bold { font-weight: 700 !important; }
.font-semibold { font-weight: 600 !important; }
.font-normal { font-weight: 400 !important; }

.text-sm { font-size: 14px !important; }
.text-base { font-size: 16px !important; }
.text-lg { font-size: 18px !important; }
.text-xl { font-size: 20px !important; }
.text-2xl { font-size: 24px !important; }

/* ===== 19. FLEX UTILITIES ===== */

.flex { display: flex !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-column { flex-direction: column !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.items-center { align-items: center !important; }
.gap-1 { gap: 8px !important; }
.gap-2 { gap: 16px !important; }
.gap-3 { gap: 24px !important; }

/* ===== 20. SHADOW UTILITIES ===== */

.shadow-sm {
    box-shadow: 0 4px 12px rgba(17, 24, 39, 0.06);
}

.shadow {
    box-shadow: 0 6px 16px rgba(17, 24, 39, 0.08);
}

.shadow-md {
    box-shadow: 0 8px 20px rgba(17, 24, 39, 0.10);
}

.shadow-lg {
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.12);
}

.shadow-xl {
    box-shadow: 0 20px 48px rgba(17, 24, 39, 0.15);
}

.shadow-none {
    box-shadow: none !important;
}
