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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --success: #10b981;
    --radius: 12px;
    
    /* Default to dark theme */
    --background: #0f172a;
    --background-gradient: #1e293b;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --image-bg: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    --pattern-opacity: 0.02;
}

/* Dark theme */
:root[data-theme="dark"] {
    --background: #0f172a;
    --background-gradient: #1e293b;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --image-bg: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    --pattern-opacity: 0.02;
}

/* Light theme */
:root[data-theme="light"] {
    --background: #f8fafc;
    --background-gradient: #e2e8f0;
    --surface: #ffffff;
    --surface-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --image-bg: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --pattern-opacity: 0.03;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, var(--background-gradient) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 2rem 0;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px var(--shadow);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.site-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
}

.theme-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-light);
    border: 2px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.theme-toggle:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: rotate(15deg);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    position: absolute;
    transition: all 0.3s ease;
}

.theme-toggle .sun-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.theme-toggle .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

:root[data-theme="light"] .theme-toggle .sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

:root[data-theme="light"] .theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.controls {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-box {
    position: relative;
    max-width: 500px;
}

.search-box input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

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

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

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

.results-count {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.gallery-item {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
    cursor: pointer;
    animation: fadeIn 0.5s ease;
}

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

.gallery-item:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 20px 25px -5px var(--shadow),
                0 10px 10px -5px var(--shadow);
}

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

.image-container {
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--image-bg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.image-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, 
        transparent 45%, 
        rgba(255,255,255,var(--pattern-opacity)) 50%, 
        transparent 55%);
    background-size: 30px 30px;
}

.image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 1;
}

.file-icon {
    width: 80px;
    height: 80px;
    color: var(--primary-color);
    opacity: 0.7;
}

.item-info {
    padding: 1.25rem;
}

.item-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    word-break: break-word;
}

.item-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.pdf {
    background: #ef4444;
}

.badge.png {
    background: #10b981;
}

.badge.svg {
    background: #f59e0b;
}

.badge.ai {
    background: #8b5cf6;
}

.item-path {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--surface-light);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-icon:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 12px -3px rgba(99, 102, 241, 0.3);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    border: 2px solid var(--border);
    box-shadow: 0 25px 50px -12px var(--shadow);
    animation: slideUp 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--surface-light);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--primary-color);
    transform: rotate(90deg);
}

.modal-body {
    display: flex;
    gap: 2rem;
    padding: 2rem;
}

#modalImage {
    max-width: 600px;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

.modal-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 300px;
}

.modal-info h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

#modalPath {
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .site-logo {
        height: 40px;
    }
    
    .header-content {
        gap: 1rem;
    }
    
    .header-left {
        gap: 1rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .modal-body {
        flex-direction: column;
    }
    
    #modalImage {
        max-width: 100%;
    }
    
    .modal-info {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 100px;
    height: 100px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--surface);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    box-shadow: 0 20px 25px -5px var(--shadow),
                0 10px 10px -5px var(--shadow);
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 10000;
    max-width: 300px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-color: var(--success);
    background: var(--success);
    color: white;
}

.toast-error {
    border-color: #ef4444;
    background: #ef4444;
    color: white;
}

.toast-warning {
    border-color: #f59e0b;
    background: #f59e0b;
    color: white;
}

@media (max-width: 768px) {
    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
}

