/* Book Discovery Layout */
.books-layout {
    display: flex;
    min-height: 100vh;
    background: #f5f5f5;
}

/* Sidebar */
.books-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 300px;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
    color: white;
    padding: 1.5rem 1.2rem;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
    z-index: 100;
    box-sizing: border-box;
}

.books-sidebar-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.books-sidebar-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 0.3rem 0;
    letter-spacing: 0.5px;
}

.books-sidebar-subtitle {
    font-size: 0.78rem;
    opacity: 0.65;
    margin: 0;
}

/* Search bar */
.books-search-wrap {
    margin-bottom: 1.5rem;
}

.books-search-wrap label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.75;
    margin-bottom: 0.5rem;
}

.books-search-box {
    display: flex;
    gap: 0.4rem;
}

.books-search-input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.books-search-input::placeholder { color: rgba(255,255,255,0.45); }
.books-search-input:focus {
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.15);
}

.books-search-btn {
    padding: 0.55rem 0.8rem;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 0.88rem;
    transition: background 0.2s;
}
.books-search-btn:hover { background: rgba(255,255,255,0.25); }

/* Genre chips */
.books-genre-section label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.75;
    margin-bottom: 0.6rem;
}

.books-genre-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.genre-chip {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.85);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.genre-chip:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.genre-chip.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
    font-weight: 600;
}

/* Back to home link */
.books-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.82rem;
    margin-top: 2rem;
    transition: color 0.2s;
}
.books-back-link:hover { color: white; }

/* Main content */
.books-main {
    margin-left: 300px;
    flex: 1;
    padding: 1.5rem 2rem;
    min-width: 0;
}

.books-header {
    margin-bottom: 1.2rem;
}

.books-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 0.25rem 0;
}

.books-page-subtitle {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

/* Status / loading */
.books-status {
    color: #555;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    min-height: 1.2rem;
}

.books-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: #1a1a2e;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
}

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

/* Error banner */
.books-error {
    background: #fff3f3;
    border: 1px solid #fcc;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: #c0392b;
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
}

/* Book grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.2rem;
}

/* Book card */
.book-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}

.book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.13);
}

.book-cover-wrap {
    background: #f0f0f0;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.book-source-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding: 0.18rem 0.45rem;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0.92;
}

.badge-nyt  { background: #000; color: #fff; }
.badge-ol   { background: #2c6e49; color: #fff; }
.badge-google { background: #4285f4; color: #fff; }

.book-cover-wrap:hover .book-cover {
    opacity: 0.88;
    transform: scale(1.03);
    transition: opacity 0.2s, transform 0.2s;
}

.book-title-link {
    text-decoration: none;
    color: inherit;
}

.book-title-link:hover .book-title {
    color: #e94560;
    text-decoration: underline;
}

.book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-cover-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
    font-size: 2.5rem;
}

.book-body {
    padding: 0.85rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.book-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    font-size: 0.78rem;
    color: #555;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-date {
    font-size: 0.72rem;
    color: #999;
    margin: 0;
}

.book-snippet {
    font-size: 0.78rem;
    color: #666;
    line-height: 1.4;
    margin: 0.2rem 0 0 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}


.book-summary-btn {
    font-size: 0.75rem;
    color: #e94560;
    background: none;
    border: 1px solid #e94560;
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.book-summary-btn:hover:not(:disabled) {
    background: #e94560;
    color: white;
}
.book-summary-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Summary panel */
.book-summary-panel {
    margin-top: 0.6rem;
    padding: 0.65rem 0.75rem;
    background: #f7f7fb;
    border-left: 3px solid #e94560;
    border-radius: 0 6px 6px 0;
    font-size: 0.78rem;
    color: #333;
    line-height: 1.5;
    display: none;
}

.book-summary-panel.visible { display: block; }

.book-summary-error {
    color: #c0392b;
    font-style: italic;
}

/* Empty state */
.books-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}
.books-empty-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.books-empty-text { font-size: 1rem; }

/* Year filter pills */
.books-year-filter {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1.2rem;
}

.year-filter-label {
    font-size: 0.78rem;
    color: #999;
    margin-right: 0.2rem;
}

.year-btn {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 1px solid #ccc;
    background: none;
    font-size: 0.78rem;
    color: #666;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.year-btn:hover { border-color: #e94560; color: #e94560; }

.year-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
    font-weight: 600;
}

/* Source tabs (Bestsellers / New Releases) */
.books-source-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1.2rem;
}

.source-tab {
    padding: 0.5rem 1.2rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    transition: color 0.2s, border-bottom-color 0.2s;
}

.source-tab:hover { color: #1a1a2e; }

.source-tab.active {
    color: #e94560;
    border-bottom-color: #e94560;
}

/* Mobile */
@media (max-width: 768px) {
    .books-sidebar {
        position: relative;
        width: 100%;
        height: auto;
        padding: 1rem;
    }
    .books-main {
        margin-left: 0;
        padding: 1rem;
    }
    .books-layout { flex-direction: column; }
    .books-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
