/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header"
        "sidebar content";
    min-height: 100vh;
}

/* Header */
header {
    grid-area: header;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.search-container {
    max-width: 600px;
}

#search {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Sidebar */
.sidebar {
    grid-area: sidebar;
    background: white;
    padding: 1.5rem;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    overflow-y: auto;
}

.filter-section {
    margin-bottom: 2rem;
}

.filter-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #667eea;
}

#publisher-filter {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

#category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-chip {
    padding: 0.4rem 0.8rem;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.category-chip:hover {
    background: #e0e0e0;
}

.category-chip.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.filter-section label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-secondary {
    width: 100%;
    padding: 0.75rem;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

/* Content */
.content {
    grid-area: content;
    padding: 2rem;
    overflow-y: auto;
}

.stats {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: #666;
}

#book-count {
    font-weight: bold;
    color: #667eea;
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.book-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.book-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f0f0f0;
}

.book-card-content {
    padding: 1rem;
}

.book-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #333;
    line-height: 1.3;
}

.book-card .author {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.book-card .publisher {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.75rem;
}

.book-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.book-categories .chip {
    padding: 0.2rem 0.5rem;
    background: #e8eaf6;
    color: #667eea;
    border-radius: 12px;
    font-size: 0.75rem;
}

.book-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.book-links a {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.book-links a:hover {
    background: #5568d3;
}

.book-links a.secondary {
    background: #f0f0f0;
    color: #667eea;
}

.book-links a.secondary:hover {
    background: #e0e0e0;
}

.enriched-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: #4caf50;
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: #999;
    font-size: 1.1rem;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: #999;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "sidebar"
            "content";
    }

    .sidebar {
        box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }

    header h1 {
        font-size: 1.5rem;
    }

    .books-grid {
        grid-template-columns: 1fr;
    }
}
