/* Library Styles - Masonry Grid & Modal */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #E5E1D5;
    /*background: #1a3f3b;*/
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Header */
.logo { max-width:800px; width:96%; margin:0 auto 20px auto; }
.logo img { max-width: 100%; height: auto; }
.library-header {
    /*background: linear-gradient(135deg, #000000 0%, #E5E1D5 100%);*/
    background-color:#1B3F3B;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    color: #333;
    padding: 40px 20px 30px 20px;
    text-align: center;
    position: relative;
}

.library-header h1 {
    font-size: 1.6rem;
    margin-bottom: 10px;
    font-weight: 600;color:#D3AE63;
}

.library-header p {
    opacity: 0.9;
    margin-bottom: 0;
    font-size: 1.1rem;color:rgba(255, 255, 255, 0.7);
}

.disclaimer { font-size: 0.95rem !important; line-height: 1.4rem !important; max-width:1000px; width:96%; opacity: 0.8; margin: 10px auto; }

/* Masonry Grid */
.masonry-grid {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    column-count: 4;
    column-gap: 20px;
}

.grid-item {
    break-inside: avoid;
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 12px;
    overflow: hidden;
    background: #1a1a1a;
}

.grid-item-inner {
    position: relative;
    overflow: hidden;
}

.grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.grid-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: all 0.3s ease;
}

/* Video placeholder */
.video-placeholder {
    position: relative;
}

.video-placeholder i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 2;
    pointer-events: none;
}

.file-placeholder {
    background: #2a2a2a;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-placeholder i {
    font-size: 48px;
    color: #666;
}

/* Overlay */
.overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
    padding: 15px;
    color: white;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.grid-item:hover .overlay {
    transform: translateY(0);
}

.file-name {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.file-size {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 4px;
}

/* No results */
.no-results {
    text-align: center;
    padding: 80px 20px;
    color: #888;
    grid-column: 1 / -1;
}

.no-results i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Modal Preview */
.modal-preview {
    --bs-modal-width: 90vw;
}

.modal-preview .modal-dialog {
    max-width: 90vw;
    width: 90vw;
    margin: 1.75rem auto;
}

.modal-preview .modal-content {
    background: #1a1a1a;
    border-radius: 16px;
    min-height: 85vh;
    border: 1px rgba(255, 255, 255, 0.1) solid;
}

.modal-preview .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 1.5rem;
}

.modal-preview .modal-body {
    padding: 0;
    flex: 1 1 auto;
    min-height: 70vh;
}

.modal {
    --bs-modal-width: 95vw !important;
}

.modal-dialog {
    max-width: 95vw !important;
    width: 95vw !important;
    margin: 1rem auto !important;
}

.preview-container {
    background: #000000;
    border-radius: 0;
    margin: 0;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-container iframe {
    width: 100%;
    height: 70vh;
    border: none;
    display: block;
}

.preview-container img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.preview-container video {
    max-width: 100%;
    max-height: 70vh;
}

.modal-preview .modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 1.5rem;
}

/* Download Button */
.btn-download {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 8px 24px;
    color: white;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-download:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    color: white;
    background: linear-gradient(135deg, #5a67d8 0%, #6b46a0 100%);
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: white;
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Lazy loading fade-in */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Loading Spinner Styles */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: white;
}

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

#scrollLoader {
    background: transparent;
}

#scrollLoader .spinner {
    width: 30px;
    height: 30px;
    border-width: 2px;
}

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

/* End message */
.end-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #888;
}

.end-message i {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #28a745;
}

/* Lazy loading fade-in */
.lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Blur-up technique for mobile */
.lazy-image {
    background-color: #f0f0f0;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 24 24" fill="none" stroke="%23ccc" stroke-width="2"%3E%3Crect x="2" y="2" width="20" height="20" rx="2.18"%3E%3C/rect%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 40px;
}

.lazy-image.loaded {
    background: none;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Stats counter animation */
#fileStats {
    transition: all 0.3s ease;
}

/* Responsive adjustments for loading */
@media (max-width: 768px) {
    .loading-spinner {
        padding: 20px;
    }
    
    .spinner {
        width: 30px;
        height: 30px;
    }
}

/* ============================================
   Mobile Optimizations
   ============================================ */
