/* Upload Components - Individual File Progress Styles */

/* Modal Layout - Fixed Height for File List with Scrolling */
#fileUploadModal .modal-body {
    display: flex;
    flex-direction: column;
    max-height: 70vh; /* Limit modal body height */
    overflow: hidden; /* Prevent modal body scrolling */
}

#fileUploadModal .modal-body > input[type="file"],
#fileUploadModal .modal-body > .mt-2.mb-2.full-width {
    flex-shrink: 0; /* Don't shrink file input and reference input */
}

/* File List Container - Fixed Height with Scroll */
#file_list {
    flex: 1;
    max-height: 40vh; /* Fixed max height */
    min-height: 200px; /* Minimum height */
    overflow-y: auto; /* Scrollable when needed */
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px;
    background-color: #f8f9fa;
    margin-bottom: 15px;
}

/* Status Container - Always Visible at Bottom */
#fileUploadModal .status {
    flex-shrink: 0; /* Don't shrink status area */
    margin-top: auto; /* Push to bottom */
    padding: 10px;
    background-color: #fff;
    border-radius: 0 0 6px 6px;
    min-height: 50px; /* Ensure minimum space for status */
}

/* Progress Bar in Status Area */
#fileUploadModal .progress {
    margin-top: 10px;
    margin-bottom: 10px;
    height: 20px; /* Ensure progress container has proper height */
}

#fileUploadModal .progress-bar {
    height: 20px; /* Ensure progress bar has proper height */
    line-height: 20px; /* Center text vertically */
    font-size: 12px; /* Readable font size for percentage */
    font-weight: 500;
    transition: width 0.3s ease;
}

/* Overall Progress Bar Dynamic Width Classes */
.progress-bar-width-0 { width: 0% !important; }
.progress-bar-width-1 { width: 1% !important; }
.progress-bar-width-2 { width: 2% !important; }
.progress-bar-width-3 { width: 3% !important; }
.progress-bar-width-4 { width: 4% !important; }
.progress-bar-width-5 { width: 5% !important; }
.progress-bar-width-10 { width: 10% !important; }
.progress-bar-width-15 { width: 15% !important; }
.progress-bar-width-20 { width: 20% !important; }
.progress-bar-width-25 { width: 25% !important; }
.progress-bar-width-30 { width: 30% !important; }
.progress-bar-width-35 { width: 35% !important; }
.progress-bar-width-40 { width: 40% !important; }
.progress-bar-width-45 { width: 45% !important; }
.progress-bar-width-50 { width: 50% !important; }
.progress-bar-width-55 { width: 55% !important; }
.progress-bar-width-60 { width: 60% !important; }
.progress-bar-width-65 { width: 65% !important; }
.progress-bar-width-70 { width: 70% !important; }
.progress-bar-width-75 { width: 75% !important; }
.progress-bar-width-80 { width: 80% !important; }
.progress-bar-width-85 { width: 85% !important; }
.progress-bar-width-90 { width: 90% !important; }
.progress-bar-width-95 { width: 95% !important; }
.progress-bar-width-100 { width: 100% !important; }

/* File Progress Container */
.file-progress-container {
    display: none; /* Hidden by default */
    margin-top: 8px;
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 6px;
    border: 1px solid #dee2e6;
}

/* File Progress Bar */
.file-progress-bar {
    width: 100%;
    height: 16px;
    background-color: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.file-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    width: 0%;
    transition: width 0.3s ease-in-out;
    border-radius: 8px;
    position: relative;
}

/* Progress width classes (CSP-compliant) */
.file-progress-fill.progress-0 { width: 0%; }
.file-progress-fill.progress-10 { width: 10%; }
.file-progress-fill.progress-20 { width: 20%; }
.file-progress-fill.progress-30 { width: 30%; }
.file-progress-fill.progress-40 { width: 40%; }
.file-progress-fill.progress-50 { width: 50%; }
.file-progress-fill.progress-60 { width: 60%; }
.file-progress-fill.progress-70 { width: 70%; }
.file-progress-fill.progress-80 { width: 80%; }
.file-progress-fill.progress-90 { width: 90%; }
.file-progress-fill.progress-100 { width: 100%; }

.file-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 20px 20px;
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% { background-position: 20px 0; }
    100% { background-position: 0 0; }
}

.file-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    z-index: 1;
}

