

.gallery-window a,
.gallery-window a:visited,
.gallery-window a:hover,
.gallery-window a:active {
    color: black !important;
    text-decoration: none !important;
}

.gallery-categories {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.category-btn {
    background: white;
    border: 1px solid black;
    padding: 8px 16px;
    font-family: 'Chicago', 'Courier New', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-btn:hover {
    background: #f0f0f0;
}

.category-btn.active {
    background: black;
    color: white;
}


.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 25px;
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    border: 2px inset #ccc;
    padding: 25px;
    background: #e6e6e6;
}

.gallery-item {
    position: relative;
    cursor: pointer;
    border: 2px outset #ccc;
    overflow: visible;
    transition: all 0.1s ease;
    background: #e6e6e6;
    padding: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 130px;
    justify-content: center;
}

.gallery-item:hover {
    border: 2px inset #ccc;
    background: #d0d0d0;
}

.gallery-item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    display: block;
    border: 1px solid black;
    margin-bottom: 8px;
    image-rendering: auto; 
    image-rendering: -webkit-optimize-contrast; 
    image-rendering: crisp-edges; 
    -webkit-backface-visibility: hidden; 
    backface-visibility: hidden; 
    -webkit-transform: translateZ(0); 
    transform: translateZ(0);
}


.gallery-item img.pdf-thumbnail-img {
    width: auto !important;
    height: auto !important;
    max-width: 100px !important;
    max-height: 130px !important;
    object-fit: contain !important;
    border: 1px solid #ccc !important;
}


.gallery-item img[src$=".svg"] {
    object-fit: contain; 
    image-rendering: auto;
    shape-rendering: geometricPrecision;
}

.gallery-overlay {
    position: static;
    background: transparent;
    color: black;
    padding: 0;
    transform: none;
    transition: none;
}

.gallery-info h4 {
    font-size: 14px;
    margin: 0;
    font-weight: bold;
    font-family: 'Chicago', 'Courier New', monospace;
    text-align: center;
    color: black;
}

.gallery-info p {
    font-size: 8px;
    margin: 0;
    color: #666;
    display: none;
}


.gallery-info-panel {
    margin-top: 15px;
    padding: 10px;
    background: #f8f8f8;
    border: 1px solid black;
}

.info-stats {
    display: flex;
    gap: 15px;
    font-size: 10px;
}

.stat-item {
    display: flex;
    align-items: center;
}

.stat-item strong {
    font-weight: bold;
}


.image-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-lightbox-container {
    background: white;
    border: 2px solid black;
    max-width: 95vw;
    max-height: 95vh;
    height: auto;
    min-height: 80vh;
    width: 90vw;
    display: flex;
    flex-direction: column;
    font-family: 'Chicago', 'Courier New', monospace;
    position: relative;
}


.image-lightbox-container:has(img[src$=".svg"]) {
    width: 95vw;
    max-width: 95vw;
    height: auto;
    min-height: 85vh;
}

.lightbox-header {
    background: #e6e6e6;
    border-bottom: 1px solid black;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
    user-select: none;
    min-height: 32px;
}

.lightbox-title {
    color: black;
    flex-grow: 1;
    text-align: left;
    margin-right: 15px;
    font-size: 14px;
    font-weight: bold;
}

.image-lightbox-close {
    width: 20px;
    height: 20px;
    background: white;
    border: 1px solid black;
    color: black;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-lightbox-close:hover {
    background: #f0f0f0;
}

.image-lightbox-close:active {
    background: #d0d0d0;
}



.lightbox-controls {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.lightbox-controls button {
    background: white;
    border: 1px solid black;
    width: 24px;
    height: 22px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Chicago', 'Courier New', monospace;
    font-weight: bold;
    flex-shrink: 0;
}

.lightbox-controls button:hover {
    background: #f0f0f0;
}

.lightbox-controls button:active {
    background: #d0d0d0;
}

.lightbox-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0;
    padding-bottom: 50px;
}

.lightbox-image-container {
    flex: 1;
    position: relative;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    background: white;
    border: 1px solid black;
}


.lightbox-image-container:has(img[src$=".svg"]) {
    min-height: 600px;
    padding: 10px;
    width: 100%;
    max-width: none;
}

#lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: grab;
    border: 1px solid black;
    image-rendering: auto; 
    image-rendering: -webkit-optimize-contrast;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    will-change: transform;
    
    shape-rendering: geometricPrecision;
    
    image-resolution: from-image;
}


#lightbox-image[src$=".svg"] {
    image-rendering: auto;
    -webkit-interpolation-mode: bicubic;
    shape-rendering: geometricPrecision;
    
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    max-height: 85vh !important;
    min-width: none !important;
    min-height: none !important;
    object-fit: contain;
    object-position: center;
}

#lightbox-image:active {
    cursor: grabbing;
}

.zoom-indicator {
    position: absolute;
    top: 15px;
    right: 15px;
    background: white;
    color: black;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: bold;
    border: 1px solid black;
    min-width: 50px;
    text-align: center;
}

