/* Books Page Styles */

.books-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-color, #fff);
    color: var(--text-color, #333);
}

/* Override theme's article max-width for books page */
article.books-container {
    max-width: 100% !important;
    width: 100%;
}

/* Stats */
.books-stats {
    text-align: center;
    font-size: 1rem;
    color: #666;
    margin-bottom: 25px;
}

.books-stats strong {
    color: #2d8c3c;
    font-weight: 600;
}

.books-stats .divider {
    margin: 0 15px;
    color: #ddd;
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
    max-width: 100%;
}

/* Responsive - use auto-fill on larger screens */
@media (min-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* Book Card */
.book-card {
    position: relative;
    display: block;
    background: white;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

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

/* Status Badge */
.book-status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 6px;
    font-size: 0.6rem;
    font-weight: 600;
    border-radius: 4px;
    z-index: 10;
}

.book-status-badge.status-reading {
    background: #3498db;
    color: white;
}

.book-status-badge.status-wish {
    background: #27ae60;
    color: white;
}

/* Cover */
.book-cover {
    position: relative;
    width: 100%;
    padding-bottom: 145%;
    overflow: hidden;
    background: #f5f0e6;
    border-radius: 8px 8px 0 0;
}

.book-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 80%;
    height: 80%;
    object-fit: cover;
    margin: 10% auto;
}

.cover-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f0e6 0%, #e8dcc8 100%);
    font-size: 3rem;
    color: #c9b896;
}

/* Book Info */
.book-info {
    padding: 10px;
}

.book-card .book-title,
.book-card h3.book-title {
    font-size: 0.75rem !important;
    font-weight: 600;
    color: var(--text-color, #1a1a1a);
    margin: 0 0 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.2rem;
    line-height: 1.1rem;
    white-space: normal;
}

.book-author {
    font-size: 0.65rem;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
}

/* Dark Mode visibility fix */
@media (prefers-color-scheme: dark) {

    .book-card .book-title,
    .book-card h3.book-title {
        color: #f0f0f0 !important;
    }

    .book-author {
        color: #aaa;
    }
}

/* Book Meta (Rating & Date) */
.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.book-rating {
    display: flex;
    gap: 1px;
}

.book-rating .star {
    color: #ddd;
    font-size: 0.75rem;
}

.book-rating .star.filled {
    color: #ffa500;
}

.book-date {
    font-size: 0.7rem;
    color: #999;
}

/* Empty State */
.books-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 1.1rem;
}

/* Book Tooltip */
.book-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 280px;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.5;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    margin-bottom: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.book-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.92);
}

.book-card:hover .book-tooltip {
    opacity: 1;
    visibility: visible;
}

.book-tooltip p {
    margin: 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-indent: 0;
    padding-left: 0;
}

.book-tooltip p:first-child {
    margin-top: 0;
}

.book-tooltip p:last-child {
    margin-bottom: 0;
}

.book-tooltip strong {
    color: #2d8c3c;
}

.book-tooltip .rating-highlight {
    color: #ffa500;
    font-weight: bold;
}

