/* ===============================================
   GLOBAL LOADER - ANIMACIÓN DE CARGA
   =============================================== */

/* Overlay del loader */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.global-loader.show {
    opacity: 1;
    visibility: visible;
}

/* Contenedor del loader */
.loader-container {
    text-align: center;
}

/* Spinner animado */
.loader-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    position: relative;
}

.loader-spinner .circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: var(--primary-light);
    border-right-color: var(--primary-medium);
    border-bottom-color: var(--primary-accent);
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.loader-spinner .circle-inner {
    position: absolute;
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    border-radius: 50%;
    border: 4px solid transparent;
    border-left-color: var(--primary-dark);
    border-bottom-color: var(--primary-accent);
    animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite reverse;
}

.loader-spinner .circle-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-medium), var(--primary-light));
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Texto del loader */
.loader-text {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    animation: fadeInOut 2s ease-in-out infinite;
}

.loader-subtext {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    animation: fadeInOut 2s ease-in-out infinite 0.5s;
}

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

/* Variantes de color del loader */
.global-loader.loader-success .circle {
    border-top-color: var(--success);
}

.global-loader.loader-warning .circle {
    border-top-color: var(--warning);
}

.global-loader.loader-danger .circle {
    border-top-color: var(--danger);
}

/* Loader en botones */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Skeleton loader para tablas */
.skeleton-loader {
    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;
    height: 20px;
    margin: 5px 0;
}

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

/* Puntos animados */
.loader-dots {
    display: inline-flex;
    gap: 4px;
}

.loader-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-medium);
    animation: bounce 1.4s ease-in-out infinite;
}

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

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

/* Mini loader para selectores */
.mini-loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(48, 88, 107, 0.2);
    border-top-color: var(--primary-medium);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

/* Loader en cards */
.card-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.card-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.card-loading::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    top: 50%;
    left: 50%;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(48, 88, 107, 0.2);
    border-top-color: var(--primary-medium);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 11;
}
