/**
 * Global Loading System Styles
 * Estilos para el sistema de loading global de ConstructoraCliente
 */

/* Overlay principal */
.global-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fadeIn 0.3s ease-in-out;
}

/* Contenido del loading */
.loading-content {
    text-align: center;
    padding: 30px 25px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    max-width: 320px;
    width: 90%;
    border: 1px solid rgba(0, 0, 0, 0.05);
    animation: slideUp 0.4s ease-out;
}

/* Spinner principal */
.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #e20613;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    margin: 0 auto 20px;
    position: relative;
}

/* Efecto adicional en el spinner */
.loading-spinner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid #e20613;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: spin 0.8s linear infinite reverse;
}

/* Texto del loading */
.loading-text {
    font-size: 16px;
    color: #333;
    font-weight: 500;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Animaciones */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Variantes de spinner */
.loading-spinner.pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* Spinner de puntos */
.loading-dots {
    display: inline-block;
    width: 60px;
    height: 20px;
    margin: 0 auto 20px;
}

.loading-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #e20613;
    margin: 0 2px;
    animation: dotPulse 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1);
        opacity: 1;
    }
}

/* Estados del overlay */
.global-loading-overlay.processing {
    background-color: rgba(226, 6, 19, 0.1);
}

.global-loading-overlay.error {
    background-color: rgba(220, 53, 69, 0.1);
}

.global-loading-overlay.success {
    background-color: rgba(40, 167, 69, 0.1);
}

/* Responsivo */
@media (max-width: 480px) {
    .loading-content {
        padding: 25px 20px;
        max-width: 280px;
        border-radius: 12px;
    }
    
    .loading-spinner {
        width: 50px;
        height: 50px;
        margin-bottom: 15px;
    }
    
    .loading-text {
        font-size: 14px;
    }
}

/* Tema oscuro */
@media (prefers-color-scheme: dark) {
    .global-loading-overlay {
        background-color: rgba(33, 37, 41, 0.95);
    }
    
    .loading-content {
        background: #343a40;
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .loading-text {
        color: #f8f9fa;
    }
    
    .loading-spinner {
        border-color: #495057;
        border-top-color: #e20613;
    }
}

/* Accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .global-loading-overlay,
    .loading-content,
    .loading-spinner {
        animation: none;
    }
    
    .loading-spinner {
        border-top-color: transparent;
        border-right-color: #e20613;
    }
}

/* Ocultar en impresión */
@media print {
    .global-loading-overlay {
        display: none !important;
    }
}

/* Utilidades adicionales */
.global-loading-overlay.no-blur {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.global-loading-overlay.transparent {
    background-color: rgba(255, 255, 255, 0.7);
}

/* Loading para áreas específicas */
.loading-container {
    position: relative;
}

.loading-container .local-loading {
    position: absolute;
    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: 1000;
}

.loading-container .local-loading .loading-spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
}

/* Indicador de progreso lineal */
.loading-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #e9ecef;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #e20613, #b8050f);
    animation: progressMove 2s ease-in-out infinite;
}

@keyframes progressMove {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0%); }
    100% { transform: translateX(100%); }
}