/**
 * Loading States CSS - Estilos para estados de carga y notificaciones
 * Optimizado para mobile-first y responsivo
 */

/* Loading Overlay Global */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 320px;
    width: 90%;
    margin: 0 1rem;
}

/* Loading Spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 1.1rem;
    color: #333;
    margin-bottom: 1rem;
    font-weight: 500;
}

/* Progress Bar */
.loading-progress {
    display: none;
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

/* Element-specific loading */
.element-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: inherit;
}

.element-loader-content {
    text-align: center;
    color: #666;
}

.element-spinner {
    width: 24px;
    height: 24px;
    margin: 0 auto 0.5rem;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading .element-loader-content span {
    font-size: 0.9rem;
    display: block;
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    width: calc(100% - 40px);
}

.notification {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    border-left: 4px solid #007bff;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.removing {
    opacity: 0;
    transform: translateX(100%);
}

.notification-success {
    border-left-color: #28a745;
}

.notification-error {
    border-left-color: #dc3545;
}

.notification-warning {
    border-left-color: #ffc107;
}

.notification-info {
    border-left-color: #17a2b8;
}

.notification-content {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 0.75rem;
}

.notification-icon {
    font-size: 1.2rem;
    font-weight: bold;
    flex-shrink: 0;
}

.notification-success .notification-icon {
    color: #28a745;
}

.notification-error .notification-icon {
    color: #dc3545;
}

.notification-warning .notification-icon {
    color: #ffc107;
}

.notification-info .notification-icon {
    color: #17a2b8;
}

.notification-message {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #333;
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.notification-close:hover {
    background-color: #f0f0f0;
    color: #666;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .loading-content {
        padding: 1.5rem;
        margin: 0 0.5rem;
    }
    
    .loading-spinner {
        width: 32px;
        height: 32px;
    }
    
    .loading-text {
        font-size: 1rem;
    }
    
    .notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
    
    .notification-content {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .notification-message {
        font-size: 0.9rem;
    }
}

/* Button Loading States */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

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

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

/* Table Loading States */
.table-loading {
    position: relative;
}

.table-loading tbody {
    opacity: 0.5;
    pointer-events: none;
}

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

.table-loading::after {
    content: 'Actualizando datos...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 2;
    font-weight: 500;
    color: #666;
}

/* Card Loading States */
.card-loading {
    position: relative;
    overflow: hidden;
}

.card-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 2s infinite;
    z-index: 1;
}

/* Form Loading States */
.form-loading {
    position: relative;
    pointer-events: none;
}

.form-loading input,
.form-loading select,
.form-loading textarea {
    opacity: 0.6;
}

.form-loading::before {
    content: 'Procesando...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 123, 255, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 10;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .loading-content {
        background: #2d3748;
        color: white;
    }
    
    .loading-text {
        color: #e2e8f0;
    }
    
    .progress-text {
        color: #a0aec0;
    }
    
    .notification {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .notification-message {
        color: #e2e8f0;
    }
    
    .notification-close:hover {
        background-color: #4a5568;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner,
    .element-spinner,
    .progress-fill::before {
        animation: none;
    }
    
    .notification {
        transition: opacity 0.1s ease;
    }
    
    .loading-overlay {
        transition: opacity 0.1s ease;
    }
}