/* ==========================================================================
   library.css — shared styles for the Library section
   Used by library.html (public page) and study-library.html (Study Hub).
   ========================================================================== */

.library-section {
    padding-top: 150px;
    min-height: 70vh;
    padding-bottom: 80px;
}

/* ── Filter chips ── */
.lib-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 2rem;
}
.lib-filter-chip {
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border-glass);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}
.lib-filter-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(16, 185, 129, 0.4);
}
.lib-filter-chip.active {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem auto 2rem;
}
.books-grid-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem 1rem;
    font-size: 1rem;
}

.book-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}
.book-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
}
[data-theme="dark"] .book-card:hover {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.book-cover {
    width: 160px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    margin-bottom: 1.8rem;
    transition: transform 0.3s;
    object-fit: cover;
}
.book-card:hover .book-cover {
    transform: scale(1.05);
}
.book-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.book-meta {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* ── Ratings row (injected by book-ratings.js) ── */
.book-rating-display {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    color: #fbbf24;
    font-size: 1rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.book-rating-display:hover,
.book-rating-display:focus-visible {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.22);
    outline: none;
    transform: translateY(-1px);
}
.book-rating-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 0.25rem;
}
.book-rating-user {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.35rem;
    font-size: 0.75rem;
    color: #34d399;
}

/* ── Card actions ── */
.book-actions {
    display: flex;
    gap: 1rem;
    width: 100%;
    margin-top: auto;
}
.book-actions .btn {
    flex: 1;
    padding: 0.7rem 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
}
.book-actions .btn-primary {
    background: #10b981;
    border: none;
    color: #fff;
}
.book-actions .btn-primary:hover {
    background: #059669;
}
.book-actions .btn-purchase {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: #fff;
    cursor: pointer;
}
.book-actions .btn-purchase:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
}
.book-actions .btn-coming-soon {
    background: var(--bg-dark);
    border: 1px dashed var(--border-glass);
    color: var(--text-muted);
    cursor: not-allowed;
}

.book-price-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    margin-bottom: 1rem;
}
.book-free-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    margin-bottom: 1rem;
}

/* ── Purchase / rating modals ── */
.purchase-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.purchase-modal-overlay.active {
    display: flex;
}
.purchase-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 2.5rem;
    max-width: 420px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.purchase-modal h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}
.purchase-modal p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}
.purchase-modal .cost-display {
    font-size: 2rem;
    font-weight: 800;
    color: #f59e0b;
    margin-bottom: 1.5rem;
}
.purchase-modal .modal-btns {
    display: flex;
    gap: 1rem;
}
.purchase-modal .modal-btns .btn {
    flex: 1;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}
.purchase-modal .btn-cancel {
    background: var(--bg-dark);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}
.purchase-modal .btn-confirm-buy {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: #fff;
}
.purchase-modal .insufficient-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: #ef4444;
    font-size: 0.9rem;
    font-weight: 600;
}
.purchase-modal .earn-tips {
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}
.purchase-modal .earn-tips li {
    margin-bottom: 0.4rem;
    list-style: disc;
    margin-left: 1rem;
}

/* ── Reviews list inside rating modal ── */
.rate-reviews {
    text-align: left;
    margin-bottom: 1.5rem;
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid var(--border-glass);
    padding-top: 1rem;
}
.rate-reviews-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.75rem;
}
.rate-review-item {
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.06);
    margin-bottom: 0.6rem;
}
[data-theme="dark"] .rate-review-item {
    background: rgba(255, 255, 255, 0.05);
}
.rate-review-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.rate-review-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}
.rate-review-stars {
    color: #fbbf24;
    font-size: 0.8rem;
    white-space: nowrap;
}
.rate-review-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
    word-break: break-word;
}
.rate-reviews-empty {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.5rem 0;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .library-section {
        padding-top: 100px;
        padding-bottom: 50px;
    }
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
        margin-top: 2rem;
    }
    .book-card {
        padding: 1.5rem;
    }
    .book-cover {
        width: 140px;
        margin-bottom: 1.5rem;
    }
    .book-title {
        font-size: 1.15rem;
    }
    .book-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    .book-actions .btn {
        width: 100%;
        min-height: 48px;
    }
    .purchase-modal {
        padding: 2rem 1.5rem;
    }
    .purchase-modal .modal-btns {
        flex-direction: column;
    }
}
