/* Comic Reader Modal Styles */
.comic-reader-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Prevent pull-to-refresh and bounce on mobile */
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
}

.comic-reader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1;
    transition: background-color 0.5s ease;
}

.comic-reader-container {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    flex-direction: column;
}

.comic-reader-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    z-index: 3;
    flex-shrink: 0;
    transition: background-color 0.5s ease;
}

.comic-reader-title {
    font-size: 1.1rem;
    font-weight: 500;
}

.comic-reader-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comic-reader-progress-bar {
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.comic-reader-progress-fill {
    height: 100%;
    background: #4CAF50;
    width: 0%;
    transition: width 0.3s ease;
}

.comic-reader-progress-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    min-width: 35px;
}

.comic-reader-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.comic-reader-page-info {
    font-size: 0.9rem;
    opacity: 0.8;
}

#comicReaderClose {
    cursor: pointer;
}

.comic-reader-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 2rem;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    z-index: 3;
    transition: background-color 0.5s ease;
}

.comic-reader-footer-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.comic-reader-footer .zoom-btn {
    min-width: 40px;
    height: 32px;
    padding: 0.25rem 0.5rem;
    border-color: rgba(255, 255, 255, 0.3);
}

.comic-reader-footer .zoom-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.comic-reader-footer .page-selector {
    min-width: 150px;
    max-width: 250px;
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.comic-reader-footer .page-selector:focus {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.1);
}

.comic-reader-footer .page-selector option {
    background-color: #212529;
    color: white;
}

.comic-reader-swiper {
    flex: 1;
    width: 100%;
    height: 100%;
}

.comic-reader-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: black;
    overflow: hidden;
    transition: background-color 0.5s ease;
}

/* Swiper zoom container styles */
.comic-reader-swiper .swiper-zoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.comic-reader-swiper .swiper-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: pan-x pan-y pinch-zoom;
}

.comic-reader-swiper .swiper-button-next,
.comic-reader-swiper .swiper-button-prev {
    color: white;
    background-color: transparent;
    width: 100px;
    height: 100%;
    top: 0;
    margin-top: 0;
    border-radius: 0;
    transition: background-color 0.2s ease;
}

.comic-reader-swiper .swiper-button-next:hover,
.comic-reader-swiper .swiper-button-prev:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.comic-reader-swiper .swiper-button-next {
    right: 0;
    justify-content: flex-end;
    padding-right: 20px;
}

.comic-reader-swiper .swiper-button-prev {
    left: 0;
    justify-content: flex-start;
    padding-left: 20px;
}

.comic-reader-swiper .swiper-button-next:after,
.comic-reader-swiper .swiper-button-prev:after {
    font-size: 1.5rem;
}

/* Loading spinner for comic pages */
.comic-page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: white;
}

.comic-page-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Tablet and mobile: immersive reader chrome */
@media (max-width: 1024px) {
    .comic-reader-header {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.5s ease;
    }

    .comic-reader-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        transition: transform 0.3s ease, opacity 0.3s ease, background-color 0.5s ease;
    }

    .comic-reader-container.reader-chrome-hidden .comic-reader-header {
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
    }

    .comic-reader-container.reader-chrome-hidden .comic-reader-footer {
        transform: translateY(100%);
        opacity: 0;
        pointer-events: none;
    }
}

/* Mobile responsive styles for comic reader */
@media (max-width: 768px) {
    .comic-reader-header {
        padding: 0.5rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .comic-reader-title {
        font-size: 0.9rem;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .comic-reader-progress {
        display: none;
    }

    .comic-reader-controls {
        gap: 0.5rem;
    }

    .comic-reader-page-info {
        font-size: 0.8rem;
    }

    .comic-reader-footer {
        padding: 0.5rem 1rem;
    }

    .comic-reader-swiper .swiper-button-next,
    .comic-reader-swiper .swiper-button-prev {
        width: 36px;
    }

    .comic-reader-swiper .swiper-button-next:after,
    .comic-reader-swiper .swiper-button-prev:after {
        font-size: 1rem;
    }

    /* Ensure images fit properly on mobile */
    .comic-reader-swiper .swiper-slide img {
        width: auto;
        height: auto;
        max-width: 100%;
        max-height: 100%;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .comic-reader-header {
        padding: 0.4rem 0.75rem;
    }

    .comic-reader-title {
        font-size: 0.8rem;
        max-width: 60%;
    }

    .comic-reader-page-info {
        font-size: 0.75rem;
    }

    /* Hide navigation arrows on very small screens - use swipe */
    .comic-reader-swiper .swiper-button-next,
    .comic-reader-swiper .swiper-button-prev {
        display: none;
    }
}

/* Light background overrides — toggled via JS when page edge color is light */
.comic-reader-container.reader-light-bg .comic-reader-header,
.comic-reader-container.reader-light-bg .comic-reader-footer {
    color: #212529;
}

.comic-reader-container.reader-light-bg .comic-reader-title,
.comic-reader-container.reader-light-bg .comic-reader-page-info {
    color: #212529;
}

.comic-reader-container.reader-light-bg .comic-reader-progress-text {
    color: rgba(0, 0, 0, 0.6);
}

.comic-reader-container.reader-light-bg .btn-outline-light {
    color: #212529;
    border-color: #212529;
}

.comic-reader-container.reader-light-bg .btn-outline-light:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #212529;
}

.comic-reader-container.reader-light-bg .page-selector {
    background-color: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.3);
    color: #212529;
}

.comic-reader-container.reader-light-bg .page-selector:focus {
    background-color: rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.5);
    color: #212529;
    box-shadow: 0 0 0 0.25rem rgba(0, 0, 0, 0.1);
}

.comic-reader-container.reader-light-bg .zoom-btn {
    border-color: rgba(0, 0, 0, 0.3);
}

.comic-reader-container.reader-light-bg .zoom-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.5);
}

.comic-reader-container.reader-light-bg .text-light {
    color: #212529 !important;
}

/* Zoom indicator hint */
.comic-reader-zoom-hint {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10;
}

.comic-reader-zoom-hint.visible {
    opacity: 1;
}

/* Next Issue Overlay Styles */
.next-issue-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.next-issue-panel {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.next-issue-panel h4 {
    color: white;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.next-issue-thumbnail-container {
    width: 140px;
    height: 200px;
    margin: 0 auto 1rem;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.next-issue-thumbnail-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.next-issue-name {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.next-issue-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.next-issue-buttons .btn {
    min-width: 100px;
}

/* Mobile responsive for next issue overlay */
@media (max-width: 480px) {
    .next-issue-panel {
        padding: 1.5rem;
        max-width: 280px;
    }

    .next-issue-panel h4 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }

    .next-issue-thumbnail-container {
        width: 100px;
        height: 150px;
    }

    .next-issue-name {
        font-size: 0.85rem;
    }

    .next-issue-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    .next-issue-buttons .btn {
        width: 100%;
    }
}

/* Resume Reading Overlay */
.resume-reading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.resume-reading-panel {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.resume-reading-panel h4 {
    color: white;
    margin-bottom: 1rem;
    font-weight: 600;
}

.resume-reading-info {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.resume-reading-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.resume-reading-buttons .btn {
    min-width: 100px;
}

/* Mobile responsive for resume reading overlay */
@media (max-width: 480px) {
    .resume-reading-panel {
        padding: 1.5rem;
        max-width: 280px;
    }

    .resume-reading-panel h4 {
        font-size: 1.1rem;
    }

    .resume-reading-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }

    .resume-reading-buttons .btn {
        width: 100%;
    }
}
