/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 200ms ease-in-out;
    --transition-slow: 300ms ease-in-out;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
    padding-bottom: var(--spacing-xl);
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ===== CONTROLS ===== */
.controls {
    background: var(--surface);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-xl);
}

/* Search Bar */
.search-container {
    position: relative;
    margin-bottom: var(--spacing-lg);
}

.search-container input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    background: var(--background);
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    color: var(--text-secondary);
    pointer-events: none;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-bottom: var(--spacing-lg);
}

.filter-btn {
    padding: 0.625rem 1.25rem;
    border: 2px solid var(--border-color);
    background: var(--surface);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    flex: 1;
    min-width: 120px;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.filter-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Sort Container */
.sort-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.sort-container label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.sort-container select {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    background: var(--background);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.sort-container select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== STATS ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-item {
    background: var(--surface);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== GALLERY ===== */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.gallery-item {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    cursor: pointer;
    opacity: 0;
    animation: fadeIn 0.4s ease-in-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.gallery-item-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background: var(--background);
}

.gallery-item-image.lazy {
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.gallery-item-image.loaded {
    opacity: 1;
}

.gallery-item-content {
    padding: var(--spacing-lg);
}

.gallery-item-question {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-item-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.gallery-item-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.gallery-item-topic {
    padding: 0.25rem 0.75rem;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
}

.gallery-item-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== NO RESULTS ===== */
.no-results {
    text-align: center;
    padding: var(--spacing-2xl);
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.no-results p {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

/* ===== LOADING ===== */
.loading {
    text-align: center;
    padding: var(--spacing-2xl);
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto var(--spacing-md);
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ===== LIGHTBOX ===== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: transform var(--transition-fast);
}

.lightbox-close:hover {
    transform: scale(1.1);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 3rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    line-height: 1;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-info {
    background: var(--surface);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-top: var(--spacing-lg);
    width: 100%;
    max-width: 800px;
    box-shadow: var(--shadow-lg);
}

.lightbox-details h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.lightbox-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.lightbox-details p:last-child {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.lightbox-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

.btn-download {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-download:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-download span {
    font-size: 1.25rem;
}

.lightbox-counter {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: var(--spacing-md);
    }
    
    .filter-buttons {
        flex-direction: column;
    }
    
    .filter-btn {
        width: 100%;
    }
    
    .lightbox-nav {
        font-size: 2rem;
        padding: 0.5rem 1rem;
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-close {
        top: -40px;
        font-size: 2.5rem;
    }
    
    .lightbox-info {
        max-width: 95%;
    }
    
    .stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: 1fr;
    }
    
    .gallery-item-image {
        height: 200px;
    }
    
    .lightbox-image {
        max-height: 60vh;
    }
    
    .lightbox-actions {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: stretch;
    }
    
    .btn-download {
        width: 100%;
        justify-content: center;
    }
    
    .lightbox-counter {
        text-align: center;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Styles for Keyboard Navigation */
button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
