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

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --hover-color: #475569;
    --success-color: #10b981;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 2rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
}

main {
    flex: 1;
    padding: 2rem 0;
}

.controls {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.search-box {
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.collection-filters-container {
    margin-bottom: 1rem;
}

.collection-filters-container > label {
    display: block;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.collection-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.collection-filter {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.collection-filter:hover {
    border-color: var(--primary-color);
}

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

.view-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.view-controls label {
    color: var(--text-muted);
    font-weight: 500;
}

.view-controls select {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.3s;
}

.view-controls select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.stats {
    margin-bottom: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.gallery {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.gallery.small {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.gallery.medium {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.gallery.large {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.pattern-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.pattern-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3);
}

.pattern-image {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background: #fff;
    padding: 10px;
}

.pattern-info {
    padding: 0.75rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.pattern-number {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.pattern-collection {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    max-width: 90%;
    max-height: 90%;
    position: relative;
    overflow: auto;
}

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

.modal-close:hover {
    background: var(--hover-color);
}

.modal-body {
    padding: 2rem;
    position: relative;
}

#modalImage {
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    display: block;
    margin: 0 auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
}

.modal-info {
    margin-top: 1.5rem;
    text-align: center;
}

.modal-info h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-block;
}

.btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--hover-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.nav-btn.prev {
    left: -70px;
}

.nav-btn.next {
    right: -70px;
}

footer {
    background: var(--card-bg);
    padding: 1.5rem 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .gallery.small,
    .gallery.medium,
    .gallery.large {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .nav-btn.prev {
        left: 10px;
    }

    .nav-btn.next {
        right: 10px;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-actions {
        flex-direction: column;
    }
}

.no-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