/* File Status Indicator */
.file-status-indicator {
    display: none; /* Hidden by default */
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-status-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.file-status-text {
    flex-grow: 1;
    font-weight: 500;
    color: #495057;
}

/* Status-specific styling */
.file-status-indicator.waiting {
    background-color: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.file-status-indicator.uploading {
    background-color: #cfe2ff;
    border-color: #a6c8ff;
    color: #055160;
}

.file-status-indicator.completed {
    background-color: #d1e7dd;
    border-color: #a3cfbb;
    color: #0a3622;
}

.file-status-indicator.error {
    background-color: #f8d7da;
    border-color: #f1aeb5;
    color: #58151c;
}

/* Progress Bar States */
.file-progress-fill.uploading {
    background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
}

.file-progress-fill.completed {
    background: linear-gradient(90deg, #28a745 0%, #1e7e34 100%);
    animation: none;
}

.file-progress-fill.completed::after {
    display: none;
}

.file-progress-fill.error {
    background: linear-gradient(90deg, #dc3545 0%, #c82333 100%);
    animation: none;
}

.file-progress-fill.error::after {
    display: none;
}

/* File Preview Card Enhancements */
.file-preview-card {
    transition: all 0.3s ease-in-out;
}

.file-preview-card.upload-mode {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.file-preview-card.completed {
    border-color: #28a745;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.1);
}

.file-preview-card.error {
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.1);
}

/* Error background for invalid files */
.file-preview-card.has-error {
    background-color: #f8d7da;
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.15);
}

.file-preview-card.has-error .file-preview-top-row {
    background-color: rgba(220, 53, 69, 0.1);
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .file-progress-container {
        padding: 4px;
        margin-top: 6px;
    }
    
    .file-progress-bar {
        height: 12px;
    }
    
    .file-progress-text {
        font-size: 9px;
    }
    
    .file-status-indicator {
        padding: 3px 6px;
        font-size: 11px;
        gap: 4px;
    }
    
    .file-status-icon {
        font-size: 12px;
    }
}

/* Accessibility enhancements */
@media (prefers-reduced-motion: reduce) {
    .file-progress-fill {
        transition: none;
    }
    
    .file-progress-fill::after {
        animation: none;
    }
    
    .file-preview-card {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .file-progress-container {
        border-width: 2px;
    }
    
    .file-progress-bar {
        border: 1px solid #000;
    }
    
    .file-status-indicator {
        border-width: 2px;
    }
}

/* Validation Error Overlay */
.upload-validation-error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.upload-validation-error-content {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    text-align: center;
    border: 2px solid #dc3545;
}

.upload-validation-error-icon {
    font-size: 3rem;
    color: #dc3545;
    margin-bottom: 20px;
}

.upload-validation-error-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #dc3545;
    margin-bottom: 15px;
}

.upload-validation-error-message {
    font-size: 1.1rem;
    color: #495057;
    margin-bottom: 25px;
    line-height: 1.5;
}

.upload-validation-error-details {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
    font-family: monospace;
    font-size: 0.9rem;
    color: #6c757d;
    text-align: left;
}

.upload-validation-error-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.upload-validation-error-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-validation-error-btn-primary {
    background-color: #dc3545;
    color: white;
}

.upload-validation-error-btn-primary:hover {
    background-color: #c82333;
}

.upload-validation-error-btn-secondary {
    background-color: #6c757d;
    color: white;
}

.upload-validation-error-btn-secondary:hover {
    background-color: #545b62;
}

/* Modal positioning for error overlay */
#fileUploadModal .modal-dialog {
    position: relative;
}

.upload-validation-error-overlay.show {
    display: flex;
}

.upload-validation-error-overlay.hide {
    display: none;
}

/* ZIP Extraction Overlay */
.zip-extraction-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1060; /* Higher than validation overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.zip-extraction-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    border: 2px solid #007bff;
}

.zip-extraction-icon {
    font-size: 4rem;
    color: #007bff;
    margin-bottom: 20px;
    animation: zip-bounce 2s infinite;
}

@keyframes zip-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.zip-extraction-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: #007bff;
    margin-bottom: 15px;
}

.zip-extraction-message {
    font-size: 1.1rem;
    color: #495057;
    margin-bottom: 30px;
    line-height: 1.5;
}

.zip-extraction-progress {
    background: #e9ecef;
    border-radius: 20px;
    height: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.zip-extraction-progress-bar {
    height: 100%;
    background: linear-gradient(45deg, #007bff, #0056b3);
    border-radius: 20px;
    transition: width 0.3s ease;
    animation: zip-progress-shine 2s infinite;
}

/* Initial state for progress bar - CSP compliant alternative to inline style */
.zip-extraction-progress-bar.zip-extraction-progress-initial {
    width: 0%;
}

@keyframes zip-progress-shine {
    0% { background-position: -100px; }
    100% { background-position: 100px; }
}

.zip-extraction-files-info {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    font-family: monospace;
    font-size: 0.9rem;
    color: #6c757d;
}

.zip-extraction-cancel {
    padding: 10px 20px;
    border: 2px solid #dc3545;
    background: transparent;
    color: #dc3545;
    border-radius: 5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.zip-extraction-cancel:hover {
    background: #dc3545;
    color: white;
}

.zip-extraction-overlay.show {
    display: flex;
}

.zip-extraction-overlay.hide {
    display: none;
}

/* Animated zip file icon */
.zip-file-animation {
    display: inline-block;
    position: relative;
}

.zip-file-animation::after {
    content: '📁';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 1.5rem;
    animation: zip-extract 1.5s infinite;
}

@keyframes zip-extract {
    0% { transform: scale(1) rotate(0deg); opacity: 1; }
    50% { transform: scale(1.2) rotate(10deg); opacity: 0.7; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ZIP Extraction Completion State */
.zip-extraction-overlay.zip-extraction-complete .zip-extraction-content {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border: 2px solid #155724;
}

.zip-extraction-overlay.zip-extraction-complete .zip-extraction-icon {
    color: #155724;
}

.zip-extraction-overlay.zip-extraction-complete .zip-extraction-icon::before {
    content: '✓';
    position: absolute;
    top: -5px;
    right: -5px;
    background: #155724;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.zip-extraction-overlay.zip-extraction-complete .zip-extraction-title {
    color: #155724;
    font-weight: 600;
}

.zip-extraction-overlay.zip-extraction-complete .zip-extraction-message {
    color: #155724;
    font-weight: 500;
}

.zip-extraction-overlay.zip-extraction-complete .zip-extraction-progress-bar {
    background: linear-gradient(90deg, #28a745, #20c997);
    animation: success-glow 0.5s ease-out;
}

@keyframes success-glow {
    0% { box-shadow: 0 0 5px rgba(40, 167, 69, 0.5); }
    50% { box-shadow: 0 0 15px rgba(40, 167, 69, 0.8); }
    100% { box-shadow: 0 0 5px rgba(40, 167, 69, 0.5); }
}
