/* ========================================================================== */
/* Chapters (listing grid and viewer basics)                                   */
/* Load order: 5                                                               */
/* Grid/list tiles for chapters and minimal chapter viewer container/toolbar.  */
/* ========================================================================== */
/* Chapters */
.chapters-section {
    margin-top: 40px;
}

.chapters-section h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--text-primary);
    text-align: center;
}

.chapter-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-height: calc(15 * 1.5em + 15 * 20px + 40px);
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    scrollbar-gutter: stable;
}

.chapter-item {
    margin: 0;
    min-width: 0;
}

.chapter-link {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 18px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    min-height: 40px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-link:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.chapter-number {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-link.read {
    opacity: 0.6;
}

.chapter-link.read .chapter-number {
    color: var(--text-secondary);
}

.chapter-title {
    display: block;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.no-chapters {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

.no-chapters p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

/* Chapter viewer basics (rest enhanced in components.css) */
.toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 10px 12px;
    background: rgba(20, 21, 24, 0.9);
    border-bottom: 1px solid #222;
    backdrop-filter: blur(6px);
}

.blacklist-delete-chapter-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.blacklist-delete-chapter-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

.blacklist-delete-chapter-btn:active {
    transform: translateY(0);
}

.delete-chapter-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.delete-chapter-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.delete-chapter-btn:active {
    transform: translateY(0);
}

.chapter-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 56px 12px 40px;
}

.page {
    margin: 0;
}

.page img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    user-select: none;
}

/* Mobile chapter list overrides */
@media (max-width: 768px) {
    .chapter-list {
        grid-template-columns: 1fr !important;
        gap: 12px;
        display: grid !important;
        max-height: calc(15 * 1.5em + 14 * 12px);
        overflow-y: auto !important;
        overflow-x: hidden;
        scrollbar-gutter: stable;
    }

    .chapter-link {
        padding: 15px;
        text-align: center;
    }

    .chapter-number {
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .chapter-title {
        font-size: 0.9rem;
    }
}