/* Loading Indicators and UX Improvements for PDGM Tool */

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

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

/* Large Loading Spinner for Modals */
.loading-spinner-large {
    display: block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* Loading State for Buttons */
.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 transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Progress Messages */
.progress-message {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background-color: #f0f9ff;
    border: 1px solid #0ea5e9;
    border-radius: 8px;
    margin: 10px 0;
    font-size: 14px;
    color: #0c4a6e;
    animation: fadeIn 0.3s ease-in;
}

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

/* Progress Steps */
.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background-color: #fafafa;
    border-radius: 8px;
    margin: 10px 0;
}

.progress-step {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #6b7280;
    transition: color 0.3s ease;
}

.progress-step.active {
    color: #2563eb;
    font-weight: 500;
}

.progress-step.completed {
    color: #059669;
}

.progress-step-icon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.progress-step.pending .progress-step-icon {
    background-color: #e5e7eb;
    color: #9ca3af;
}

.progress-step.active .progress-step-icon {
    background-color: #2563eb;
    color: white;
}

.progress-step.completed .progress-step-icon {
    background-color: #059669;
    color: white;
}

/* Modal Loading State */
.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 40px;
}

.modal-loading-text {
    margin-top: 16px;
    font-size: 16px;
    color: #4b5563;
    text-align: center;
}

/* Enhanced Button States */
.btn-export {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-export:hover:not(.btn-loading) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-export:active:not(.btn-loading) {
    transform: translateY(0);
}

.btn-export.btn-loading {
    cursor: not-allowed;
}

/* Pulse Animation for Loading States */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Error State Improvements */
.error-message {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    margin: 10px 0;
}

.error-message::before {
    content: '⚠️';
    margin-right: 8px;
}

/* Success State */
.success-message {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    color: #166534;
    margin: 10px 0;
}

.success-message::before {
    content: '✅';
    margin-right: 8px;
}

/* Responsive Loading States */
@media (max-width: 768px) {
    .progress-message {
        font-size: 12px;
        padding: 8px;
    }
    
    .loading-spinner-large {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
    
    .modal-loading {
        min-height: 150px;
        padding: 20px;
    }
}

/* Documentation Button Loading States */
.documentation-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.documentation-buttons .btn-export {
    flex: 1;
    min-width: 200px;
}

/* Loading Overlay for Modal Content */
.modal-content-loading {
    position: relative;
}

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

/* Skeleton Loading for Text Content */
.skeleton-text {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
    height: 1em;
    margin: 0.5em 0;
}

.skeleton-text.line-1 { width: 100%; }
.skeleton-text.line-2 { width: 85%; }
.skeleton-text.line-3 { width: 90%; }
.skeleton-text.line-4 { width: 75%; }

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

/* Enhanced Modal Animations */
.modal {
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

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

@keyframes modalSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

