/**
 * Chapters Body Styles
 * Section below reader with series info, chapters list, and sidebar
 */

/* Flex chain: extend chapters body to fill remaining page height */
.site-main:has(.kcr-chapters-body-wrapper) {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

.site-main:has(.kcr-chapters-body-wrapper) > .content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-area:has(.kcr-chapters-body-wrapper) > .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.content-area:has(.kcr-chapters-body-wrapper) article {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content-area:has(.kcr-chapters-body-wrapper) .entry-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Remove footer gap on reader pages */
.site-container:has(.kcr-chapters-body-wrapper) > .site-footer {
    margin-top: 0;
}

.kcr-chapters-body-wrapper {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    background: #f5f5f5;
    flex: 1;
    display: flex;
    flex-direction: column;
    border: none;
    box-shadow: none;
    outline: none;
    overflow: hidden;
}

/* Mobile: Use 100% width to prevent horizontal scroll */
@media (max-width: 768px) {
    .kcr-chapters-body-wrapper {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        max-width: 100%;
        background: #fff;
    }

    .kcr-chapters-body {
        padding: 40px 5px;
    }
}

/* Side panels no longer needed - wrapper background handles gray sides */
.kcr-chapters-background-left,
.kcr-chapters-background-right {
    display: none;
}

.kcr-chapters-body {
    position: relative;
    z-index: 1;
    background: #fff;
    padding: 60px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    border: none;
    box-shadow: none;
    outline: none;
    overflow-x: hidden;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.kcr-chapters-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 300px 1fr 250px;
    gap: 40px;
    flex: 1;
}

/* Left Column: Series Info */
.kcr-series-info {
    position: sticky;
    top: 100px;
    height: fit-content;
    z-index: 10;
    align-self: start;
}

.kcr-series-cover {
    width: 100%;
    max-width: 250px;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: none;
}

.kcr-series-cover-image {
    width: 100%;
    height: auto;
    display: block;
}

.kcr-series-meta {
    padding: 20px 0;
}

.kcr-series-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 15px 0;
    color: #1a1a1a;
    line-height: 1.3;
}

/* Author Credits */
.kcr-author-credits {
    font-size: 14px;
    color: #555;
    margin-bottom: 12px;
    line-height: 1.5;
}

.kcr-author-role {
    color: #999;
    font-size: 12px;
}

/* Genre Badges */
.kcr-genre-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.kcr-genre-badge {
    display: inline-block;
    padding: 3px 10px;
    background: #f0f0f0;
    color: #555;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

.kcr-series-description {
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    margin-bottom: 20px;
}

.kcr-series-description p {
    margin: 0 0 10px 0;
}

.kcr-series-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kcr-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.kcr-stat-label {
    font-weight: 600;
    color: #666;
}

.kcr-stat-value {
    color: #1a1a1a;
}

.kcr-stat-badge {
    background: #d63638;
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.kcr-mature-badge {
    background: #d63638;
}

/* Center Column: Chapters List */
.kcr-chapters-list {
    min-width: 0;
}

.kcr-chapters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}

.kcr-chapters-heading {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #1a1a1a;
}

.kcr-chapters-sort-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.kcr-chapters-sort-btn:hover {
    background: #e5e5e5;
    color: #1a1a1a;
}

.kcr-chapters-sort-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Chapter Pagination */
.kcr-chapters-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.kcr-chapters-pagination:empty {
    display: none;
}

.kcr-chapters-pagination .kcr-page-btn {
    padding: 5px 14px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.kcr-chapters-pagination .kcr-page-btn:hover {
    background: #e0e0e0;
    color: #1a1a1a;
}

.kcr-chapters-pagination .kcr-page-btn.kcr-active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* Hidden chapters (JS pagination) */
.kcr-chapter-item.kcr-hidden {
    display: none;
}

.kcr-chapters-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kcr-chapter-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 12px 12px 30px;
    background: #f9f9f9;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
}

.kcr-chapter-item:hover {
    background: #f0f0f0;
    transform: translateX(5px);
}

.kcr-chapter-item.kcr-current-chapter {
    background: #e6f7ff;
}

.kcr-chapter-thumbnail {
    width: 142px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: #ddd;
}

.kcr-chapter-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kcr-chapter-info {
    flex: 1;
    min-width: 0;
}

.kcr-chapter-number {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.kcr-chapter-title-text {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bookmark Badge */
.kcr-chapter-thumbnail {
    position: relative;
}

.kcr-bookmark-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(255, 203, 5, 0.95);
    color: #1a1a1a;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.kcr-bookmark-badge .dashicons {
    font-family: dashicons !important;
    display: inline-block;
    font-size: 14px;
    width: 14px;
    height: 14px;
    line-height: 1;
    font-style: normal;
    font-weight: normal;
    speak: never;
    text-decoration: inherit;
    text-transform: none;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.kcr-bookmark-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #ffcb05;
    margin-top: 4px;
}

.kcr-bookmark-info .dashicons {
    font-family: dashicons !important;
    display: inline-block;
    font-size: 14px;
    width: 14px;
    height: 14px;
    line-height: 1;
    font-style: normal;
    font-weight: normal;
    speak: never;
    text-decoration: inherit;
    text-transform: none;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.kcr-chapter-item.kcr-has-bookmark {
    border-left: 3px solid #ffcb05;
}

/* Right Sidebar: Social & Metadata */
.kcr-series-sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
    align-self: start;
    z-index: 10;
}

.kcr-sidebar-section {
    margin-bottom: 30px;
}

.kcr-sidebar-heading {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #1a1a1a;
}

.kcr-support-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.kcr-support-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: #FF5E5B;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.kcr-support-btn:hover {
    background: #ff4744;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 94, 91, 0.3);
}

.kcr-support-btn .dashicons {
    font-size: 18px;
}

.kcr-social-links {
    display: flex;
    gap: 10px;
}

.kcr-social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: #f0f0f0;
    color: #666;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.kcr-social-btn:hover {
    background: #00d9ff;
    color: #fff;
    transform: translateY(-2px);
}

.kcr-social-btn.kcr-copy-link-btn:hover {
    background: #00d9ff;
}

.kcr-social-btn .dashicons {
    font-size: 20px;
    transition: all 0.2s;
}

/* Purchase Card */
.kcr-purchase-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.kcr-purchase-cover {
    width: 100%;
    max-width: 180px;
    margin: 0 auto 12px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kcr-purchase-cover img {
    width: 100%;
    height: auto;
    display: block;
}

.kcr-purchase-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
    line-height: 1.4;
}

.kcr-purchase-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kcr-purchase-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    background: #1a1a1a;
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.kcr-purchase-btn:hover {
    background: #333;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Purchase Header Bar */
.kcr-purchase-header-bar {
    background: #1a1a1a;
    color: #fff;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px 4px 0 0;
}

.kcr-purchase-header-bar + .kcr-purchase-card {
    border-radius: 0 0 8px 8px;
    margin-top: 0;
}

/* Author Bio Card */
.kcr-author-bio-card {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.kcr-author-photo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 10px;
    display: block;
}

.kcr-author-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.kcr-author-bio-text {
    font-size: 13px;
    line-height: 1.5;
    color: #666;
}

.kcr-author-role-label {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .kcr-chapters-container {
        grid-template-columns: 250px 1fr;
        gap: 30px;
    }

    .kcr-series-sidebar {
        position: static;
        grid-column: 1 / -1;
        display: flex;
        gap: 30px;
        width: 100%;
        right: auto;
    }

    .kcr-sidebar-section {
        flex: 1;
    }

    .kcr-purchase-card,
    .kcr-author-bio-card {
        text-align: left;
    }

    .kcr-purchase-cover {
        margin: 0 0 12px;
        max-width: 120px;
    }

    .kcr-author-photo {
        margin: 0 0 10px;
    }

    .kcr-purchase-buttons {
        flex-direction: row;
    }
}

@media (max-width: 768px) {
    .kcr-chapters-container {
        grid-template-columns: 1fr;
        gap: 30px;
        padding: 0 5px;  /* Minimal padding for edge protection */
    }

    .kcr-series-info {
        position: static;
        display: flex;
        gap: 20px;
    }

    .kcr-series-cover {
        width: 150px;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .kcr-series-meta {
        flex: 1;
        padding: 0;
    }

    .kcr-series-title {
        font-size: 20px;
    }

    .kcr-chapter-thumbnail {
        width: 120px;
        height: 68px;
    }

    .kcr-sidebar-section {
        margin-bottom: 20px;
    }

    .kcr-series-sidebar {
        flex-direction: column;
    }

    .kcr-purchase-card,
    .kcr-author-bio-card {
        text-align: center;
    }

    .kcr-purchase-cover {
        margin: 0 auto 12px;
    }

    .kcr-author-photo {
        margin: 0 auto 10px;
    }

    .kcr-purchase-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .kcr-chapters-body {
        padding: 40px 0;
    }

    .kcr-series-info {
        flex-direction: column;
    }

    .kcr-series-cover {
        width: 100%;
    }

    .kcr-chapter-item {
        gap: 10px;
        padding: 10px;
    }

    .kcr-chapter-thumbnail {
        width: 100px;
        height: 56px;
    }

    .kcr-chapters-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .kcr-chapters-sort-btn {
        font-size: 12px;
        padding: 5px 10px;
    }

    .kcr-chapters-pagination {
        gap: 4px;
    }

    .kcr-chapters-pagination .kcr-page-btn {
        padding: 4px 10px;
        font-size: 12px;
    }

    .kcr-social-links {
        flex-wrap: wrap;
    }
}
