/* app/static/css/secure-file-upload.css */

/* File Upload Styling */
.file-upload-container {
    position: relative;
    margin-bottom: 1rem;
}

.file-upload-error {
    border-left: 4px solid #dc3545;
    background-color: #f8d7da;
    color: #721c24;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease-in-out;
}

.file-upload-info {
    border-left: 4px solid #0dcaf0;
    background-color: #d1ecf1;
    color: #055160;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease-in-out;
}

.file-upload-success {
    border-left: 4px solid #198754;
    background-color: #d4edda;
    color: #0f5132;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease-in-out;
}

/* File input styling */
input[type="file"].is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

input[type="file"]:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Custom file upload button */
.custom-file-upload {
    display: inline-block;
    padding: 0.5rem 1rem;
    cursor: pointer;
    background-color: #0d6efd;
    color: white;
    border-radius: 0.375rem;
    border: 1px solid #0d6efd;
    transition: all 0.2s ease-in-out;
    font-size: 0.875rem;
    text-align: center;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.custom-file-upload:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    color: white;
    text-decoration: none;
}

.custom-file-upload input[type="file"] {
    position: absolute;
    left: -9999px;
    opacity: 0;
    visibility: hidden;
}

/* File preview styling */
.file-preview {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

.file-preview img {
    max-width: 60px;
    max-height: 60px;
    object-fit: cover;
    border-radius: 0.25rem;
    margin-right: 0.75rem;
}

.file-preview-info {
    flex: 1;
}

.file-preview-name {
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.25rem;
}

.file-preview-size {
    color: #6c757d;
    font-size: 0.875rem;
}

.file-preview-remove {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease-in-out;
}

.file-preview-remove:hover {
    background-color: #dc3545;
    color: white;
}

/* Progress bar for file uploads */
.file-upload-progress {
    width: 100%;
    height: 0.5rem;
    background-color: #e9ecef;
    border-radius: 0.25rem;
    overflow: hidden;
    margin-top: 0.5rem;
}

.file-upload-progress-bar {
    height: 100%;
    background-color: #0d6efd;
    border-radius: 0.25rem;
    transition: width 0.3s ease-in-out;
}

.file-upload-progress-text {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: center;
    margin-top: 0.25rem;
}

/* Drag and drop styling */
.file-drop-zone {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease-in-out;
    background-color: #f8f9fa;
    cursor: pointer;
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
    border-color: #0d6efd;
    background-color: #e7f1ff;
}

.file-drop-zone.drag-over {
    transform: scale(1.02);
}

.file-drop-zone-icon {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.file-drop-zone-text {
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.file-drop-zone-hint {
    font-size: 0.875rem;
    color: #adb5bd;
}

/* Global error notification */
#global-file-error {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    max-width: 500px;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    animation: slideDown 0.4s ease-out;
}

#global-file-error .btn-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1;
    color: currentColor;
    text-decoration: none;
    opacity: 0.5;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

#global-file-error .btn-close:hover {
    opacity: 0.75;
}

/* Loading states */
.file-upload-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.file-upload-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid transparent;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    #global-file-error {
        max-width: 90%;
        margin: 0 5%;
    }

    .file-drop-zone {
        padding: 1.5rem;
    }

    .file-preview {
        flex-direction: column;
        text-align: center;
    }

    .file-preview img {
        margin: 0 0 0.5rem 0;
    }
}

/* Bootstrap integration */
.alert.file-upload-error,
.alert.file-upload-info,
.alert.file-upload-success {
    display: flex;
    align-items: center;
    border: none;
    border-radius: 0.375rem;
}

.alert.file-upload-error i,
.alert.file-upload-info i,
.alert.file-upload-success i {
    flex-shrink: 0;
}

/* Form validation integration */
.was-validated .custom-file-upload:invalid,
.was-validated .custom-file-upload.is-invalid {
    border-color: #dc3545;
}

.was-validated .custom-file-upload:valid,
.was-validated .custom-file-upload.is-valid {
    border-color: #198754;
}

/* File type icons */
.file-type-icon {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    margin-right: 0.5rem;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.file-type-icon.pdf {
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dz0idyYz.org/2000/svgIiBmWlsbD0iI2RjMzU0NSIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMkg2QTIgMiAwIDAgMCA0IDR2MTZBIDJBIDI2IDBDMDU2OTMgNkE2c2g2VjNhMSAxIDAgMFEwIDEtMUgyViAyaDlWQiBIOFoiLz48L3JnPg==");
}

.file-type-icon.image {
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dz0idyYM29yZy8yMDAwL3N2ZyIgZmlsbD0iIzE5ODc1NCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNOSAyQTMgMyAwIDAgMCA2IDV2MTRBM0EgM0EgMDEwMS0gNiAxOGgxMmEzIDMgMCAwIDAgMy0zVjVhMyAzIDAgMCAwLTMtM3ptMCA2YTEuNSAxLjUgMCAxIDEgMCAzIDEuNSAxLjUgMCAwIDEgMC0zWm00IDEwSDZ2LTJsMyAyIDMtM2wgMy0ydjJaIi8+PC9zdmc+");
}

.file-type-icon.document {
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dz0idyYM29yZy8yMDAwL3N2ZyIgZmlsbD0iIzBkNmVmZCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTQgMkg2QTIgMiAwIDAgMCA0IDR2MTZBIDJBIDI2IDBDMDU2OTMgNkE2c2g2VjNhMSAxIDAgMFEwIDEtMUgyViAyaDlWQiBIOFoiLz48L3JnPg==");
}