.lightbox-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to bottom, #f0f0f0, #d0d0d0);
    border-top: 1px solid black;
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
    box-sizing: border-box;
}

.image-counter {
    font-size: 12px;
    font-weight: bold;
    color: black;
    background: white;
    padding: 4px 8px;
    border: 1px solid black;
    border-radius: 0;
    line-height: 1;
}

.image-info {
    text-align: right;
    line-height: 1.2;
}

.image-filename {
    font-size: 12px;
    font-weight: bold;
    color: black;
    margin-bottom: 3px;
    line-height: 1.2;
}

.image-category {
    font-size: 11px;
    color: #666;
    background: white;
    padding: 3px 8px;
    border: 1px solid black;
    font-style: italic;
    line-height: 1.1;
    display: inline-block;
}


.gallery-item {
    animation: fadeIn 0.3s ease;
}

.gallery-item.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gallery-grid::-webkit-scrollbar {
    width: 16px;
}

.gallery-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border: 1px solid black;
}

.gallery-grid::-webkit-scrollbar-thumb {
    background: #bbb;
    border: 1px solid black;
}

.gallery-grid::-webkit-scrollbar-thumb:hover {
    background: #999;
}


@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 10px;
        max-height: 300px;
        padding: 15px;
    }
    
    .gallery-categories {
        gap: 4px;
        padding: 8px;
    }
    
    .category-btn {
        padding: 6px 10px;
        font-size: 10px;
        min-width: 60px;
    }
    
    .image-lightbox-container {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .lightbox-controls button {
        width: 22px;
        height: 20px;
        font-size: 11px;
    }
    
    .gallery-info-panel {
        padding: 10px;
    }
    
    .info-stats {
        gap: 10px;
        font-size: 10px;
    }
    
    .stat-item {
        padding: 4px 8px;
        min-width: 60px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
        padding: 10px;
    }
    
    .gallery-categories {
        justify-content: flex-start;
        overflow-x: auto;
        padding: 8px;
    }
    
    .category-btn {
        padding: 5px 8px;
        font-size: 9px;
        min-width: 50px;
        flex-shrink: 0;
    }
    
    .lightbox-image-container {
        min-height: 300px;
    }
    
    .lightbox-header {
        padding: 6px 10px;
    }
    
    .lightbox-title {
        font-size: 12px;
    }
    
    .lightbox-footer {
        padding: 8px 10px;
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
}


.gallery-grid {
    scroll-behavior: smooth;
}


.gallery-item img[src=""] {
    background: #f0f0f0;
}



@keyframes borderGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}


.category-btn:focus,
.lightbox-controls button:focus {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

.gallery-item:focus {
    outline: 3px solid #1976d2;
    outline-offset: 3px;
}


.gallery-item img {
    transition: opacity 0.3s ease;
}

.gallery-item img[src=""] {
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.4; }
}


.window-content {
    scrollbar-width: thin;
    scrollbar-color: #bbb #f1f1f1;
}

.window-content::-webkit-scrollbar {
    width: 12px;
}

.window-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border: 1px inset #ddd;
}

.window-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #ccc 0%, #aaa 100%);
    border: 1px outset #bbb;
}

.window-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #aaa 0%, #888 100%);
}


.pdf-thumbnail {
    max-width: 80px;   
    max-height: 104px; 
    width: auto;
    height: auto;
    border: 1px solid black;
    margin: 0 auto 8px auto;
    transition: all 0.2s ease;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}


.pdf-thumbnail-img {
    width: auto !important;
    height: auto !important;
    max-width: 100px;  
    max-height: 130px; 
    object-fit: contain !important; 
    image-rendering: auto !important;
    image-rendering: -webkit-optimize-contrast !important;
    border: 1px solid #ccc;
    margin: 0 auto 8px auto;
    transition: all 0.2s ease;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: block;
}


.pdf-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: contain; 
    image-rendering: auto !important;
    image-rendering: -webkit-optimize-contrast !important;
    border: none;
    margin: 0;
}


.pdf-thumbnail.loading {
    width: 80px;   
    height: 104px; 
    background: linear-gradient(135deg, #d32f2f, #b71c1c);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    box-shadow: inset 1px 1px 0 rgba(255,255,255,0.3), inset -1px -1px 0 rgba(0,0,0,0.3);
}

.pdf-icon {
    color: white;
    font-family: 'Chicago', monospace;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.5);
}

.gallery-item[data-pdf] {
    background: #f5f5f5;
}

.gallery-item[data-pdf]:hover .pdf-thumbnail {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.gallery-item[data-pdf]:hover .pdf-thumbnail-img {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}


.gallery-item[data-pdf]:hover .pdf-thumbnail.loading {
    box-shadow: 
        inset 1px 1px 0 rgba(255,255,255,0.3), 
        inset -1px -1px 0 rgba(0,0,0,0.3),
        0 4px 8px rgba(0,0,0,0.2);
}

.gallery-item[data-pdf] .gallery-info h4::after {
    content: " ";
    font-size: 10px;
    margin-left: 4px;
}