/* Multiple Upload Form Element Styles */

.enhanced-upload-wrapper {
    margin-bottom: 1rem;
}

.file-drop-zone {
    border: 2px dashed #dee2e6;
    border-radius: 0.375rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
    position: relative;
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
    border-color: #495057;
    background: #e7f3ff;
    transform: translateY(-1px);
}

.drop-zone-content svg {
    color: #6c757d;
    margin-bottom: 1rem;
    transition: color 0.3s ease;
}

.file-drop-zone:hover .drop-zone-content svg,
.file-drop-zone.drag-over .drop-zone-content svg {
    color: #0d6efd;
}

.drop-zone-content p {
    margin: 0 0 0.5rem 0;
    color: #6c757d;
    font-size: 1.1rem;
    font-weight: 500;
}

.browse-link {
    color: #6c757d;
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
}

.browse-link:hover {
    color: #6c757d;
}

.drop-zone-content small {
    color: #6c757d;
    font-size: 0.875rem;
}

.max-size-display {
    font-weight: 600;
    color: #495057;
}

/* File preview and existing files areas */
.file-preview-area,
.existing-files {
    margin-top: 1rem;
}

/* Hide preview area when empty */
.file-preview-area:empty {
    display: none;
}

/* Hide existing files when empty */
.existing-files:empty {
    display: none;
}

.existing-files h4 {
    font-size: 1rem;
    color: #495057;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.file-preview,
.existing-file-item {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: all 0.3s ease;
}

.file-preview:hover,
.existing-file-item:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.file-preview.new-file {
    border-left: none;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.existing-file-item {
    border-left: 4px solid #17a2b8;
}

.existing-file-item.marked-for-removal {
    border-left-color: #dc3545;
    background: #f8f9fa;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.image-preview {
    flex-shrink: 0;
}

.image-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
}

.file-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.file-details {
    flex-grow: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.25rem;
    word-break: break-word;
    line-height: 1.4;
}

.file-size {
    color: #6c757d;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.file-type {
    color: #6c757d;
    font-size: 0.75rem;
    font-family: monospace;
    background: #f8f9fa;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    display: inline-block;
}

/* Hide file type for new files */
.file-preview.new-file .file-type {
    display: none;
}

.remove-file,
.remove-existing-file {
    background: #dc3545;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    font-weight: bold;
}

/* Make remove button smaller and gray for new files */
.file-preview.new-file .remove-file {
    background: #6c757d;
    width: 24px;
    height: 24px;
    font-size: 0.875rem;
}

.file-preview.new-file .remove-file:hover {
    background: #5a6268;
    transform: scale(1.1);
}

.remove-file:hover,
.remove-existing-file:hover {
    background: #c82333;
    transform: scale(1.1);
}

.restore-file {
    background: #28a745 !important;
    font-size: 1rem !important;
}

.restore-file:hover {
    background: #218838 !important;
}

/* Upload Progress */
.upload-progress {
    margin-top: 0.75rem;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #0b5ed7);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* Error Display */
.file-upload-error {
    background: #f8d7da;
    color: #721c24;
    padding: 0.75rem 1rem;
    border: 1px solid #f5c6cb;
    border-radius: 0.375rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    display: none;
}

.file-upload-error:before {
    content: "\26a0\fe0f ";
    margin-right: 0.5rem;
}

/* Integration with Bootstrap/TYPO3 form classes */
.tx-form .enhanced-upload-wrapper {
    margin-bottom: 1.5rem;
}

.form-group .enhanced-upload-wrapper {
    margin-top: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .file-drop-zone {
        padding: 1.5rem 1rem;
    }

    .drop-zone-content p {
        font-size: 1rem;
    }

    .file-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        position: relative;
    }

    .image-preview,
    .file-icon {
        align-self: center;
    }

    .remove-file,
    .remove-existing-file {
        position: absolute;
        top: -0.5rem;
        right: -0.5rem;
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }

    .file-preview,
    .existing-file-item {
        padding: 1rem 1rem 1.5rem 1rem;
    }
}

@media (max-width: 480px) {
    .file-drop-zone {
        padding: 1rem 0.75rem;
    }

    .drop-zone-content svg {
        width: 36px;
        height: 36px;
    }

    .drop-zone-content p {
        font-size: 0.9rem;
    }
}

/* Animation for file additions */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-preview.new-file,
.existing-file-item {
    animation: slideInUp 0.3s ease;
}

/* Focus states for accessibility */
.file-drop-zone:focus-within {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

.remove-file:focus,
.remove-existing-file:focus,
.restore-file:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Validation states integration with TYPO3 form validation */
.has-error .enhanced-upload-wrapper .file-drop-zone {
    border-color: #dc3545;
}

.has-error .enhanced-upload-wrapper .file-drop-zone:hover,
.has-error .enhanced-upload-wrapper .file-drop-zone.drag-over {
    border-color: #c82333;
    background: #fff5f5;
}

.has-success .enhanced-upload-wrapper .file-drop-zone {
    border-color: #28a745;
}

/* Custom scrollbar for preview areas with many files */
.file-preview-area {
    max-height: 400px;
    overflow-y: auto;
}

.file-preview-area::-webkit-scrollbar {
    width: 8px;
}

.file-preview-area::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.file-preview-area::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.file-preview-area::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Print styles */
@media print {
    .file-drop-zone,
    .remove-file,
    .remove-existing-file,
    .upload-progress {
        display: none !important;
    }

    .file-preview,
    .existing-file-item {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        background: white !important;
        break-inside: avoid;
    }

    .file-name {
        color: #000 !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .file-drop-zone {
        border-width: 3px;
        border-color: #000;
    }

    .file-drop-zone:hover,
    .file-drop-zone.drag-over {
        background: #fff;
        border-color: #0000ff;
    }

    .remove-file,
    .remove-existing-file {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }

    .file-preview,
    .existing-file-item {
        border: 2px solid #000;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .file-drop-zone,
    .file-preview,
    .existing-file-item,
    .remove-file,
    .remove-existing-file,
    .progress-bar {
        transition: none !important;
        animation: none !important;
    }

    .file-preview:hover,
    .existing-file-item:hover {
        transform: none !important;
    }
}

/* Hide the native file input */
.existing-files input[type="file"] {
    display: none;
}
