/**
 * Performance optimizations for CSS
 * Add this file to reduce UI lag and improve rendering performance
 */

/* Enable GPU acceleration for animations and transitions */
.file-row,
.directory-row,
.modal-content,
.dropdown-menu,
.alert {
    transform: translateZ(0);
    will-change: transform;
}

/* Optimize rendering for file list */
#file-list {
    contain: layout style;
}

/* Use hardware acceleration for images and animations */
.file-thumbnail img {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Preload animations to prevent stuttering */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* High-performance box shadows */
.card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.11);
}

/* Add containment to improve rendering performance */
.table-responsive {
    contain: content;
}

/* Optimize fixed position elements */
#mediaPreviewModal {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Optimize loading indicators */
.spinner-border {
    will-change: transform;
    animation-duration: 0.8s;
}

/* Image rendering optimizations */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy-image[src] {
    opacity: 1;
}

/* Optimize scrolling performance */
body {
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
}

/* Virtualization containers */
.virtual-scroll-container {
    overflow-y: auto;
    height: 100%;
    position: relative;
}

.virtual-scroll-content {
    position: absolute;
    width: 100%;
}

/* Pagination styling */
.pagination-container {
    margin: 20px 0;
}

.pagination {
    flex-wrap: wrap;
    justify-content: center;
}

/* Batch loading indicator */
.batch-loading-indicator {
    text-align: center;
    padding: 10px;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    margin: 10px 0;
    color: #666;
}

/* Floating loading indicator for slow operations */
.floating-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 8px 15px;
    display: flex;
    align-items: center;
    z-index: 1050;
    animation: fadeIn 0.3s;
}

/* Loading indicator in breadcrumbs */
.loading-spinner-small {
    display: inline-block;
    margin-left: 8px;
    opacity: 0.6;
}

/* Loading indicator fade effect to prevent abrupt removal */
.loading-spinner-small {
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.loading-spinner-small.fade-out {
    opacity: 0;
}

/* Toast notifications for feedback */
.toast-container {
    z-index: 1090;
}

.toast-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.toast-icon.success {
    background-color: #28a745;
}

.toast-icon.warning {
    background-color: #ffc107;
}

.toast-icon.error {
    background-color: #dc3545;
}

.toast-icon.info {
    background-color: #17a2b8;
}

/* Grid view for file browser */
#file-list.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px;
}

.grid-view-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    height: 160px;
    text-align: center;
    transition: all 0.2s;
}

.grid-view-item:hover {
    background-color: rgba(13, 110, 253, 0.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.grid-view-item .file-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

/* Media preview modal */
#mediaPreviewModal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
}

.modal-content {
    position: relative;
    margin: auto;
    padding: 0;
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    background: none;
    border: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close:hover {
    opacity: 1;
}

.modal-header {
    color: white;
    padding: 15px;
    text-align: center;
}

.image-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.video-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.video-container video {
    width: 100%;
    max-height: 80vh;
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Optimize images */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Improve responsive layout */
@media (max-width: 768px) {
    #file-list.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 576px) {
    .file-thumbnail {
        display: none;
    }
}

/* Media queries for slow devices */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Fix for iOS Safari mobile scroll performance */
@supports (-webkit-touch-callout: none) {
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-y: scroll;
    }
}