@media (max-width: 768px) {
    /* Grid adjustments */
    .masonry-grid {
        column-count: 2;
        column-gap: 10px;
        padding: 10px;
    }
    
    .grid-item {
        margin-bottom: 10px;
        border-radius: 8px;
    }
    
    /* Header adjustments */
    .library-header {
        padding: 30px 15px;
    }
    
    .library-header h1 {
        font-size: 1.5rem;
    }
    
    /* MODAL ADJUSTMENTS - MAKE MODAL SMALLER */
    .modal-preview .modal-dialog {
        max-width: 95vw;
        width: 95vw;
        margin: 1rem auto;
    }
    
    .modal-preview .modal-content {
        min-height: 80vh !important;
        max-height: 85vh !important;
        border-radius: 16px;
    }
    
    .modal-preview .modal-body {
        padding: 0;
        min-height: 60vh !important;
        max-height: 65vh !important;
        overflow-y: auto;
    }
    
    .preview-container,
    .preview-container iframe,
    #previewContent iframe {
        min-height: 65vh;
        height: 65vh !important;
    }
    
    .modal-preview .modal-header {
        padding: 10px 15px;
    }
    
    .modal-preview .modal-footer {
        padding: 10px 15px;
    }
    
    /* Overlay adjustments */
    .overlay {
        transform: translateY(0);
        padding: 6px 8px;
    }
    
    .file-name {
        font-size: 10px;
        white-space: normal;
        word-break: break-word;
    }
    
    /* Button adjustments */
    .btn-download {
        padding: 8px 25px !important;
        font-size: 16px !important;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .modal-preview .modal-dialog {
        max-width: 98vw;
        width: 98vw;
        margin: 0.5rem auto;
    }
    
    .modal-preview .modal-content {
        max-height: 75vh;
        border-radius: 12px;
    }
    
    .preview-container,
    .preview-container iframe,
    #previewContent iframe {
        min-height: 30vh;
        height: 30vh;
    }
    
    .modal-preview .modal-body {
        max-height: 40vh;
    }
    
    .modal-preview .modal-header h5 {
        font-size: 14px;
    }
    
    .btn-download {
        padding: 5px 12px;
        font-size: 11px;
    }
}

/* Folder Grid */
        .folder-grid {
            max-width: 1400px;
            margin: 0 auto;
            padding: 30px 20px;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 25px;
        }

        .folder-card {
            background: #1a1a1a;
            border-radius: 16px;
            overflow: hidden;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            cursor: pointer;
            text-decoration: none;
            color: white;
            display: block;
        }

        .folder-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
            color: white;
        }

        .folder-thumbnail {
            position: relative;
            width: 100%;
            padding-bottom: 75%; /* 4:3 aspect ratio */
            overflow: hidden;
            background: #2a2a2a;
        }

        .folder-thumbnail img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        .folder-card:hover .folder-thumbnail img {
            transform: scale(1.05);
        }

        .folder-thumbnail .overlay-icon {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 3rem;
            color: rgba(255, 255, 255, 0.3);
            pointer-events: none;
            text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        }

        .folder-info {
            padding: 16px 18px;
        }

        .folder-info .folder-name {
            font-size: 1.1rem;
            font-weight: 600;
            margin-bottom: 6px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .folder-info .folder-meta {
            font-size: 0.85rem;
            color: #888;
            display: flex;
            align-items: center;
            gap: 15px;
        }

        .folder-info .folder-meta span {
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .folder-info .folder-meta i {
            font-size: 0.8rem;
        }

        /* No folders message */
        .no-folders {
            grid-column: 1 / -1;
            text-align: center;
            padding: 80px 20px;
            color: #888;
        }

        .no-folders i {
            font-size: 4rem;
            margin-bottom: 20px;
            opacity: 0.5;
        }

        /* Loading skeleton */
        .skeleton {
            background: #1a1a1a;
            border-radius: 16px;
            overflow: hidden;
        }

        .skeleton .skeleton-thumb {
            width: 100%;
            padding-bottom: 75%;
            background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s infinite;
        }

        .skeleton .skeleton-text {
            padding: 16px 18px;
        }

        .skeleton .skeleton-line {
            height: 16px;
            background: #2a2a2a;
            border-radius: 4px;
            margin-bottom: 8px;
            background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s infinite;
        }

        .skeleton .skeleton-line.short {
            width: 60%;
        }

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

        /* Responsive */
        @media (max-width: 1200px) {
            .folder-grid {
                grid-template-columns: repeat(3, 1fr);
                gap: 20px;
            }
        }

        @media (max-width: 768px) {
            .library-header {
                padding: 30px 15px;
            }

            .library-header h1 {
                font-size: 1.8rem;
            }

            .library-header .disclaimer {
                font-size: 0.9rem;
            }

            .folder-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 15px;
                padding: 15px;
            }

            .folder-info .folder-name {
                font-size: 0.95rem;
            }

            .folder-info .folder-meta {
                font-size: 0.75rem;
                gap: 10px;
            }
        }

        @media (max-width: 480px) {
            .folder-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 10px;
                padding: 10px;
            }

            .library-header h1 {
                font-size: 1.4rem;
            }

            .folder-info {
                padding: 10px 12px;
            }

            .folder-info .folder-name {
                font-size: 0.85rem;
            }

            .folder-info .folder-meta {
                font-size: 0.7rem;
                gap: 8px;
            }

            .folder-thumbnail .overlay-icon {
                font-size: 2rem;
            }
        }

        /* Scrollbar styling */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        ::-webkit-scrollbar-track {
            background: #1a1a1a;
        }

        ::-webkit-scrollbar-thumb {
            background: #667eea;
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #764ba2;
        }