:root {
    --primary-color: #2196F3;
    --secondary-color: #00A8F3;
    --background-color: #1B1B1B;
    --card-bg: #2A2A2A;
    --text-primary: #FFFFFF;
    --text-secondary: #BBBBBB;
    --border-color: #3A3A3A;
    --padding: 12px;
    --border-radius: 4px;
    --font-size: 14px;
    --box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    --hover-box-shadow: 0 5px 15px rgba(33,150,243,0.2);
    --transition-duration: 0.3s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Roboto', sans-serif;
}

body, html {
    height: 100%;
}

body {
    background-color: var(--background-color);
    color: var(--text-primary);
}

.flex-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

header {
    margin-bottom: 30px;
}

h1 {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 28px;
    margin-bottom: 20px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    width: 100%;
}

[data-search] {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: var(--padding);
    border-radius: var(--border-radius);
    flex: 1;
}

[data-search]::placeholder {
    color: var(--text-secondary);
}

.filter-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.categories-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.category-button {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: var(--padding);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--font-size);
}

.category-button.active {
    background: var(--primary-color);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.category-button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.category-button.active:hover {
    color: var(--text-primary);
}

[data-material-grid] {
    column-count: 4;
    column-gap: 20px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    min-height: 200px;
}

[data-material-grid]:empty::after {
    content: 'No snippets found';
    display: block;
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
    font-size: 16px;
}

.material-card {
    display: inline-block;
    width: 100%;
    margin-bottom: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    transition: transform 0.2s, opacity var(--transition-duration), border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    opacity: 1;
    animation: fadeIn var(--transition-duration) ease-in;
    position: relative;
}

.material-card:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.material-card.hide {
    opacity: 0;
    transform: scale(0.95);
    animation: fadeOut var(--transition-duration) ease-out;
}

.material-card.show {
    opacity: 1;
    transform: scale(1);
}

.material-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--hover-box-shadow);
}

.material-preview {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.material-info {
    padding: 15px;
}

.material-info h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
}

.material-info p {
    color: var(--text-secondary);
    font-size: 14px;
}

.material-info .author {
    color: var(--text-primary);
    font-size: 12px;
    margin-top: 5px;
    margin-bottom: 10px;
    font-weight: bold;
}

.material-tags {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: var(--border-radius);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.tag:hover {
    background: var(--primary-color);
    color: var(--text-primary);
}

.tag:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}

.copy-notification {
    position: fixed;
    background: var(--primary-color);
    color: white;
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-size: 14px;
    pointer-events: none;
    transform: translate(-50%, 0);
    animation: floatUp 1s ease-out forwards;
    z-index: 1000;
    box-shadow: var(--hover-box-shadow);
    font-weight: 500;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -30px);
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.95);
    }
}

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

#convert-button {
    display: none;
}

footer {
    background-color: var(--background-color);
    color: var(--text-secondary);
    padding: 20px 0;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.footer-content p {
    margin: 0;
    font-size: var(--font-size);
}

.footer-content nav {
    display: flex;
    gap: 20px;
}

.footer-content nav a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-content nav a:hover {
    color: var(--primary-color);
}

.add-snippet-button {
    display: flex;
    align-items: center;
    background-color: #28a745;
    color: #fff;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s;
}

.add-snippet-button svg {
    width: 20px;
    height: 20px;
    margin-right: 8px;
}

.add-snippet-button:hover {
    background-color: #218838;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

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

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Clear Filters Button */
.clear-filters-button {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: var(--padding);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: var(--font-size);
}

.clear-filters-button:hover {
    background: var(--primary-color);
    color: var(--text-primary);
}

/* Result Count */
.result-count {
    text-align: right;
    color: var(--text-secondary);
    font-size: var(--font-size);
    margin-bottom: 20px;
}

.result-count span {
    color: var(--primary-color);
    font-weight: 500;
}

/* Mobile Responsiveness */
@media (max-width: 1200px) {
    [data-material-grid] {
        column-count: 3;
    }
}

@media (max-width: 900px) {
    [data-material-grid] {
        column-count: 2;
    }
    
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

@media (max-width: 600px) {
    [data-material-grid] {
        column-count: 1;
    }
    
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 22px;
    }
    
    .categories-filter {
        justify-content: flex-start;
    }
    
    .category-button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .add-snippet-button {
        width: 100%;
        justify-content: center;
    }
}
