/* ============================================
   LOADING ENHANCED - Système de chargement amélioré
   ============================================ */

/* Overlay Global - Amélioré */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.loading-overlay.hidden {
    animation: fadeOut 0.2s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Spinner principal amélioré */
.loading-spinner {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 50px 60px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.25),
        0 10px 30px rgba(0, 120, 212, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    animation: slideUp 0.3s ease-out;
    min-width: 320px;
    position: relative;
    overflow: hidden;
}

.loading-spinner::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(0, 120, 212, 0.05) 50%, 
        transparent 70%);
    animation: rotate 4s linear infinite;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

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

/* Spinner circulaire moderne */
.loading-spinner-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    position: relative;
    z-index: 1;
}

.spinner-modern {
    width: 64px;
    height: 64px;
    border: 5px solid rgba(0, 120, 212, 0.1);
    border-top-color: #0078D4;
    border-right-color: #00B4D8;
    border-bottom-color: #0099BC;
    border-radius: 50%;
    animation: spin 0.9s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    position: relative;
    box-shadow: 
        0 0 20px rgba(0, 120, 212, 0.3),
        inset 0 0 10px rgba(0, 120, 212, 0.1);
}

.spinner-modern::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 3px solid transparent;
    border-top-color: rgba(0, 180, 216, 0.4);
    border-radius: 50%;
    animation: spin 1.2s linear infinite reverse;
}

.spinner-modern::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid rgba(0, 120, 212, 0.15);
    border-top-color: #0078D4;
    border-radius: 50%;
    animation: spin 0.7s linear infinite reverse;
    box-shadow: inset 0 0 8px rgba(0, 120, 212, 0.2);
}

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

/* Icône Font Awesome alternative */
.loading-spinner i {
    font-size: 48px;
    color: #0078D4;
    margin-bottom: 0;
    animation: spin 1s linear infinite;
}

.loading-spinner p {
    font-size: 16px;
    color: #323130;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
}

.loading-spinner .loading-message {
    font-size: 14px;
    color: #605E5C;
    font-weight: 400;
    margin-top: 8px;
    max-width: 250px;
}

/* Barre de progression moderne */
.loading-progress {
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, 
        rgba(0, 120, 212, 0.1) 0%, 
        rgba(0, 180, 216, 0.15) 50%, 
        rgba(0, 120, 212, 0.1) 100%);
    background-size: 200% 100%;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 24px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.loading-progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s ease-in-out infinite;
    border-radius: 10px;
}

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

.loading-progress-bar {
    height: 100%;
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 120, 212, 0.5),
                0 0 20px rgba(0, 180, 216, 0.3);
    animation: progressAnimation 2s ease-in-out infinite;
    width: 35%;
}

.loading-progress-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        #0078D4 0%, 
        #00B4D8 25%,
        #0099BC 50%,
        #00B4D8 75%,
        #0078D4 100%);
    background-size: 200% 100%;
    animation: gradientFlow 3s ease-in-out infinite;
}

.loading-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.6) 50%, 
        transparent 100%);
    animation: shine 2s ease-in-out infinite;
}

@keyframes gradientFlow {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

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

@keyframes progressAnimation {
    0% {
        transform: translateX(-100%);
        opacity: 0.8;
    }
    50% {
        transform: translateX(250%);
        opacity: 1;
    }
    100% {
        transform: translateX(250%);
        opacity: 0.8;
    }
}

/* Loader de section (pour tableaux, modals, etc.) */
.section-loading {
    position: relative;
    min-height: 200px;
}

.section-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.section-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(0, 120, 212, 0.1);
    border-top-color: #0078D4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 11;
}

/* Loader inline pour boutons */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-loading .btn-text {
    opacity: 0;
}

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

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

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    margin-bottom: 0;
    width: 60%;
}

.skeleton-title {
    height: 24px;
    width: 40%;
    margin-bottom: 16px;
}

.skeleton-card {
    height: 120px;
    border-radius: 8px;
}

/* Loader pour tableaux */
.table-loading {
    position: relative;
}

.table-loading tbody::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-loading tbody::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid rgba(0, 120, 212, 0.1);
    border-top-color: #0078D4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 6;
}

/* Loader pour modals */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 8px;
}

.modal-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 120, 212, 0.1);
    border-top-color: #0078D4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Pulse animation pour indicateurs */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

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

/* Dots loader */
.dots-loader {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.dots-loader span {
    width: 8px;
    height: 8px;
    background: #0078D4;
    border-radius: 50%;
    animation: dots-bounce 1.4s ease-in-out infinite;
}

.dots-loader span:nth-child(1) {
    animation-delay: 0s;
}

.dots-loader span:nth-child(2) {
    animation-delay: 0.2s;
}

.dots-loader span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dots-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .loading-spinner {
        padding: 40px 30px;
        min-width: 240px;
    }
    
    .spinner-modern {
        width: 50px;
        height: 50px;
    }
    
    .loading-spinner i {
        font-size: 40px;
    }
    
    .loading-spinner p {
        font-size: 14px;
    }
}

/* États de chargement pour les onglets */
.tab-panel.loading {
    position: relative;
    min-height: 300px;
}

.tab-panel.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-panel.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(0, 120, 212, 0.1);
    border-top-color: #0078D4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 11;
}

