/* ===== TOC BUTTON SECTION ===== */
.toc-button-section {
    margin-bottom: 16px;
}

.toc-popup-btn {
    width: 100%;
    padding: 14px 20px;
    background: var(--bg-card, #141414);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 12px;
    color: var(--text, #e8e8e8);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.toc-popup-btn:hover {
    background: var(--bg-secondary, #1a1a1a);
    border-color: var(--primary, #ff6b35);
}

.toc-icon {
    font-size: 18px;
}

.toc-text {
    flex: 1;
    font-weight: 600;
    text-align: left;
}

.toc-count {
    font-size: 12px;
    background: var(--bg-secondary, #1a1a1a);
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--text-secondary, #888);
}

.toc-popup-btn:hover .toc-count {
    background: var(--primary, #ff6b35);
    color: white;
}

.toc-arrow {
    color: var(--text-secondary, #888);
    transition: transform 0.2s;
}

.toc-popup-btn:hover .toc-arrow {
    transform: translateX(4px);
    color: var(--primary, #ff6b35);
}

/* ===== CHAPTER SECTION - LATEST 5 ===== */
.chapter-section {
    background: var(--bg-card, #141414);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.chapter-header .section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #e8e8e8);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Latest chapters list */
#latestChaptersList {
    padding: 8px 0;
}

#latestChaptersList .chapter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.05));
    transition: background 0.2s;
}

#latestChaptersList .chapter-item:last-child {
    border-bottom: none;
}

#latestChaptersList .chapter-item:hover {
    background: rgba(255,255,255,0.03);
}

#latestChaptersList .chapter-number {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #1a1a1a);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #888);
    flex-shrink: 0;
    padding: 0 6px;
}

#latestChaptersList .chapter-title {
    flex: 1;
    min-width: 0;
}

#latestChaptersList .chapter-title a {
    color: var(--text, #e8e8e8);
    text-decoration: none;
    font-size: 14px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#latestChaptersList .chapter-title a:hover {
    color: var(--primary, #ff6b35);
}

#latestChaptersList .chapter-views {
    font-size: 12px;
    color: var(--text-muted, #666);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== FULL TOC MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 16px;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg, #0a0a0a);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    border: 1px solid var(--border, rgba(255,255,255,0.08));
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text, #e8e8e8);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text, #e8e8e8);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Modal search & sort */
.toc-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
}

.toc-search-bar input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary, #1a1a1a);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 10px;
    color: var(--text, #e8e8e8);
    font-size: 14px;
}

.toc-search-bar input:focus {
    outline: none;
    border-color: var(--primary, #ff6b35);
}

.toc-search-bar .sort-btn {
    padding: 12px 16px;
    background: var(--bg-secondary, #1a1a1a);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 10px;
    color: var(--text-secondary, #888);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.toc-search-bar .sort-btn:hover {
    border-color: var(--primary, #ff6b35);
    color: var(--text, #e8e8e8);
}

/* Full TOC chapter list in modal */
#fullTocList {
    padding: 4px 0;
    max-height: 60vh;
    overflow-y: auto;
}

#fullTocList .chapter-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.05));
    transition: background 0.15s;
}

#fullTocList .chapter-item:last-child {
    border-bottom: none;
}

#fullTocList .chapter-item:hover {
    background: rgba(255,255,255,0.03);
    margin: 0 -4px;
    padding-left: 4px;
    padding-right: 4px;
    border-radius: 8px;
}

#fullTocList .chapter-number {
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #1a1a1a);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary, #888);
    flex-shrink: 0;
    padding: 0 6px;
}

#fullTocList .chapter-title {
    flex: 1;
    min-width: 0;
}

#fullTocList .chapter-title a {
    color: var(--text, #e8e8e8);
    text-decoration: none;
    font-size: 14px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#fullTocList .chapter-title a:hover {
    color: var(--primary, #ff6b35);
}

#fullTocList .chapter-views {
    font-size: 12px;
    color: var(--text-muted, #666);
    flex-shrink: 0;
}

/* ===== COMMENTS SECTION ===== */
.comments-section-wrapper {
    margin-bottom: 16px;
    background: var(--bg-card, #141414);
    border-radius: 12px;
    overflow: hidden;
}

/* ===== MOBILE FIXES ===== */
@media (max-width: 768px) {
    /* Modal full screen on mobile */
    .modal {
        padding: 0 !important;
    }
    
    .modal-content {
        max-height: 100vh !important;
        border-radius: 0 !important;
    }
}