.book-tooltip .tooltip-comment {
    font-style: italic;
    color: #ccc;
    white-space: normal;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hide tooltip on small screens */
@media (max-width: 768px) {
    .book-tooltip {
        display: none;
    }
}

/* Responsive Design */
/* Standardize Grid Layout with Games/Movies */

/* Desktop default: 3 columns */
@media (min-width: 768px) {
    .books-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large screens: max 4 columns */
@media (min-width: 1200px) {
    .books-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .books-container {
        padding: 10px;
    }

    .books-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .book-info {
        padding: 6px;
    }

    .book-card .book-title,
    .book-card h3.book-title {
        font-size: 0.6rem !important;
        line-height: 0.9rem;
        height: 1.8rem;
    }

    .book-author {
        font-size: 0.55rem;
    }

    .book-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .book-rating .star {
        font-size: 0.65rem;
    }

    .book-date {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .books-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .book-card {
        border-radius: 4px;
    }

    .book-info {
        padding: 5px;
    }

    .book-card .book-title,
    .book-card h3.book-title {
        font-size: 0.55rem !important;
    }

    .book-meta {
        margin-top: 4px;
    }
}

@media (max-width: 360px) {
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}

/* Theme support */
[data-theme="dark"] .book-card {
    background: #2d2d2d;
}

[data-theme="dark"] .book-cover {
    background: #3d3d3d;
}

[data-theme="dark"] .cover-placeholder {
    background: linear-gradient(135deg, #3d3d3d 0%, #2d2d2d 100%);
    color: #666;
}

[data-theme="dark"] .book-card .book-title,
[data-theme="dark"] .book-card h3.book-title {
    color: #f0f0f0 !important;
}

[data-theme="dark"] .book-author {
    color: #aaa;
}

[data-theme="dark"] .books-stats {
    color: #aaa;
}

[data-theme="dark"] .books-stats strong {
    color: #2d8c3c;
}

/* Controls */
.books-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
    padding: 12px 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

/* Link Style Mode Toggle */
.view-mode-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.mode-link {
    text-decoration: none;
    color: #999;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.mode-link:hover {
    color: #2d8c3c;
}

.mode-link.active {
    color: #2d8c3c;
    font-weight: 600;
}

.mode-divider {
    color: #ccc;
    font-size: 0.85rem;
}

[data-theme="dark"] .mode-link,
.dark-mode .mode-link {
    color: #777;
}

[data-theme="dark"] .mode-link:hover,
.dark-mode .mode-link:hover,
[data-theme="dark"] .mode-link.active,
.dark-mode .mode-link.active {
    color: #2d8c3c;
}

[data-theme="dark"] .mode-divider,
.dark-mode .mode-divider {
    color: #555;
}

[data-theme="dark"] .books-controls,
.dark-mode .books-controls {
    background: #2a2a2a;
}

/* Minimalist Mode */
.books-grid.minimal-mode {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Color palette for minimal mode rows */
.books-grid.minimal-mode .book-card:nth-child(8n+1) {
    background-color: rgba(139, 69, 19, 0.06);
}

.books-grid.minimal-mode .book-card:nth-child(8n+2) {
    background-color: rgba(22, 163, 74, 0.06);
}

.books-grid.minimal-mode .book-card:nth-child(8n+3) {
    background-color: rgba(37, 99, 235, 0.06);
}

.books-grid.minimal-mode .book-card:nth-child(8n+4) {
    background-color: rgba(147, 51, 234, 0.06);
}

.books-grid.minimal-mode .book-card:nth-child(8n+5) {
    background-color: rgba(234, 88, 12, 0.06);
}

.books-grid.minimal-mode .book-card:nth-child(8n+6) {
    background-color: rgba(8, 145, 178, 0.06);
}

.books-grid.minimal-mode .book-card:nth-child(8n+7) {
    background-color: rgba(190, 24, 93, 0.06);
}

.books-grid.minimal-mode .book-card:nth-child(8n+8) {
    background-color: rgba(205, 133, 63, 0.06);
}

.books-grid.minimal-mode .book-card {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.books-grid.minimal-mode .book-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--border-color, #e0e0e0);
}

/* Ensure hovered card is above others */
.books-grid.minimal-mode .book-card {
    position: relative;
    z-index: 1;
}

.books-grid.minimal-mode .book-card:hover {
    z-index: 100;
}

.books-grid.minimal-mode .book-cover {
    display: none;
}

.books-grid.minimal-mode .book-info {
    flex: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.books-grid.minimal-mode .book-card .book-title,
.books-grid.minimal-mode .book-card h3.book-title {
    height: auto;
    margin: 0;
    font-size: 0.75rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    color: #1a1a1a !important;
    font-weight: 400;
}

/* Dark mode override for minimal mode title */
[data-theme="dark"] .books-grid.minimal-mode .book-card .book-title,
[data-theme="dark"] .books-grid.minimal-mode .book-card h3.book-title {
    color: #f0f0f0 !important;
}

.books-grid.minimal-mode .book-author {
    color: #666;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.books-grid.minimal-mode .book-meta {
    margin-top: 0;
    gap: 15px;
    flex-shrink: 0;
}

.books-grid.minimal-mode .book-date {
    width: 80px;
    text-align: right;
}

/* Tooltip with cover in minimal mode */
.books-grid.minimal-mode .book-tooltip {
    display: flex;
    gap: 12px;
    max-width: 380px;
    left: 0;
    transform: none;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.95);
}

.books-grid.minimal-mode .book-tooltip::after {
    left: 60px;
}

@media (max-width: 768px) {
    .books-grid.minimal-mode .book-card {
        flex-wrap: wrap;
        gap: 5px;
    }

    .books-grid.minimal-mode .book-info {
        flex-wrap: wrap;
    }

    .books-grid.minimal-mode .book-author {
        max-width: 100%;
        width: 100%;
    }
}

/* Tooltip Content Layout */
.tooltip-poster {
    flex-shrink: 0;
    width: 80px;
    border-radius: 4px;
    overflow: hidden;
}

.tooltip-poster img {
    width: 100%;
    height: auto;
    display: block;
}

.tooltip-content {
    flex: 1;
    min-width: 0;
}
/* Force Light Theme */
[data-theme="light"] .books-container,
.books-container[data-theme="light"] {
    background-color: #ffffff !important;
    color: #333333 !important;
}

[data-theme="light"] .book-card,
.book-card[data-theme="light"] {
    background: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
}

[data-theme="light"] .book-card .book-title,
.book-card[data-theme="light"] .book-title {
    color: #333 !important;
}

[data-theme="light"] .books-header,
.books-header[data-theme="light"] {
    color: #333 !important;
}

[data-theme="light"] .books-title,
.books-title[data-theme="light"] {
    color: #333 !important;
}

[data-theme="light"] .books-stats,
.books-stats[data-theme="light"] {
    color: #666 !important;
}

[data-theme="light"] .book-tooltip,
.book-tooltip[data-theme="light"] {
    background: rgba(255, 255, 255, 0.95) !important;
    color: #333 !important;
    border: 1px solid #e0e0e0 !important;
}

[data-theme="light"] .book-tooltip::after,
.book-tooltip[data-theme="light"]::after {
    border-top-color: rgba(255, 255, 255, 0.95) !important;
}

[data-theme="light"] .mode-link,
.mode-link[data-theme="light"] {
    color: #666 !important;
}

[data-theme="light"] .mode-link.active,
.mode-link.active[data-theme="light"] {
    color: #2d8c3c !important;
}

/* Infinite Scroll Loading Spinner */
.infinite-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #666;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2d8c3c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Card click fix - ensure entire card is clickable */
.book-card {
    position: relative;
    z-index: 1;
}

.book-card:hover {
    z-index: 100;
}

.book-card:hover .book-tooltip {
    z-index: 101;
}
