/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #D2B48C;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.main-navigation {
    background-color: #000000;
    padding: 0.75rem 0;
    position: relative;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
}

.logo-image {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.nav-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-home-link,
.nav-rahw-link {
    background-color: #ffffff;
    color: #000000;
    padding: 0.5rem 1.5rem;
    text-decoration: none;
    font-weight: 700;
    border-radius: 4px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.nav-home-link:hover,
.nav-rahw-link:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Header */
.library-header {
    position: relative;
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.header-image-container {
    height: 300px;
    overflow: hidden;
    position: relative;
}

.header-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.7);
}

.header-text-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    text-align: center;
}

.library-title {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 0.5rem;
}

.library-subtitle {
    font-size: 1.2rem;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    opacity: 0.9;
    line-height: 1.4;
}

/* Main content */
.library-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    flex: 1;
}

/* Filter section */
.filter-section {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
}

.filter-group {
    flex: 1;
    min-width: 250px;
}

.filter-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
}

.filter-dropdown {
    width: 100%;
    padding: 0.75rem;
    border: 3px solid #000000;
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
    transition: border-color 0.3s ease;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.filter-dropdown:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

/* Content grid */
.content-section {
    margin-bottom: 3rem;
}

.four-column-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.thumbnail-item {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.thumbnail-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.thumbnail-image {
    width: 100%;
    height: 200px;
    object-fit: contain;
    padding: 1rem;
    background-color: #f8f9fa;
}

.thumbnail-info {
    padding: 1rem;
    background: white;
    border-top: 1px solid #eee;
}

.thumbnail-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.thumbnail-author {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Lightbox modal */
.lightbox-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.lightbox-modal.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    z-index: 2001;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-media-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.lightbox-media-container video,
.lightbox-media-container audio,
.lightbox-media-container iframe {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.lightbox-media-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* PDF and PPT specific styles */
.lightbox-media-container object,
.lightbox-media-container embed {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Footer */
.library-footer {
    text-align: center;
    padding: 2rem;
    background: #2c3e50;
    color: white;
    margin-top: 3rem;
    border-radius: 10px 10px 0 0;
}

.footer-note {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Responsive design */
@media (max-width: 1024px) {
    .four-column-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .library-title {
        font-size: 2rem;
    }
    
    .library-subtitle {
        font-size: 1rem;
    }
    
    .header-image-container {
        height: 200px;
    }
    
    .filter-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .four-column-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-home-link,
    .nav-rahw-link {
        width: 100%;
        text-align: center;
    }
    
    .lightbox-media-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .library-title {
        font-size: 1.5rem;
    }
    
    .library-subtitle {
        font-size: 0.9rem;
    }
    
    .four-column-grid {
        grid-template-columns: 1fr;
    }
    
    .nav-home-link,
    .nav-rahw-link {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
    }
    
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
}

/* Loading state for thumbnails */
.thumbnail-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Centering for all text elements */
.library-header h1,
.library-header p,
.filter-label {
    text-align: center;
}

/* SVG thumbnail specific styles */
.thumbnail-image[src$=".svg"] {
    background-color: #ffffff;
    padding: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.thumbnail-image[src$=".svg"]:hover {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

/* Selected thumbnail highlight */
.thumbnail-item.selected {
    border: 3px solid #2c3e50;
    box-shadow: 0 5px 20px rgba(44, 62, 80, 0.3);
}

/* Filter selection feedback */
.filter-dropdown option:checked {
    background-color: #2c3e50;
    color: white;
}

.filter-dropdown option:hover {
    background-color: #f0f0f0;
}

/* Smooth transitions for filter changes */
.thumbnail-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, border 0.3s ease;
}

.thumbnail-item.hidden {
    opacity: 0.3;
    pointer-events: none;
}

/* Accessibility improvements */
.filter-dropdown:focus-visible {
    outline: 2px solid #2c3e50;
    outline-offset: 2px;
}

.thumbnail-item:focus-within {
    outline: 2px solid #2c3e50;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .main-navigation,
    .filter-section,
    .lightbox-modal,
    .library-footer {
        display: none;
    }
    
    .thumbnail-item {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .thumbnail-image {
        height: 150px;
    }
}

/* Lightbox media type indicators */
.thumbnail-item::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}

.thumbnail-item[data-media-type="video"]::after {
    content: '▶';
}

.thumbnail-item[data-media-type="audio"]::after {
    content: '♪';
}

.thumbnail-item[data-media-type="pdf"]::after {
    content: 'PDF';
    font-size: 10px;
}

.thumbnail-item[data-media-type="ppt"]::after {
    content: 'PPT';
    font-size: 10px;
}

/* Lightbox animation */
.lightbox-modal {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox-modal.active {
    opacity: 1;
}

.lightbox-content {
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox-modal.active .lightbox-content {
    transform: scale(1);
}